From: Guillaume Pellerin Date: Tue, 14 Mar 2017 17:29:06 +0000 (+0100) Subject: Add LiveStreaming MVC X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=00c77bd271740643d273e4759c78d99c07c50b13;p=mezzo.git Add LiveStreaming MVC --- diff --git a/app/organization/media/admin.py b/app/organization/media/admin.py index 7eb1695a..759cbe6a 100644 --- a/app/organization/media/admin.py +++ b/app/organization/media/admin.py @@ -35,7 +35,7 @@ class MediaImageInline(TabularDynamicInlineAdmin): model = MediaImage - + class MediaAdmin(BaseTranslationModelAdmin): model = Media @@ -60,10 +60,13 @@ class MediaCategoryAdmin(BaseTranslationModelAdmin): model = MediaCategory +class LiveStreamingAdmin(BaseTranslationModelAdmin): - + model = LiveStreaming + list_display = ['title',] admin.site.register(Media, MediaAdmin) admin.site.register(Playlist, PlaylistAdmin) admin.site.register(MediaCategory, MediaCategoryAdmin) +admin.site.register(LiveStreaming, LiveStreamingAdmin) diff --git a/app/organization/media/migrations/0014_livestreaming.py b/app/organization/media/migrations/0014_livestreaming.py new file mode 100644 index 00000000..238adc4c --- /dev/null +++ b/app/organization/media/migrations/0014_livestreaming.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.11 on 2017-03-14 17:28 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('sites', '0002_alter_domain_unique'), + ('organization-media', '0013_mediaimage'), + ] + + operations = [ + migrations.CreateModel( + name='LiveStreaming', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('keywords_string', models.CharField(blank=True, editable=False, max_length=500)), + ('title', models.CharField(max_length=500, verbose_name='Title')), + ('title_en', models.CharField(max_length=500, null=True, verbose_name='Title')), + ('title_fr', models.CharField(max_length=500, null=True, verbose_name='Title')), + ('slug', models.CharField(blank=True, help_text='Leave blank to have the URL auto-generated from the title.', max_length=2000, null=True, verbose_name='URL')), + ('_meta_title', models.CharField(blank=True, help_text='Optional title to be used in the HTML title tag. If left blank, the main title field will be used.', max_length=500, null=True, verbose_name='Title')), + ('description', models.TextField(blank=True, verbose_name='Description')), + ('description_en', models.TextField(blank=True, null=True, verbose_name='Description')), + ('description_fr', models.TextField(blank=True, null=True, verbose_name='Description')), + ('gen_description', models.BooleanField(default=True, help_text='If checked, the description will be automatically generated from content. Uncheck if you want to manually set a custom description.', verbose_name='Generate description')), + ('created', models.DateTimeField(editable=False, null=True)), + ('updated', models.DateTimeField(editable=False, null=True)), + ('status', models.IntegerField(choices=[(1, 'Draft'), (2, 'Published')], default=2, help_text='With Draft chosen, will only be shown for admin users on the site.', verbose_name='Status')), + ('publish_date', models.DateTimeField(blank=True, db_index=True, help_text="With Published chosen, won't be shown until this time", null=True, verbose_name='Published from')), + ('expiry_date', models.DateTimeField(blank=True, help_text="With Published chosen, won't be shown after this time", null=True, verbose_name='Expires on')), + ('short_url', models.URLField(blank=True, null=True)), + ('in_sitemap', models.BooleanField(default=True, verbose_name='Show in sitemap')), + ('html5_url', models.URLField(blank=True, max_length=1024, verbose_name='html5 url')), + ('html5_url_en', models.URLField(blank=True, max_length=1024, null=True, verbose_name='html5 url')), + ('html5_url_fr', models.URLField(blank=True, max_length=1024, null=True, verbose_name='html5 url')), + ('youtube_id', models.CharField(blank=True, max_length=64, null=True, verbose_name='youtube id')), + ('type', models.CharField(choices=[('html5', 'html5'), ('youtube', 'youtube')], default='html5', max_length=32, verbose_name='type')), + ('site', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site')), + ], + options={ + 'verbose_name': 'live streaming', + 'verbose_name_plural': 'live streamings', + }, + ), + ] diff --git a/app/organization/media/models.py b/app/organization/media/models.py index 640d3796..ffe49571 100644 --- a/app/organization/media/models.py +++ b/app/organization/media/models.py @@ -42,6 +42,12 @@ PLAYLIST_TYPE_CHOICES = [ ('video', _('video')), ] +LIVE_STREAMING_TYPE_CHOICES = [ + ('html5', _('html5')), + ('youtube', _('youtube')), +] + + class Media(Displayable): """Media""" @@ -169,3 +175,21 @@ class PlaylistRelated(models.Model): class Meta: verbose_name = _('playlist') verbose_name_plural = _('playlists') + + +class LiveStreaming(Displayable): + """Live streaming""" + + html5_url = models.URLField(_('html5 url'), max_length=1024, blank=True) + youtube_id = models.CharField(_('youtube id'), max_length=64, blank=True, null=True) + type = models.CharField(_('type'), max_length=32, choices=LIVE_STREAMING_TYPE_CHOICES, default='html5') + + class Meta: + verbose_name = "live streaming" + verbose_name_plural = "live streamings" + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse("organization-streaming-detail", kwargs={"slug": self.slug}) diff --git a/app/organization/media/translation.py b/app/organization/media/translation.py index 3dc1ed9b..55f0bff2 100644 --- a/app/organization/media/translation.py +++ b/app/organization/media/translation.py @@ -58,3 +58,9 @@ class MediaCategoryTranslationOptions(TranslationOptions): class MediaImageTranslationOptions(TranslationOptions): fields = () + + +@register(LiveStreaming) +class LiveStreamingTranslationOptions(TranslationOptions): + + fields = ('title', 'description', 'html5_url') diff --git a/app/organization/media/urls.py b/app/organization/media/urls.py index 0cc5df19..abdd7787 100644 --- a/app/organization/media/urls.py +++ b/app/organization/media/urls.py @@ -40,4 +40,5 @@ urlpatterns = [ url("^playlists/list/(?P.*)$", PlaylistListView.as_view(), name="organization-playlist-list"), url("^playlists/overlay/(?P.*)/$", PlaylistOverlayView.as_view(), name="organization-playlist-overlay"), url("^playlist-media-autocomplete/$", permission_required('playlist.can_edit')(PlayListMediaView.as_view()), name='media-autocomplete'), + url("^streamings/(?P.*)/detail/$", LiveStreamingDetailView.as_view(), name="organization-streaming-detail"), ] diff --git a/app/organization/media/views.py b/app/organization/media/views.py index f24ae5a4..8f89245c 100644 --- a/app/organization/media/views.py +++ b/app/organization/media/views.py @@ -111,6 +111,7 @@ class PlayListMediaView(autocomplete.Select2QuerySetView): class MediaOverlayView(SlugMixin, DetailView): + model = Media template_name='media/media/media_overlay.html' context_object_name = 'media' @@ -122,6 +123,13 @@ class MediaOverlayView(SlugMixin, DetailView): class PlaylistOverlayView(SlugMixin, DetailView): + model = Playlist template_name='media/playlist_overlay.html' context_object_name = 'playlist' + + +class LiveStreamingDetailView(SlugMixin, DetailView): + + model = LiveStreaming + template_name='media/live_streaming_detail.html' diff --git a/app/organization/projects/migrations/0052_auto_20170314_1828.py b/app/organization/projects/migrations/0052_auto_20170314_1828.py new file mode 100644 index 00000000..9dcedf8f --- /dev/null +++ b/app/organization/projects/migrations/0052_auto_20170314_1828.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.11 on 2017-03-14 17:28 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-projects', '0051_auto_20170314_0937'), + ] + + operations = [ + migrations.AlterField( + model_name='projectpublicdata', + name='challenges_description', + field=models.TextField(help_text='Full description of the challenges faced by the project (100-150 words).', verbose_name='challenges description'), + ), + migrations.AlterField( + model_name='projectpublicdata', + name='objectives_description', + field=models.TextField(help_text='What the project is looking to gain from the collaboration and what kind of artist would be suitable (100 – 150 words).', verbose_name='objectives description'), + ), + ]