Added All medias view
authorveltr
Thu, 06 Dec 2012 14:30:23 +0100
changeset 129 ff6c954f3aaa
parent 124 41c09a24bc92
child 130 93d63d88f4f7
Added All medias view
src/hashcut/locale/en/LC_MESSAGES/django.mo
src/hashcut/locale/en/LC_MESSAGES/django.po
src/hashcut/locale/fr/LC_MESSAGES/django.mo
src/hashcut/locale/fr/LC_MESSAGES/django.po
src/hashcut/templates/mashup_all_contents.html
src/hashcut/templates/mashup_all_mashups.html
src/hashcut/templates/mashup_home.html
src/hashcut/urls.py
src/hashcut/views.py
Binary file src/hashcut/locale/en/LC_MESSAGES/django.mo has changed
--- a/src/hashcut/locale/en/LC_MESSAGES/django.po	Thu Dec 06 12:38:51 2012 +0100
+++ b/src/hashcut/locale/en/LC_MESSAGES/django.po	Thu Dec 06 14:30:23 2012 +0100
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-05 11:13+0100\n"
+"POT-Creation-Date: 2012-12-06 14:27+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,35 +18,45 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1)\n"
 
-#: templates/mashup_all_mashups.html:22 templates/mashup_content.html:54
-#: templates/mashup_edit.html:78 templates/mashup_home.html:15
-#: templates/mashup_profile.html:27
+#: templates/mashup_all_contents.html:7 templates/mashup_all_contents.html:18
+#: templates/mashup_home.html:119
+msgid "All source videos"
+msgstr "All source videos"
+
+#: templates/mashup_all_contents.html:22 templates/mashup_all_mashups.html:22
+#: templates/mashup_content.html:54 templates/mashup_edit.html:78
+#: templates/mashup_home.html:15 templates/mashup_profile.html:27
 msgid "Home"
 msgstr "Home"
 
-#: templates/mashup_all_mashups.html:23 templates/mashup_content.html:55
-#: templates/mashup_profile.html:28
+#: templates/mashup_all_contents.html:23 templates/mashup_all_mashups.html:23
+#: templates/mashup_content.html:55 templates/mashup_profile.html:28
 msgid "New hashcut"
 msgstr "New Hashcut"
 
-#: templates/mashup_all_mashups.html:24 templates/mashup_content.html:56
-#: templates/mashup_edit.html:79 templates/mashup_home.html:65
-#: templates/mashup_profile.html:29
+#: templates/mashup_all_contents.html:24 templates/mashup_all_mashups.html:24
+#: templates/mashup_content.html:56 templates/mashup_edit.html:79
+#: templates/mashup_home.html:65 templates/mashup_profile.html:29
 msgid "My profile"
 msgstr "My profile"
 
-#: templates/mashup_all_mashups.html:36
+#: templates/mashup_all_contents.html:36 templates/mashup_all_mashups.html:36
 msgid "Previous"
 msgstr "Previous"
 
-#: templates/mashup_all_mashups.html:44
+#: templates/mashup_all_contents.html:44 templates/mashup_all_mashups.html:44
 msgid "Next"
 msgstr "Next"
 
-#: templates/mashup_all_mashups.html:47
+#: templates/mashup_all_contents.html:47 templates/mashup_all_mashups.html:47
 msgid "All"
 msgstr "All"
 
+#: templates/mashup_all_mashups.html:7 templates/mashup_all_mashups.html:18
+#: templates/mashup_home.html:105
+msgid "All Hashcuts"
+msgstr "All Hashcuts"
+
 #: templates/mashup_content.html:6
 #, python-format
 msgid "Playing video %(title)s"
@@ -232,7 +242,7 @@
 msgstr "Featured Hashcuts"
 
 #: templates/mashup_home.html:83 templates/mashup_home.html.py:89
-#: templates/mashup_home.html:99
+#: templates/mashup_home.html:99 templates/mashup_home.html.py:113
 msgid "by"
 msgstr "by"
 
@@ -240,31 +250,31 @@
 msgid "Newest Hashcuts"
 msgstr "Newest Hashcuts"
 
-#: templates/mashup_home.html:105
-msgid "All Hashcuts"
-msgstr "All Hashcuts"
+#: templates/mashup_home.html:108
+msgid "Available videos"
+msgstr "Available source videos"
 
-#: templates/mashup_home.html:111
+#: templates/mashup_home.html:125
 msgid "What's a Hashcut?"
 msgstr "What's a Hashcut?"
 
-#: templates/mashup_home.html:116
+#: templates/mashup_home.html:130
 msgid "How to?"
 msgstr "How to?"
 
-#: templates/mashup_home.html:119
+#: templates/mashup_home.html:133
 msgid "Sign up"
 msgstr "Sign up"
 
-#: templates/mashup_home.html:120
+#: templates/mashup_home.html:134
 msgid "Start by creating your own profile on this platform."
 msgstr "Start by creating your own profile on this platform."
 
-#: templates/mashup_home.html:124
+#: templates/mashup_home.html:138
 msgid "Create a new hashcut"
 msgstr "Create a new Hashcut"
 
-#: templates/mashup_home.html:125
+#: templates/mashup_home.html:139
 msgid ""
 "Choose videos, define and organize segments and comment them to create your "
 "own hashcut."
@@ -272,11 +282,11 @@
 "Choose videos, define and organize segments and comment them to create your "
 "own hashcut."
 
-#: templates/mashup_home.html:129
+#: templates/mashup_home.html:143
 msgid "Publish and share"
 msgstr "Publish and share"
 
-#: templates/mashup_home.html:130
+#: templates/mashup_home.html:144
 msgid ""
 "Once your hashcut is done, publish it here and share your work on social "
 "networks."
Binary file src/hashcut/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/hashcut/locale/fr/LC_MESSAGES/django.po	Thu Dec 06 12:38:51 2012 +0100
+++ b/src/hashcut/locale/fr/LC_MESSAGES/django.po	Thu Dec 06 14:30:23 2012 +0100
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-05 11:13+0100\n"
+"POT-Creation-Date: 2012-12-06 14:27+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,35 +18,45 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1)\n"
 
-#: templates/mashup_all_mashups.html:22 templates/mashup_content.html:54
-#: templates/mashup_edit.html:78 templates/mashup_home.html:15
-#: templates/mashup_profile.html:27
+#: templates/mashup_all_contents.html:7 templates/mashup_all_contents.html:18
+#: templates/mashup_home.html:119
+msgid "All source videos"
+msgstr "Toutes les vidéos sources"
+
+#: templates/mashup_all_contents.html:22 templates/mashup_all_mashups.html:22
+#: templates/mashup_content.html:54 templates/mashup_edit.html:78
+#: templates/mashup_home.html:15 templates/mashup_profile.html:27
 msgid "Home"
 msgstr "Accueil"
 
-#: templates/mashup_all_mashups.html:23 templates/mashup_content.html:55
-#: templates/mashup_profile.html:28
+#: templates/mashup_all_contents.html:23 templates/mashup_all_mashups.html:23
+#: templates/mashup_content.html:55 templates/mashup_profile.html:28
 msgid "New hashcut"
 msgstr "Créer un Hashcut"
 
-#: templates/mashup_all_mashups.html:24 templates/mashup_content.html:56
-#: templates/mashup_edit.html:79 templates/mashup_home.html:65
-#: templates/mashup_profile.html:29
+#: templates/mashup_all_contents.html:24 templates/mashup_all_mashups.html:24
+#: templates/mashup_content.html:56 templates/mashup_edit.html:79
+#: templates/mashup_home.html:65 templates/mashup_profile.html:29
 msgid "My profile"
 msgstr "Mon profil"
 
-#: templates/mashup_all_mashups.html:36
+#: templates/mashup_all_contents.html:36 templates/mashup_all_mashups.html:36
 msgid "Previous"
 msgstr "Précédents"
 
-#: templates/mashup_all_mashups.html:44
+#: templates/mashup_all_contents.html:44 templates/mashup_all_mashups.html:44
 msgid "Next"
 msgstr "Suivants"
 
-#: templates/mashup_all_mashups.html:47
+#: templates/mashup_all_contents.html:47 templates/mashup_all_mashups.html:47
 msgid "All"
 msgstr "Tous"
 
