Repository: kartoza/prj.app

Issue:
We need to support youtube embeds in entries
# Problem

Sometimes a video expresses a new feature better than words. We should be able to embed a video link to youtube, vimeo etc. and have it display nicely in the changelog. I do not envision providing video upload support at this point, though it is certainly something we could add later.
# Proposed solution
- Add a new field to the entry model for a user video.
- Make a pleasing layout so that the changelog looks good with all combinations of video, picture, neither being attached to an entry.
- MAke sure that non printable outputs (e.g. rst download) still work nicely.
# Expected outcome
- Writers should be able to insert videos to an entry
- Viewers should be able to see videos on a version's changelog



Discussion:

Resolving patch:
diff --git a/django_project/changes/forms.py b/django_project/changes/forms.py
--- a/django_project/changes/forms.py
+++ b/django_project/changes/forms.py
@@ -84,7 +84,9 @@ class Meta:
         model = Entry
         fields = (
             'category', 'title', 'description',
-            'image_file', 'image_credits'
+            'image_file', 'image_credits', 'video',
+            'funded_by', 'funder_url', 'developed_by',
+            'developer_url'
         )
 
     def __init__(self, *args, **kwargs):
@@ -104,6 +106,11 @@ def __init__(self, *args, **kwargs):
                 Field('description', css_class="form-control"),
                 Field('image_file', css_class="form-control"),
                 Field('image_credits', css_class="form-control"),
+                Field('video', css_class="form-control"),
+                Field('funded_by', css_class="form-control"),
+                Field('funder_url', css_class="form-control"),
+                Field('developed_by', css_class="form-control"),
+                Field('developer_url', css_class="form-control"),
                 css_id='entry-form')
         )
         self.helper.layout = layout
diff --git a/django_project/changes/models/entry.py b/django_project/changes/models/entry.py
--- a/django_project/changes/models/entry.py
+++ b/django_project/changes/models/entry.py
@@ -8,6 +8,7 @@
 from django.conf.global_settings import MEDIA_ROOT
 from django.db import models
 from audited_models.models import AuditedModel
+from embed_video.fields import EmbedVideoField
 from django.contrib.auth.models import User
 
 logger = logging.getLogger(__name__)
@@ -61,6 +62,36 @@ class Entry(AuditedModel):
         null=True,
         blank=True)
 
+    video = EmbedVideoField(
+        verbose_name='Youtube video',
+        help_text='Paste your youtube video link',
+        null=True,
+        blank=True)
+
+    funded_by = models.CharField(
+        help_text='Input the funder name.',
+        max_length=255,
+        null=True,
+        blank=True)
+
+    funder_url = models.CharField(
+        help_text='Input the funder URL.',
+        max_length=255,
+        null=True,
+        blank=True)
+
+    developed_by = models.CharField(
+        help_text='Input the developer name.',
+        max_length=255,
+        null=True,
+        blank=True)
+
+    developer_url = models.CharField(
+        help_text='Input the developer URL.',
+        max_length=255,
+        null=True,
+        blank=True)
+
     approved = models.BooleanField(
         help_text=(
             'Whether this entry has been approved for use by the '
@@ -103,3 +134,41 @@ def get_absolute_url(self):
             'version_slug': self.version.slug,
             'project_slug': self.version.project.slug
         })
+
+    def funder_info_html(self):
+        string = ""
+        if self.funded_by and self.funder_url is None:
+            string = ""
+            return string
+        elif self.funded_by and not self.funder_url:
+            string = "This feature was funded by %s " % (self.funded_by)
+            return string
+        elif self.funder_url and not self.funded_by:
+            string = "This feature was funded by [%s](%s)" % (
+                self.funder_url, self.funder_url)
+            return string
+        elif self.funded_by and self.funder_url:
+            string = "This feature was funded by [%s](%s)" % (
+                self.funded_by, self.funder_url)
+            return string
+        else:
+            return string
+
+    def developer_info_html(self):
+        string = ""
+        if self.developed_by and self.developer_url is None:
+            string = ""
+            return string
+        elif self.developed_by and not self.developer_url:
+            string = "This feature was developed by %s " % (self.developed_by)
+            return string
+        elif self.developer_url and not self.developed_by:
+            string = "This feature was developed by [%s](%s)" % (
+                self.developer_url, self.developer_url)
+            return string
+        elif self.developed_by and self.developer_url:
+            string = "This feature was developed by [%s](%s)" % (
+                self.developed_by, self.developer_url)
+            return string
+        else:
+            return string
diff --git a/django_project/core/settings/contrib.py b/django_project/core/settings/contrib.py
--- a/django_project/core/settings/contrib.py
+++ b/django_project/core/settings/contrib.py
@@ -16,6 +16,7 @@
     'raven.contrib.django',
     'reversion',
     'rosetta',
+    'embed_video',
     # 'user_map',
 )
 


Test patch: