--- a/src/hashcut/static/hashcut/bpi/css/common.css Fri Nov 30 16:48:37 2012 +0100
+++ b/src/hashcut/static/hashcut/bpi/css/common.css Fri Nov 30 16:49:12 2012 +0100
@@ -415,6 +415,7 @@
color: #C81000;
}
.pagination{
+ padding: 0 0 20px;
text-align: center;
}
.pagination a{
--- a/src/hashcut/static/hashcut/iri/css/common.css Fri Nov 30 16:48:37 2012 +0100
+++ b/src/hashcut/static/hashcut/iri/css/common.css Fri Nov 30 16:49:12 2012 +0100
@@ -415,6 +415,7 @@
color: #C81000;
}
.pagination{
+ padding: 0 0 20px;
text-align: center;
}
.pagination a{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hashcut/templates/bpi_mashup_all_mashups.html Fri Nov 30 16:49:12 2012 +0100
@@ -0,0 +1,61 @@
+{% extends "bpi_mashup_home.html" %}
+{% load static %}
+{% load i18n %}
+{% load analytics %}
+{% load thumbnail %}
+{% load front_tags %}
+ {% block title %}Tous les Hashcuts{% endblock %}
+ {% block css_page %}
+ <link rel="stylesheet" href="{% static 'hashcut/bpi/css/profil.css' %}" />
+ {% endblock %}
+
+{% block wrap_header %}
+<div class="wrap-header">
+ <div class="header">
+ {% include 'partial/bpi_mashup_popin_user.html' %}
+ {% include 'partial/bpi_hashcut_logo.html' %}
+ <div class="title-header"></div>
+ <div class="profil-wrap">
+ <ul>
+ <li><a href="{% url mashup_home branding=branding %}" class="all-hashcut">Accueil</a></li>
+ <li><a href="{% url mashup_edit branding=branding %}" class="new-hashcut">Créer un Hashcut</a></li>
+ <li><a href="#user" class="my-profil open-popin">Mon profil</a></li>
+ </ul>
+ </div>
+ </div><!-- header -->
+</div> <!-- wrap-header -->
+{% endblock %}
+
+{% block content %}
+<div class="content">
+ <h2 class="title-content">Tous les Hashcuts</h2>
+
+ <div class="pagination">
+ {% if results.has_previous %}
+ <a href="{% url mashup_all branding=branding %}?page={{ results.previous_page_number }}" >Précédent</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 branding=branding %}?page={{i|add:'1'}}">{{i|add:'1'}}</a>
+ {% endfor %}
+ {% endif %}
+ {% if results.has_next %}
+ <a href="{% url mashup_all branding=branding %}?page={{ results.next_page_number }}">Suivant</a>
+ {% endif %}
+ {% if results.paginator.num_pages > 1 %}
+ <a href="{% url mashup_all branding=branding %}?page=x">(Tous)</a>
+ {% endif %}
+ </p>
+ </div>
+
+ <div class="hashcut-video-wrap profil">
+ {% for m in results.object_list %}
+ <div class="video-item">
+ <a href="{% url mashup_hashcut branding=branding ldt_id=m.project.ldt_id %}" class="screenshot">{% thumbnail m.project.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
+ <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> par {{ m.creator }} | <span class="duration">02:24</span> </h3>
+ </div>
+ {% endfor %}
+ </div>
+</div><!-- content -->
+{% endblock %}
+
--- a/src/hashcut/templates/bpi_mashup_home.html Fri Nov 30 16:48:37 2012 +0100
+++ b/src/hashcut/templates/bpi_mashup_home.html Fri Nov 30 16:49:12 2012 +0100
@@ -2,6 +2,7 @@
{% load i18n %}
{% load analytics %}
{% load thumbnail %}
+{% load front_tags %}
<!DOCTYPE html>
<html>
<head>
@@ -86,7 +87,7 @@
</div>
<div class="pagination">
- <a href="#">Tous les Hashcuts</a>
+ <a href="{% url mashup_all branding=branding %}">Tous les Hashcuts</a>
</div>
</div><!-- left-content -->
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hashcut/templates/iri_mashup_all_mashups.html Fri Nov 30 16:49:12 2012 +0100
@@ -0,0 +1,61 @@
+{% extends "iri_mashup_home.html" %}
+{% load static %}
+{% load i18n %}
+{% load analytics %}
+{% load thumbnail %}
+{% load front_tags %}
+ {% block title %}Tous les Hashcuts{% endblock %}
+ {% block css_page %}
+ <link rel="stylesheet" href="{% static 'hashcut/iri/css/profil.css' %}" />
+ {% endblock %}
+
+{% block wrap_header %}
+<div class="wrap-header">
+ <div class="header">
+ {% include 'partial/iri_mashup_popin_user.html' %}
+ {% include 'partial/iri_hashcut_logo.html' %}
+ <div class="title-header"></div>
+ <div class="profil-wrap">
+ <ul>
+ <li><a href="{% url mashup_home branding=branding %}" class="all-hashcut">Accueil</a></li>
+ <li><a href="{% url mashup_edit branding=branding %}" class="new-hashcut">Créer un Hashcut</a></li>
+ <li><a href="#user" class="my-profil open-popin">Mon profil</a></li>
+ </ul>
+ </div>
+ </div><!-- header -->
+</div> <!-- wrap-header -->
+{% endblock %}
+
+{% block content %}
+<div class="content">
+ <h2 class="title-content">Tous les Hashcuts</h2>
+
+ <div class="pagination">
+ {% if results.has_previous %}
+ <a href="{% url mashup_all branding=branding %}?page={{ results.previous_page_number }}" >Précédent</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 branding=branding %}?page={{i|add:'1'}}">{{i|add:'1'}}</a>
+ {% endfor %}
+ {% endif %}
+ {% if results.has_next %}
+ <a href="{% url mashup_all branding=branding %}?page={{ results.next_page_number }}">Suivant</a>
+ {% endif %}
+ {% if results.paginator.num_pages > 1 %}
+ <a href="{% url mashup_all branding=branding %}?page=x">(Tous)</a>
+ {% endif %}
+ </p>
+ </div>
+
+ <div class="hashcut-video-wrap profil">
+ {% for m in results.object_list %}
+ <div class="video-item">
+ <a href="{% url mashup_hashcut branding=branding ldt_id=m.project.ldt_id %}" class="screenshot">{% thumbnail m.project.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
+ <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> par {{ m.creator }} | <span class="duration">02:24</span> </h3>
+ </div>
+ {% endfor %}
+ </div>
+</div><!-- content -->
+{% endblock %}
+
--- a/src/hashcut/templates/iri_mashup_home.html Fri Nov 30 16:48:37 2012 +0100
+++ b/src/hashcut/templates/iri_mashup_home.html Fri Nov 30 16:49:12 2012 +0100
@@ -86,7 +86,7 @@
</div>
<div class="pagination">
- <a href="#">Tous les Hashcuts</a>
+ <a href="{% url mashup_all branding=branding %}">Tous les Hashcuts</a>
</div>
</div><!-- left-content -->
--- a/src/hashcut/urls.py Fri Nov 30 16:48:37 2012 +0100
+++ b/src/hashcut/urls.py Fri Nov 30 16:49:12 2012 +0100
@@ -1,5 +1,5 @@
from django.conf.urls.defaults import patterns, url
-from hashcut.views import MashupHome, MashupEdit, MashupHashcut, MashupContent, MashupProfile
+from hashcut.views import MashupHome, MashupEdit, MashupHashcut, MashupContent, MashupProfile, MashupAllMashups
urlpatterns = patterns('',
url(r'^(?P<branding>.*)/edit/$', MashupEdit.as_view(), name="mashup_edit"),
@@ -7,6 +7,7 @@
url(r'^(?P<branding>.*)/hashcut/(?P<ldt_id>.*)/$', MashupHashcut.as_view(), name="mashup_hashcut"),
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>.*)/$', MashupHome.as_view(), name="mashup_home"),
url(r'^$', MashupHome.as_view()),
)
--- a/src/hashcut/views.py Fri Nov 30 16:48:37 2012 +0100
+++ b/src/hashcut/views.py Fri Nov 30 16:49:12 2012 +0100
@@ -1,4 +1,6 @@
+from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
+from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.http import HttpResponseNotFound
from django.views.generic.base import View, TemplateResponseMixin
from ldt.api.ldt.resources import ProjectResource
@@ -235,5 +237,49 @@
context.update({"username":username, "mashups":mashups})
return self.render_to_response(context)
+
+
+class MashupAllMashups(TemplateResponseMixin, MashupContextView):
+
+ # iri = default brand name
+ branding = "iri"
+ template_suffix = "mashup_all_mashups.html"
+ template_name = "iri_mashup_all_mashups.html"
+
+ def get_template_names(self):
+ """
+ Return a list of template names to be used for the request. Must return
+ a list. May not be called if get_template is overridden.
+ """
+ try:
+ names = super(MashupAllMashups, self).get_template_names()
+ except ImproperlyConfigured:
+ raise ImproperlyConfigured("Class MashupAllMashups requires either a definition of 'template_name'")
+
+ # the branding template is supposed to override the default template. So we insert instead of append
+ if self.branding and self.branding != "":
+ names.insert(0,"%s_%s" % (self.branding, self.template_suffix))
+
+ return names
+
+ def get(self, request, branding="iri", **kwargs):
+ page = request.GET.get("page") or 1
+ self.branding = branding
+ brd = Branding.objects.get(name=self.branding)
+
+ mashups = Mashup.objects.filter(branding=brd)
+ nb = getattr(settings, 'LDT_FRONT_MEDIA_PER_PAGE', 9)
+ if page=="x":
+ nb = mashups.count()
+
+ paginator = Paginator(mashups, 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)
\ No newline at end of file