]> git.0d.be Git - django-panik-emissions.git/commitdiff
add possibility to attach a license to soundfiles
authorFrédéric Péters <fpeters@0d.be>
Sun, 23 Apr 2017 12:44:46 +0000 (14:44 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sun, 23 Apr 2017 12:44:46 +0000 (14:44 +0200)
emissions/forms.py
emissions/migrations/0010_auto_20170423_1441.py [new file with mode: 0644]
emissions/models.py
emissions/views.py

index fa5e081523387cc81ce16d15adeaa607b2b12d69..aa916a7d4f24b0f4409b834702c648c7f63b2410 100644 (file)
@@ -273,7 +273,7 @@ class SoundFileEditForm(forms.ModelForm):
 
     def __init__(self, *args, **kwargs):
         super(SoundFileEditForm, self).__init__(*args, **kwargs)
-        self.fields.keyOrder = ['title', 'format', 'podcastable', 'fragment']
+        self.fields.keyOrder = ['title', 'format', 'podcastable', 'fragment', 'license']
 
 
 class DiffusionForm(forms.ModelForm):
diff --git a/emissions/migrations/0010_auto_20170423_1441.py b/emissions/migrations/0010_auto_20170423_1441.py
new file mode 100644 (file)
index 0000000..e5093ce
--- /dev/null
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('emissions', '0009_auto_20170418_1525'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='emission',
+            name='default_license',
+            field=models.CharField(default=b'', max_length=20, verbose_name='Default license for podcasts', blank=True, choices=[(b'', 'Unspecified'), (b'cc by', 'Creative Commons Attribution'), (b'cc by-sa', 'Creative Commons Attribution ShareAlike'), (b'cc by-nc', 'Creative Commons Attribution NonCommercial'), (b'cc by-nd', 'Creative Commons Attribution NoDerivs'), (b'cc by-nc-sa', 'Creative Commons Attribution NonCommercial ShareAlike'), (b'cc by-nc-nd', 'Creative Commons Attribution NonCommercial NoDerivs'), (b'cc0 / pd', 'Creative Commons Zero / Public Domain'), (b'artlibre', 'Art Libre')]),
+        ),
+        migrations.AddField(
+            model_name='soundfile',
+            name='license',
+            field=models.CharField(default=b'', max_length=20, verbose_name='License', blank=True, choices=[(b'', 'Unspecified'), (b'cc by', 'Creative Commons Attribution'), (b'cc by-sa', 'Creative Commons Attribution ShareAlike'), (b'cc by-nc', 'Creative Commons Attribution NonCommercial'), (b'cc by-nd', 'Creative Commons Attribution NoDerivs'), (b'cc by-nc-sa', 'Creative Commons Attribution NonCommercial ShareAlike'), (b'cc by-nc-nd', 'Creative Commons Attribution NonCommercial NoDerivs'), (b'cc0 / pd', 'Creative Commons Zero / Public Domain'), (b'artlibre', 'Art Libre')]),
+        ),
+    ]
index 52c6dd90eaddd8b9712f93a5b1dfccca7bb9332c..5d0576a9b4bb37550584094e078b87848e038c07 100644 (file)
@@ -19,6 +19,19 @@ from taggit.managers import TaggableManager
 from utils import maybe_resize
 
 
+LICENSES = (
+    ('', _('Unspecified')),
+    ('cc by', _('Creative Commons Attribution')),
+    ('cc by-sa', _('Creative Commons Attribution ShareAlike')),
+    ('cc by-nc', _('Creative Commons Attribution NonCommercial')),
+    ('cc by-nd', _('Creative Commons Attribution NoDerivs')),
+    ('cc by-nc-sa', _('Creative Commons Attribution NonCommercial ShareAlike')),
+    ('cc by-nc-nd', _('Creative Commons Attribution NonCommercial NoDerivs')),
+    ('cc0 / pd', _('Creative Commons Zero / Public Domain')),
+    ('artlibre', _('Art Libre')),
+)
+
+
 class WeekdayMixin(object):
     DAY_HOUR_START = 6
 
@@ -110,6 +123,8 @@ class Emission(models.Model):
     duration = models.IntegerField(_('Duration'), default=60,
             help_text=_('In minutes'))
 
+    default_license = models.CharField(_('Default license for podcasts'),
+            max_length=20, blank=True, default='', choices=LICENSES)
     email = models.EmailField(_('Email'), max_length=254, null=True, blank=True)
     website = models.URLField(_('Website'), null=True, blank=True)
 
@@ -422,6 +437,7 @@ class SoundFile(models.Model):
     duration = models.IntegerField(_('Duration'), null=True, help_text=_('In seconds'))
 
     format = models.ForeignKey('Format', verbose_name=_('Format'), null=True, blank=True)
+    license = models.CharField(_('License'), max_length=20, blank=True, default='', choices=LICENSES)
 
     # denormalized from Focus
     got_focus = models.DateTimeField(default=None, null=True, blank=True)
index 19983af2088df39093b603cafaaaf18e70fbcfb3..f07e9a2d2c7709c0fc8ba0833d60c87075d37b5e 100644 (file)
@@ -207,7 +207,9 @@ class EpisodeDetailView(DetailView):
         context['diffusions'] = Diffusion.objects.filter(episode=self.object.id)
         context['soundfiles'] = SoundFile.objects.filter(episode=self.object.id)
         context['add_soundfile_form'] = SoundFileForm(initial={
-            'episode': self.object, 'title': _('Record')})
+            'episode': self.object,
+            'title': _('Record'),
+            'license': self.object.emission.default_license})
         context['add_diffusion_form'] = DiffusionForm(initial={'episode': self.object})
 
         try: