]> git.parisson.com Git - diggersdigest.git/commitdiff
Update records models
authorThomas Fillon <thomas@parisson.com>
Fri, 28 Aug 2015 15:46:39 +0000 (17:46 +0200)
committerThomas Fillon <thomas@parisson.com>
Fri, 28 Aug 2015 15:46:39 +0000 (17:46 +0200)
diggersdigest/diggersdigest/local_settings.py
diggersdigest/diggersdigest/settings.py
diggersdigest/records/migrations/0004_auto_20150828_1342.py [new file with mode: 0644]
diggersdigest/records/migrations/0005_auto_20150828_1545.py [new file with mode: 0644]
diggersdigest/records/models.py
diggersdigest/records/script_data_recover.py

index 0f2eb26816c56dd471bfd1a518c135b577b32755..56482b6be1ae9127693b71371175bd2ef4587b9d 100644 (file)
@@ -42,13 +42,17 @@ FILEBROWSER_EXTENSIONS = {
 # This has to be a subset of EXTENSIONS.
 # e.g., add ?type=image to the browse-URL ...
 FILEBROWSER_SELECT_FORMATS = {
-    'file': ['Folder', 'Image', 'Document', 'Video', 'Audio'],
+    'File': ['Folder', 'Document'],
+    'Image': ['Image'],
+    'Media': ['Video', 'Audio'],
+    'Audio': ['Audio'],
+    'Document': ['Document'],
+    # for TinyMCE we can also define lower-case items
     'image': ['Image'],
-    'document': ['Document'],
+    'file': ['Folder', 'Image', 'Document'],
     'media': ['Video', 'Audio'],
     'audio': ['Audio'],
-    }
-
+}
 
 ###################
 # DEPLOY SETTINGS #
index 8d379b7476e735501a5393b75e03de622fd1c9ba..26fddcf257beaeda904368585013d2aafbd3c64a 100644 (file)
@@ -63,15 +63,14 @@ from django.utils.translation import ugettext_lazy as _
 # Sequence of value/name pairs for types of product options,
 # eg Size, Colour. NOTE: Increasing the number of these will
 # require database migrations!
-SHOP_OPTION_TYPE_CHOICES = (
-#     (1, "Size"),
-#     (2, "Colour"),
-# )
+SHOP_OPTION_TYPE_CHOICES = (
+     (1, "Cover condition"),
+     (2, "Vinyl condition"),
+ )
 
 # Sequence of indexes from the SHOP_OPTION_TYPE_CHOICES setting that
 # control how the options should be ordered in the admin,
-# eg for "Colour" then "Size" given the above:
-# SHOP_OPTION_ADMIN_ORDER = (2, 1)
+# SHOP_OPTION_ADMIN_ORDER = (1, 2)
 
 
 ######################
diff --git a/diggersdigest/records/migrations/0004_auto_20150828_1342.py b/diggersdigest/records/migrations/0004_auto_20150828_1342.py
new file mode 100644 (file)
index 0000000..7c7f3f4
--- /dev/null
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('records', '0003_auto_20150827_1634'),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name='gallery',
+            options={'managed': False, 'verbose_name': 'OLD_Gallery'},
+        ),
+        migrations.AlterModelOptions(
+            name='grading',
+            options={'managed': False, 'verbose_name': 'OLD_Grading'},
+        ),
+        migrations.AlterModelOptions(
+            name='link',
+            options={'managed': False, 'verbose_name': 'OLD_Link'},
+        ),
+        migrations.AlterModelOptions(
+            name='mix',
+            options={'managed': False, 'verbose_name': 'OLD_Mix', 'verbose_name_plural': 'OLD_Mixes'},
+        ),
+        migrations.AlterModelOptions(
+            name='news',
+            options={'managed': False, 'verbose_name': 'OLD_News', 'verbose_name_plural': 'OLD_News'},
+        ),
+        migrations.AlterModelOptions(
+            name='shop',
+            options={'managed': False, 'verbose_name': 'OLD_Shop'},
+        ),
+        migrations.AlterModelOptions(
+            name='theme',
+            options={'managed': False, 'verbose_name': 'OLD_Theme'},
+        ),
+        migrations.AlterModelOptions(
+            name='user',
+            options={'managed': False, 'verbose_name_plural': 'OLD_User'},
+        ),
+        migrations.AddField(
+            model_name='podcast',
+            name='genre',
+            field=models.CharField(max_length=128, null=True),
+        ),
+        migrations.AddField(
+            model_name='podcast',
+            name='mix_cloud_url',
+            field=models.URLField(null=True),
+        ),
+        migrations.AddField(
+            model_name='podcast',
+            name='old_date',
+            field=models.CharField(max_length=64, null=True),
+        ),
+    ]
diff --git a/diggersdigest/records/migrations/0005_auto_20150828_1545.py b/diggersdigest/records/migrations/0005_auto_20150828_1545.py
new file mode 100644 (file)
index 0000000..bd33487
--- /dev/null
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('records', '0004_auto_20150828_1342'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='record',
+            name='cover_state',
+        ),
+        migrations.RemoveField(
+            model_name='record',
+            name='vinyl_state',
+        ),
+    ]
index 875abb8ebb531d8d2c5d46d163698886e72151fe..f12d2f51f2ce715590b0fd1384ddd32aa43f9d2b 100644 (file)
@@ -1,10 +1,11 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
 from __future__ import unicode_literals
 
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
-from cartridge.shop.models import Product
-
 from mezzanine.core.fields import FileField
 from mezzanine.core.models import CONTENT_STATUS_DRAFT, CONTENT_STATUS_PUBLISHED
 from mezzanine.blog.models import BlogPost
