--- /dev/null
+# chown -R mysql:mysql /var/lib/mysql/
+# mysqld_safe &
+# mysql -u digger -p diggersdigest < /var/lib/mysql/diggersdigest.sql
+
+
+import os
+from records import models as rec_models
+
+from diggersdigest import settings
+
+
+
+# Label
+label_set = set([shop.label for shop in rec_models.Shop.objects.all()])
+count = 0
+for lab in label_set:
+ obj, created = rec_models.Label.objects.get_or_create(name = lab)
+ if created:
+ print "Create new Label : %s" % obj.name
+ count += 1
+print "%d fiches label créées" % count
+
+# Artist
+artist_set = set([shop.artiste for shop in rec_models.Shop.objects.all()])
+count = 0
+for artist in artist_set:
+ obj, created = rec_models.Artist.objects.get_or_create(name = artist)
+ if created:
+ print "Create new Artist : %s" % obj.name
+ count += 1
+
+print "%d fiches artiste créées" % count
+
+# Pays
+country_set = set([shop.pays for shop in rec_models.Shop.objects.all()])
+count = 0
+for country in country_set:
+ obj, created = rec_models.Country.objects.get_or_create(name = country)
+ if created:
+ print "Create new Country : %s" % obj.name
+ count += 1
+
+print "%d fiches pays créées" % count
+
+# Theme
+[theme for theme in rec_models.Theme.objects.all()]
+
+
+# MP3
+mp3_shop_list = [shop.mp3 for shop in rec_models.Shop.objects.all()]
+
+# MP3 for mix
+mp3_mix_list = [mix.mp3 for mix in rec_models.Mix.objects.all()]
+
+AUDIO_PATH = os.path.join(settings.MEDIA_ROOT, 'uploads/audio/')
+MIX_PATH = os.path.join(AUDIO_PATH, 'mixes')
+RECORDS_PATH = os.path.join(AUDIO_PATH, "records")
+
+# Check mp3 in media upload path
+def check_mp3(file_list, file_path):
+ file_exists = [os.path.exists(os.path.join(file_path, file_name))
+ for file_name in file_list]
+
+ missing_files = [file_name for (file_name, ok) in zip(file_list, file_exists) if not ok]
+ if missing_files:
+ print "Missing files in path : %s\n" % file_path
+ print '\n'.join(missing_files)
+ else:
+ print "No missing MP3 Mix files"
+ return missing_files
+
+
+check_mp3(mp3_mix_list, MIX_PATH)
+
+check_mp3(mp3_shop_list, RECORDS_PATH)
+
+# NEWS
+news_list = [news for news in rec_models.News.objects.all()]
+
+
+# SHOPS TO RECORDS
+import HTMLParser
+parser = HTMLParser.HTMLParser()
+shop_list = rec_models.Shop.objects.all()
+for shop in shop_list:
+ print "-----------"
+ print shop.titre
+ s_titre = shop.titre
+ if not (shop.titre == parser.unescape(shop.titre)):
+ s_titre = parser.unescape(shop.titre)
+ print "\t-->\t%s" % s_titre
+
+ s_theme = rec_models.Theme.objects.filter(id=shop.theme)[0]
+ print "\tTheme : %s" % s_theme.nom
+
+ s_artist = rec_models.Artist.objects.filter(name=shop.artiste)[0]
+ print "\tArtist : %s" % s_artist.name
+
+ s_label = rec_models.Label.objects.filter(name=shop.label)[0]
+ print "\tLabel : %s" % s_label.name
+ s_country = rec_models.Country.objects.filter(name=shop.pays)[0]
+ print "\tCountry : %s" % s_country.name
+
+ record_from_shop = rec_models.Record(title=s_titre,
+ artist=s_artist,
+ label=s_label,
+ country=s_country)
+ print record_from_shop.__dict__
+
+## class Shop(models.Model):
+## theme = models.IntegerField()
+## artiste = models.CharField(max_length=128)
+## new = models.IntegerField()
+## titre = models.CharField(max_length=128)
+## label = models.CharField(max_length=128)
+## date = models.CharField(max_length=8)
+## pays = models.CharField(max_length=128)
+## desc = models.TextField()
+## cover = models.IntegerField()
+## vinyl = models.IntegerField()
+## prix = models.IntegerField()
+## devise = models.IntegerField()
+## mp3 = models.CharField(max_length=128)
+## visu1 = models.IntegerField()
+## ordre = models.IntegerField()
+## published = models.IntegerField()
+
+## class Record(Product):
+## """
+## Model for Record
+## """
+## # herited fields (from Product):
+## # title --> shop.titre
+## # categories --> shop.theme
+## # price --> shop.prix
+## # status --> shop.published
+
+## artiste = models.CharField(max_length=128)
+## new = models.IntegerField()
+## label = models.CharField(max_length=128)
+## date = models.CharField(max_length=8)
+## pays = models.CharField(max_length=128)
+## desc = models.TextField()
+## cover = models.IntegerField() # TODO : choices=GRADINGS)
+## vinyl = models.IntegerField() # TODO : choices=GRADING)
+## audio = FileField(_("Audio File"), max_length=200, format="media",
+## upload_to=upload_to("records.Record.audio", "audio/records"))