From 6790af68bf6af99db9a0929f0515b6dae6e7b241 Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Thu, 27 Aug 2015 19:19:25 +0200 Subject: [PATCH] Improve ConditionGrading and specify old models through verbose name --- diggersdigest/records/admin.py | 3 +- diggersdigest/records/models.py | 17 +++++- diggersdigest/records/script_data_recover.py | 60 ++++++++++++++------ 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/diggersdigest/records/admin.py b/diggersdigest/records/admin.py index f476c37..acf7368 100644 --- a/diggersdigest/records/admin.py +++ b/diggersdigest/records/admin.py @@ -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) diff --git a/diggersdigest/records/models.py b/diggersdigest/records/models.py index f251cc3..875abb8 100644 --- a/diggersdigest/records/models.py +++ b/diggersdigest/records/models.py @@ -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 diff --git a/diggersdigest/records/script_data_recover.py b/diggersdigest/records/script_data_recover.py index 6f0d9e5..1badee2 100644 --- a/diggersdigest/records/script_data_recover.py +++ b/diggersdigest/records/script_data_recover.py @@ -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")) -- 2.39.5