@@ -62,7 +63,7 @@ class Link(models.Model):
     published = models.IntegerField()
 
     class Meta:
-        verbose_name = 'OLD_Links'
+        verbose_name = 'OLD_Link'
         managed = False
         db_table = 'links'
 
@@ -218,8 +219,8 @@ class Record(models.Model):
     label = models.ForeignKey(Label, verbose_name=_('label'), related_name='records', null=True, on_delete=models.SET_NULL)
     release_date = models.DateField(_('release date'), null=True)
     country = models.ForeignKey(Country, verbose_name=_('country'), related_name='records', null=True, on_delete=models.SET_NULL)
-    cover_state = models.ForeignKey(ConditionGrading, verbose_name=_('cover condition'), related_name='records_cover_condition', null=True, on_delete=models.SET_NULL)
-    vinyl_state = models.ForeignKey(ConditionGrading, verbose_name=_('vinyl condition'), related_name='records_vinyl_condition', null=True, on_delete=models.SET_NULL)
+    #cover_state = models.ForeignKey(ConditionGrading, verbose_name=_('cover condition'), related_name='records_cover_condition', null=True, on_delete=models.SET_NULL)
+    #vinyl_state = models.ForeignKey(ConditionGrading, verbose_name=_('vinyl condition'), related_name='records_vinyl_condition', null=True, on_delete=models.SET_NULL)
     audio_file =  FileField(_("audio file"), max_length=1024, format="audio",
                         upload_to=upload_to("records.Record.audio", "audio/records"), null=True)
 
@@ -227,5 +228,14 @@ class Record(models.Model):
         return " - ".join([self.artist, self.title])
 
 class Podcast(BlogPost):
