]> git.parisson.com Git - diggersdigest.git/commitdiff
Improve ConditionGrading and specify old models through verbose name
authorThomas Fillon <thomas@parisson.com>
Thu, 27 Aug 2015 17:19:25 +0000 (19:19 +0200)
committerThomas Fillon <thomas@parisson.com>
Thu, 27 Aug 2015 17:19:25 +0000 (19:19 +0200)
diggersdigest/records/admin.py
diggersdigest/records/models.py
diggersdigest/records/script_data_recover.py

index f476c371ec93de4f86424e553834236c860e8fe3..acf7368d6c92182eb60a33049d210d397b9778a8 100644 (file)
@@ -14,7 +14,7 @@ from .models import Label
 from .models import Country
 from .models import Record
 from .models import Podcast
-
+from .models import ConditionGrading
     
 admin.site.register(Gallery)
 admin.site.register(Grading)
@@ -29,3 +29,4 @@ admin.site.register(Label)
 admin.site.register(Country)
 admin.site.register(Record)
 admin.site.register(Podcast)
+admin.site.register(ConditionGrading)
index f251cc3f03b0b9fe973bc87dcff3be039b945146..875abb8ebb531d8d2c5d46d163698886e72151fe 100644 (file)
@@ -32,6 +32,7 @@ class Gallery(models.Model):
     published = models.IntegerField()
 
     class Meta:
+        verbose_name = 'OLD_Gallery'
         managed = False
         db_table = 'gallery'
 
@@ -44,6 +45,7 @@ class Grading(models.Model):
     nom = models.CharField(max_length=5)
 
     class Meta:
+        verbose_name = 'OLD_Grading'
         managed = False
         db_table = 'grading'
 
@@ -60,6 +62,7 @@ class Link(models.Model):
     published = models.IntegerField()
 
     class Meta:
+        verbose_name = 'OLD_Links'
         managed = False
         db_table = 'links'
 
@@ -78,6 +81,8 @@ class Mix(models.Model):
     published = models.IntegerField()
 
     class Meta:
+        verbose_name = 'OLD_Mix'
+        verbose_name_plural = 'OLD_Mixes'
         managed = False
         db_table = 'mix'
 
@@ -97,6 +102,8 @@ class News(models.Model):
     published = models.IntegerField()
 
     class Meta:
+        verbose_name = 'OLD_News'
+        verbose_name_plural = 'OLD_News'
         managed = False
         db_table = 'news'
 
@@ -123,6 +130,7 @@ class Shop(models.Model):
     published = models.IntegerField()
 
     class Meta:
+        verbose_name = 'OLD_Shop'
         managed = False
         db_table = 'shop'
 
@@ -136,6 +144,7 @@ class Theme(models.Model):
     published = models.IntegerField()
 
     class Meta:
+        verbose_name = 'OLD_Theme'
         managed = False
         db_table = 'theme'
 
@@ -149,6 +158,7 @@ class User(models.Model):
     type = models.IntegerField()
 
     class Meta:
+        verbose_name_plural = 'OLD_User'
         managed = False
         db_table = 'user'
 
@@ -175,11 +185,14 @@ class Country(models.Model):
 
 
 class ConditionGrading(models.Model):
-    name = models.CharField(_('name'), max_length=128)
+
     abbr = models.CharField(_('abbreviation'), max_length=5, unique=True)
+    name = models.CharField(_('name'), max_length=128)
     description = models.TextField(_('description'))
 
-    
+    def __unicode__(self):
+        return " = ".join([self.abbr, self.name])
+   
 class Record(models.Model):
     """
     Model for Record
index 6f0d9e50798b16abcf466d751b878e294085ad9a..1badee222912df5c60613d9c2244c7ba7d6fd1dd 100644 (file)
@@ -77,6 +77,50 @@ check_mp3(mp3_shop_list, RECORDS_PATH)
 # NEWS
 news_list = [news for news in rec_models.News.objects.all()]
 
+# GRADING
+
+Grading_Dict = {
+    'SS': {
+        'name': "Still Sealed",
+        'description': "in perfect condition, no wear"},
+    'M' : {
+        'name': "Mint" ,
+        'description': "Still in new condition, no imperfections, a Perfect Copy !"},
+    'NM' : {
+        'name': "Near mint" ,
+        'description': "Imperceptible wear, full vinyl gloss"},
+    'EX' : {
+        'name': "Excellent",
+        'description': "Only very slight wear and paper scuffs, vinyl still glossy with very rare noise"},
+    'VG++' : {
+        'name': "Near Excellent",
+        'description': "Light surface noise and wear but fairly minor, vinyl still plays nicely"},
+    'VG+' : {
+        'name': "Very Very Good",
+        'description': "Evident groove wear or minor scuff marks, surface noise noticeable but does not really affect the playing"},
+    'VG' : {
+        'name': "Very Good",
+        'description': "Wear and scuffs are more evident and many surface noises are noticeable"},
+    'VG-' : {
+        'name': "Good to Very Good",
+        'description': "Heavy groove wear or scuffing, plays noisily"}
+    }
+
+
+count = 0
+for grade in rec_models.Grading.objects.all():
+    name = Grading_Dict[grade.nom]['name']
+    desc = Grading_Dict[grade.nom]['description']
+    obj, created = rec_models.ConditionGrading.objects.get_or_create(id=grade.id,
+                                                                     abbr=grade.nom,
+                                                                     name=name,
+                                                                     description=desc)
+    if created:
+        print "Create new GradingCondition : %s" % obj.name
+        count += 1
+
+print "%d fiches GradingCondition crées" % count
+
 
 # SHOPS TO RECORDS
 import HTMLParser
@@ -129,19 +173,3 @@ for shop in shop_list:
 ##     """
 ##     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"))