+#: templates/mashup_all_mashups.html:7 templates/mashup_all_mashups.html:18
+#: templates/mashup_home.html:105
+msgid "All Hashcuts"
+msgstr "Tous les Hashcuts"
+
 #: templates/mashup_content.html:6
 #, python-format
 msgid "Playing video %(title)s"
@@ -234,7 +244,7 @@
 msgstr "Hashcuts à la Une"
 
 #: templates/mashup_home.html:83 templates/mashup_home.html.py:89
-#: templates/mashup_home.html:99
+#: templates/mashup_home.html:99 templates/mashup_home.html.py:113
 msgid "by"
 msgstr "par"
 
@@ -242,31 +252,31 @@
 msgid "Newest Hashcuts"
 msgstr "Derniers Hashcuts"
 
-#: templates/mashup_home.html:105
-msgid "All Hashcuts"
-msgstr "Tous les Hashcuts"
+#: templates/mashup_home.html:108
+msgid "Available videos"
+msgstr "Vidéos sources disponibles"
 
-#: templates/mashup_home.html:111
+#: templates/mashup_home.html:125
 msgid "What's a Hashcut?"
 msgstr "Hashcut ?"
 
-#: templates/mashup_home.html:116
+#: templates/mashup_home.html:130
 msgid "How to?"
 msgstr "Comment faire ?"
 
-#: templates/mashup_home.html:119
+#: templates/mashup_home.html:133
 msgid "Sign up"
 msgstr "S'inscrire"
 
-#: templates/mashup_home.html:120
+#: templates/mashup_home.html:134
 msgid "Start by creating your own profile on this platform."
 msgstr "Commencez par créer votre espace personnel sur cette plateforme."
 
-#: templates/mashup_home.html:124
+#: templates/mashup_home.html:138
 msgid "Create a new hashcut"
 msgstr "Créer un Hashcut"
 
-#: templates/mashup_home.html:125
+#: templates/mashup_home.html:139
 msgid ""
 "Choose videos, define and organize segments and comment them to create your "
 "own hashcut."
@@ -274,11 +284,11 @@
 "Choisissez des médias, segmentez les, assemblez les segments et rajoutez des "
 "commentaires sur le Hashcut."
 
-#: templates/mashup_home.html:129
+#: templates/mashup_home.html:143
 msgid "Publish and share"
 msgstr "Publier et partager"
 
-#: templates/mashup_home.html:130
+#: templates/mashup_home.html:144
 msgid ""
 "Once your hashcut is done, publish it here and share your work on social "
 "networks."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hashcut/templates/mashup_all_contents.html	Thu Dec 06 14:30:23 2012 +0100
@@ -0,0 +1,62 @@
+{% extends "mashup_home.html" %}
+{% load static %}
+{% load i18n %}
+{% load analytics %}
+{% load thumbnail %}
+{% load front_tags %}
+    {% block title %}{% trans 'All source videos' %}{% endblock %}
+    {% block css_page %}
+    <link rel="stylesheet" href="{% static 'hashcut' %}/{{branding}}/css/profil.css" />
+    {% endblock %}
+
+{% block wrap_header %}
+<div class="wrap-header"> 
+    <div class="header">
+    {% include 'partial/mashup_popin_user.html' %}
+    {% include 'partial/hashcut_logo.html' %}
+        <div class="title-video-wrap">
+            <p class="title-video" href="#">{% trans 'All source videos' %}</p>
+        </div>
+        <div class="profil-wrap">
+            <ul>
+                <li><a href="{% url mashup_home branding=branding %}" class="all-hashcut">{% trans "Home" %}</a></li>
+                <li><a href="{% url mashup_edit branding=branding %}" class="new-hashcut">{% trans "New hashcut" %}</a></li>
+                <li><a href="#user" class="my-profil open-popin">{% trans "My profile" %}</a></li>
+            </ul>
+        </div>
+    </div><!-- header -->
+</div> <!-- wrap-header -->
+{% endblock %}
+
+{% block content %}
+<div class="content">
+    
+    <div class="pagination">
+            {% if results.has_previous %}
+                <a href="{% url mashup_all_contents branding=branding %}?page={{ results.previous_page_number }}" >{% trans "Previous" %}</a>
+            {% endif %}
+            {% if results.paginator.num_pages > 1 %}
+              {% for i in results.paginator.num_pages|get_range %}
+                 <a {% if i|add:'1' == results.number %} class="active"{% endif %} href="{% url mashup_all_contents branding=branding %}?page={{i|add:'1'}}">{{i|add:'1'}}</a>
+              {% endfor %}
+            {% endif %}
+            {% if results.has_next %}
+                <a href="{% url mashup_all_contents branding=branding %}?page={{ results.next_page_number }}">{% trans "Next" %}</a>
+            {% endif %}
+            {% if results.paginator.num_pages > 1 %}
+                <a href="{% url mashup_all_contents branding=branding %}?page=x">({% trans "All" %})</a>
+            {% endif %}
+            </p>
+    </div>
+    
+    <div class="hashcut-video-wrap profil">
+        {% for content in results.object_list %}
+        <div class="video-item">
+            <a href="{% url mashup_content branding=branding ctt_id=content.iri_id %}" class="screenshot">{% thumbnail content.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %}&nbsp;{% endthumbnail %}</a>
+            <h3><a class="title" href="{% url mashup_content branding=branding ctt_id=content.iri_id %}">{% if content.title|length > 30 %}{{content.title|slice:":30"}}...{% else %}{{content.title}}{% endif %}</a> | <span class="duration">{{content.duration|str_duration:"h"}}</span></h3>
+        </div>
+        {% endfor %}
+    </div>
+</div><!-- content -->
+{% endblock %}
+
--- a/src/hashcut/templates/mashup_all_mashups.html	Thu Dec 06 12:38:51 2012 +0100
+++ b/src/hashcut/templates/mashup_all_mashups.html	Thu Dec 06 14:30:23 2012 +0100
@@ -4,7 +4,7 @@
 {% load analytics %}
 {% load thumbnail %}
 {% load front_tags %}