-    audio =  FileField(verbose_name=_("Audio File"), max_length=200, format="audio",
+    audio =  FileField(verbose_name=_("Audio File"), max_length=200, format="Audio",
                        upload_to=upload_to("records.Podcast.audio", "audio/mixes"))
+    genre = models.CharField(max_length=128, null=True)
+    # titre --> title
+    old_date = models.CharField(max_length=64, null=True)
+    mix_cloud_url = models.URLField(null=True)
+    # desc --> description
+    # mp3 --> audio
+    #visu1 = models.IntegerField()
+    # ordre : on laisse tombé ?
+    # published --> status / 0 --> CONTENT_STATUS_DRAFT = 1 / 1 CONTENT_STATUS_PUBLISHED = 2
index 1badee222912df5c60613d9c2244c7ba7d6fd1dd..a391e0a830e57fbd12af121cd8db495317d621b8 100644 (file)
@@ -8,6 +8,8 @@ from records import models as rec_models
 
 from diggersdigest import settings
 
+import HTMLParser
+parser = HTMLParser.HTMLParser()
 
 
 # Label
@@ -18,7 +20,12 @@ for lab in label_set:
     if created:
         print "Create new Label : %s" % obj.name
         count += 1
-print "%d fiches label créées" % count
+
+print '--------------------------------------'        
+print "%d created label objects" % count
+print "%d label in new db / %d in old db" % (len(rec_models.Label.objects.all()), len(label_set))
+print '--------------------------------------'        
+
 
 # Artist
 artist_set = set([shop.artiste for shop in rec_models.Shop.objects.all()])
@@ -29,7 +36,11 @@ for artist in artist_set:
         print "Create new Artist : %s" % obj.name
         count += 1
 
-print "%d fiches artiste créées" % count
+print '--------------------------------------'
+print "%d created artist object" % count
+print "%d artist in new db / %d in old db" % (len(rec_models.Artist.objects.all()), len(artist_set))
+print '--------------------------------------'        
+
 
 # Pays
 country_set = set([shop.pays for shop in rec_models.Shop.objects.all()])
@@ -40,7 +51,11 @@ for country in country_set:
         print "Create new Country : %s" % obj.name
         count += 1
 
-print "%d fiches pays créées" % count
+print '--------------------------------------'
+print "%d created country object" % count
+print "%d country in new db / %d in old db" % (len(rec_models.Country.objects.all()), len(country_set))
+print '--------------------------------------'        
+
 
 # Theme
 [theme for theme in rec_models.Theme.objects.all()]
@@ -56,6 +71,7 @@ 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))
@@ -70,7 +86,57 @@ def check_mp3(file_list, file_path):
     return missing_files
 
 
-check_mp3(mp3_mix_list, MIX_PATH)    
+check_mp3(mp3_mix_list, MIX_PATH)
+
+
+# PODCAST FROM MIX
+PODCAST_IMG_PATH = os.path.join('uploads/blog/mixes')
+PODCAST_AUDIO_PATH = os.path.join('uploads/audio/mixes')
+from django.contrib.auth import models as auth_models
+digger = auth_models.User.objects.get(username='digger')
+
+
+
+for mix in rec_models.Mix.objects.all():
+    if mix.visu1:
+        img_file = str(mix.id) + '.jpg' 
+        img_path = os.path.join(PODCAST_IMG_PATH, img_file)
+    else:
+        img_path = ''
+    
+    print '---------------------------'
+    print 'pk :\t %d' % mix.pk
+    print 'audio :\t %s' % os.path.join(PODCAST_AUDIO_PATH, mix.mp3)
+    print 'genre :\t %s' % mix.genre
+    print "old_date :\t %s" % mix.date
+    print  "title :\t %s" % parser.unescape(mix.titre)
+    #status=mix.published+1,
+    #featured_image=img_path,
+    #user=digger)
+    obj, created = rec_models.Podcast.objects.get_or_create(
+        pk=mix.pk,
+        audio=os.path.join(PODCAST_AUDIO_PATH, mix.mp3),
+        genre=mix.genre,
+        old_date=mix.date,
+        title=parser.unescape(mix.titre),
+        description=parser.unescape(mix.desc),
+        status=mix.published+1,
+        featured_image=img_path,
+        user=digger)
+    
+    ## audio =  FileField(verbose_name=_("Audio File"), max_length=200, format="audio",
+    ##                    upload_to=upload_to("records.Podcast.audio", "audio/mixes"))
+    ## genre = models.CharField(max_length=128)
+    ## # titre --> title
+    ## date = models.CharField(max_length=64)
+    ## # desc --> description
+    ## # mp3 --> audio
+    ## #visu1 = models.IntegerField() si 1 --> featured_image
+    ## # ordre : on laisse tombé ?
+    ## # published --> status / 0 --> CONTENT_STATUS_DRAFT = 1 / 1 CONTENT_STATUS_PUBLISHED = 2
+
+
 
 check_mp3(mp3_shop_list, RECORDS_PATH)
 
@@ -123,8 +189,6 @@ print "%d fiches GradingCondition crées" % count
 
 
 # SHOPS TO RECORDS
-import HTMLParser
-parser = HTMLParser.HTMLParser()
 shop_list = rec_models.Shop.objects.all()
 for shop in shop_list:
     print "-----------"