-    {% block title %}Tous les Hashcuts{% endblock %}
+    {% block title %}{% trans 'All Hashcuts' %}{% endblock %}
     {% block css_page %}
     <link rel="stylesheet" href="{% static 'hashcut' %}/{{branding}}/css/profil.css" />
     {% endblock %}
@@ -15,7 +15,7 @@
     {% include 'partial/mashup_popin_user.html' %}
     {% include 'partial/hashcut_logo.html' %}
         <div class="title-video-wrap">
-            <p class="title-video" href="#">Tous les Hashcuts</p>
+            <p class="title-video" href="#">{% trans 'All Hashcuts' %}</p>
         </div>
         <div class="profil-wrap">
             <ul>
--- a/src/hashcut/templates/mashup_home.html	Thu Dec 06 12:38:51 2012 +0100
+++ b/src/hashcut/templates/mashup_home.html	Thu Dec 06 14:30:23 2012 +0100
@@ -96,7 +96,7 @@
                     {% for m in mashups %}
                     <div class="video-item">
                         <a href="{% url mashup_hashcut branding=branding ldt_id=m.project.ldt_id %}" class="screenshot">{% thumbnail m.project.image "142x95" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %}&nbsp;{% endthumbnail %}</a>
-                        <h3><a class="title" href="{% url mashup_hashcut branding=branding ldt_id=m2.project.ldt_id %}">{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %}</a> {% trans "by" %} <a class="author" href="{% url mashup_profile branding=branding username=m.creator %}">{{ m.creator }}</a><!-- | <span class="duration">02:24</span> --></h3>
+                        <h3><a class="title" href="{% url mashup_hashcut branding=branding ldt_id=m.project.ldt_id %}">{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %}</a> {% trans "by" %} <a class="author" href="{% url mashup_profile branding=branding username=m.creator %}">{{ m.creator }}</a><!-- | <span class="duration">02:24</span> --></h3>
                     </div>
                     {% endfor %}
                 </div>
@@ -104,7 +104,21 @@
                 <div class="pagination">
                     <a href="{% url mashup_all branding=branding %}">{% trans 'All Hashcuts' %}</a>
                 </div>
-           
+
+                <h2>{% trans "Available videos" %}</h2>
+                <div class="hashcut-video-wrap last">
+                    {% for content in contents %}
+                    <div class="video-item">
+                        <a href="{% url mashup_content branding=branding ctt_id=content.iri_id %}" class="screenshot">{% thumbnail content.image "142x95" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %}&nbsp;{% endthumbnail %}</a>
+                        <h3><a class="title" href="{% url mashup_content branding=branding ctt_id=content.iri_id %}">{% if content.title|length > 30 %}{{content.title|slice:":30"}}...{% else %}{{content.title}}{% endif %}</a> {% trans "by" %} | <span class="duration">{{content.duration|str_duration:"h"}}</span></h3>
+                    </div>
+                    {% endfor %}
+                </div>
+                
+                <div class="pagination">
+                    <a href="{% url mashup_all_contents branding=branding %}">{% trans 'All source videos' %}</a>
+                </div>
+                           
             </div><!-- left-content -->
             <div class="right-content">
                 <div class="definition">
--- a/src/hashcut/urls.py	Thu Dec 06 12:38:51 2012 +0100
+++ b/src/hashcut/urls.py	Thu Dec 06 14:30:23 2012 +0100
@@ -1,6 +1,6 @@
 from django.conf.urls.defaults import patterns, url
 from hashcut.views import MashupHome, MashupEdit, MashupHashcut, MashupContent, MashupProfile, MashupAllMashups,\
-    MashupCreateUser, MashupIdenticateUser
+    MashupAllContents, MashupCreateUser, MashupIdenticateUser
 
 urlpatterns = patterns('',
     url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog', name='jsi18n'),
@@ -10,6 +10,7 @@
     url(r'^(?P<branding>.*)/media/(?P<ctt_id>.*)/$', MashupContent.as_view(), name="mashup_content"),
     url(r'^(?P<branding>.*)/profile/(?P<username>.*)/$', MashupProfile.as_view(), name="mashup_profile"),
     url(r'^(?P<branding>.*)/all/$', MashupAllMashups.as_view(), name="mashup_all"),
+    url(r'^(?P<branding>.*)/allcontents/$', MashupAllContents.as_view(), name="mashup_all_contents"),
     url(r'^(?P<branding>.*)/createuser/$', MashupCreateUser.as_view(), name="mashup_create_user"),
     url(r'^(?P<branding>.*)/iduser/$', MashupIdenticateUser.as_view(), name="mashup_identicate_user"),
     url(r'^(?P<branding>.*)/$', MashupHome.as_view(), name="mashup_home"),
--- a/src/hashcut/views.py	Thu Dec 06 12:38:51 2012 +0100
+++ b/src/hashcut/views.py	Thu Dec 06 14:30:23 2012 +0100
@@ -40,7 +40,7 @@
         m1 = None
         m2 = None
         last_mashups = None
-        mashups = Mashup.objects.filter(branding=brd).order_by('-project__creation_date')[:10]
+        mashups = Mashup.objects.filter(branding=brd).order_by('-project__creation_date')[:6]
         logging.debug(repr(mashups))
         l = len(mashups)
         if l>0:
@@ -49,8 +49,11 @@
             m2 = mashups[1]
         if l>2:
             last_mashups = mashups[2:]
+        
+        contents = Content.objects.filter(tags__icontains=branding).order_by('?')[:4]
+        
         context = self.get_context_dict(request)
-        context.update({"mashups":last_mashups, "m1":m1, "m2":m2})
+        context.update({"mashups":last_mashups, "contents": contents, "m1":m1, "m2":m2})
         return self.render_to_response(context)
     
 
@@ -179,6 +182,32 @@
         context = self.get_context_dict(request)
         context.update({"results":results})
         return self.render_to_response(context)
+    
+
+
+class MashupAllContents(TemplateResponseMixin, MashupContextView):
+    
+    def get_template_names(self):
+        return "mashup_all_contents.html"
+    
+    def get(self, request, branding="iri", **kwargs):
+        page = request.GET.get("page") or 1
+        self.branding = branding
+        
+        contents = Content.objects.filter(tags__icontains=branding)
+        nb = getattr(settings, 'LDT_FRONT_MEDIA_PER_PAGE', 9)
+        if page=="x":
+            nb = contents.count()
+        
+        paginator = Paginator(contents, nb)
+        try:
+            results = paginator.page(page)
+        except (EmptyPage, InvalidPage):
+            results = paginator.page(paginator.num_pages)
+        
+        context = self.get_context_dict(request)
+        context.update({"results":results})
+        return self.render_to_response(context)