Home with real links to branding hashcut.
--- a/src/hashcut/templates/bpi_mashup_home.html Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/templates/bpi_mashup_home.html Thu Nov 29 17:01:37 2012 +0100
@@ -30,7 +30,7 @@
{% block body %}
<div class="wrap-header-top">
<div class="wrap-header-top-content">
- <a title="Bibliothèque Publique d'Information" href="#"><img src="{% static 'hashcut/bpi/img/pompidou-logo.png' %}" alt="Bibliothèque centre Pompidou" /></a>
+ <a title="Bibliothèque Publique d'Information" href="{% url mashup_home branding=branding %}"><img src="{% static 'hashcut/bpi/img/pompidou-logo.png' %}" alt="Bibliothèque centre Pompidou" /></a>
</div>
</div><!-- wrap-header-top -->
@@ -60,21 +60,25 @@
<h2>Hashcuts à la Une</h2>
<div class="hashcut-video-wrap news">
<div class="video-item">
- <a href="" class="screenshot">{% thumbnail p1.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
- <h3><strong>{{ p1.title }}</strong> par <a href="#">{{ p1.created_by }}</a> | <span>02:24</span> </h3>
+ {% if m1 %}
+ <a href="{% url mashup_hashcut branding=branding ldt_id=m1.project.ldt_id %}" class="screenshot">{% thumbnail m1.project.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
+ <h3><strong>{{ m1.project.title }}</strong> par <a href="#">{{ m1.creator }}</a> | <span>02:24</span> </h3>
+ {% endif %}
</div>
<div class="video-item">
- <a href="#" class="screenshot">{% thumbnail p2.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
- <h3><strong>{{ p2.title }}</strong> par <a href="#">{{ p1.created_by }}</a> | <span>02:24</span> </h3>
+ {% if m2 %}
+ <a href="{% url mashup_hashcut branding=branding ldt_id=m2.project.ldt_id %}" class="screenshot">{% thumbnail m2.project.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
+ <h3><strong>{{ m2.project.title }}</strong> par <a href="#">{{ m2.creator }}</a> | <span>02:24</span> </h3>
+ {% endif %}
</div>
</div>
<h2>Derniers Hashcuts</h2>
<div class="hashcut-video-wrap last">
- {% for p in projects %}
+ {% for m in mashups %}
<div class="video-item">
- <a href="#" class="screenshot">{% thumbnail p.image "142x95" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
- <h3><strong>{% if p.title|length > 30 %}{{p.title|slice:":30"}}...{% else %}{{p.title}}{% endif %}</strong> par <a href="#">{{ p.created_by }}</a> | <span>02:24</span> </h3>
+ <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 %} {% endthumbnail %}</a>
+ <h3><strong>{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %}</strong> par <a href="#">{{ m.creator }}</a> | <span>02:24</span> </h3>
</div>
{% endfor %}
</div>
--- a/src/hashcut/templates/iri_mashup_home.html Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/templates/iri_mashup_home.html Thu Nov 29 17:01:37 2012 +0100
@@ -30,7 +30,7 @@
{% block body %}
<div class="wrap-header-top">
<div class="wrap-header-top-content">
- <a title="Institut de recherche et d'innovation" href="#"><img src="{% static 'hashcut/iri/img/logo-iri.png' %}" alt="Institut de recherche et d'innovation" /></a>
+ <a title="Institut de recherche et d'innovation" href="{% url mashup_home branding=branding %}"><img src="{% static 'hashcut/iri/img/logo-iri.png' %}" alt="Institut de recherche et d'innovation" /></a>
</div>
</div><!-- wrap-header-top -->
@@ -60,21 +60,25 @@
<h2>Hashcuts à la Une</h2>
<div class="hashcut-video-wrap news">
<div class="video-item">
- <a href="" class="screenshot">{% thumbnail p1.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
- <h3><strong>{{ p1.title }}</strong> par <a href="#">{{ p1.created_by }}</a> | <span>02:24</span> </h3>
+ {% if m1 %}
+ <a href="{% url mashup_hashcut branding=branding ldt_id=m1.project.ldt_id %}" class="screenshot">{% thumbnail m1.project.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
+ <h3><strong>{{ m1.project.title }}</strong> par <a href="#">{{ m1.creator }}</a> | <span>02:24</span> </h3>
+ {% endif %}
</div>
<div class="video-item">
- <a href="#" class="screenshot">{% thumbnail p2.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
- <h3><strong>{{ p2.title }}</strong> par <a href="#">{{ p1.created_by }}</a> | <span>02:24</span> </h3>
+ {% if m2 %}
+ <a href="{% url mashup_hashcut branding=branding ldt_id=m2.project.ldt_id %}" class="screenshot">{% thumbnail m2.project.image "302x202" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
+ <h3><strong>{{ m2.project.title }}</strong> par <a href="#">{{ m2.creator }}</a> | <span>02:24</span> </h3>
+ {% endif %}
</div>
</div>
<h2>Derniers Hashcuts</h2>
<div class="hashcut-video-wrap last">
- {% for p in projects %}
+ {% for m in mashups %}
<div class="video-item">
- <a href="#" class="screenshot">{% thumbnail p.image "142x95" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""/>{% empty %} {% endthumbnail %}</a>
- <h3><strong>{% if p.title|length > 30 %}{{p.title|slice:":30"}}...{% else %}{{p.title}}{% endif %}</strong> par <a href="#">{{ p.created_by }}</a> | <span>02:24</span> </h3>
+ <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 %} {% endthumbnail %}</a>
+ <h3><strong>{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %}</strong> par <a href="#">{{ m.creator }}</a> | <span>02:24</span> </h3>
</div>
{% endfor %}
</div>
--- a/src/hashcut/templates/partial/bpi_hashcut_logo.html Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/templates/partial/bpi_hashcut_logo.html Thu Nov 29 17:01:37 2012 +0100
@@ -1,5 +1,5 @@
{% load static %}
- <h1><a title="Hashcut - Le Mashup cliquable" class="clearfix" href="#">
+ <h1><a title="Hashcut - Le Mashup cliquable" class="clearfix" href="{% url mashup_home branding=branding %}">
<img src="{% static 'hashcut/bpi/img/hashcut-logo.png' %}" alt="Hashcut" />
<span>Le Mashup<br />Cliquable</span>
</a></h1>
\ No newline at end of file
--- a/src/hashcut/templates/partial/bpi_mashup_popin_user.html Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/templates/partial/bpi_mashup_popin_user.html Thu Nov 29 17:01:37 2012 +0100
@@ -4,8 +4,8 @@
<div class="pointer"></div>
<div class="popin-content">
<h2>{{creator}}</h2>
- <h3>mash@cinecast.fr</h3>
- <a href="#" class="nb-hashcut">12 Hashcuts</a>
+ <h3>{{email_creator}}</h3>
+ <a href="#" class="nb-hashcut">{{nb_mashup_creator}} Hashcuts</a>
<p>
<a href="#" class="change-account button">Changer de compte</a>
</p>
--- a/src/hashcut/templates/partial/iri_hashcut_logo.html Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/templates/partial/iri_hashcut_logo.html Thu Nov 29 17:01:37 2012 +0100
@@ -1,5 +1,5 @@
{% load static %}
- <h1><a title="Hashcut - Le Mashup cliquable" class="clearfix" href="#">
+ <h1><a title="Hashcut - Le Mashup cliquable" class="clearfix" href="{% url mashup_home branding=branding %}">
<img src="{% static 'hashcut/iri/img/hashcut-logo.png' %}" alt="Hashcut" />
<span>Le Mashup<br />Cliquable</span>
</a></h1>
\ No newline at end of file
--- a/src/hashcut/templates/partial/iri_mashup_popin_user.html Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/templates/partial/iri_mashup_popin_user.html Thu Nov 29 17:01:37 2012 +0100
@@ -4,8 +4,8 @@
<div class="pointer"></div>
<div class="popin-content">
<h2>{{creator}}</h2>
- <h3>mash@cinecast.fr</h3>
- <a href="#" class="nb-hashcut">12 Hashcuts</a>
+ <h3>{{email_creator}}</h3>
+ <a href="#" class="nb-hashcut">{{nb_mashup_creator}} Hashcuts</a>
<p>
<a href="#" class="change-account button">Changer de compte</a>
</p>
--- a/src/hashcut/views.py Thu Nov 29 13:23:13 2012 +0100
+++ b/src/hashcut/views.py Thu Nov 29 17:01:37 2012 +0100
@@ -6,8 +6,26 @@
import logging
from hashcut.models import Mashup, Branding
+class MashupContextView(View):
+
+ branding = "iri"
+
+ def get_context_dict(self, request):
+ context = {}
+ context["branding"] = self.branding
+ context["creator"] = ""
+ context["nb_mashup_creator"] = ""
+ if request and request.user:
+ context["creator"] = request.user.username
+ if not self.branding or self.branding=="":
+ self.branding = "iri"
+ brd = Branding.objects.get(name=self.branding)
+ context["nb_mashup_creator"] = Mashup.objects.filter(branding=brd,project__owner=request.user).count()
+ return context
+
+
-class MashupHome(TemplateResponseMixin, View):
+class MashupHome(TemplateResponseMixin, MashupContextView):
# iri = default brand name
branding = "iri"
@@ -31,19 +49,28 @@
return names
- def get(self, request, branding=None, **kwargs):
- if branding and branding!="":
- self.branding = branding
- projects = Project.safe_objects.all()[:10]
- p1 = projects[0]
- p2 = projects[1]
- projects = projects[2:]
- context = {"branding":self.branding, "projects":projects, "p1":p1, "p2":p2}
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+ brd = Branding.objects.get(name=self.branding)
+ m1 = None
+ m2 = None
+ last_mashups = None
+ mashups = Mashup.objects.filter(branding=brd)[:10]
+ logging.debug(repr(mashups))
+ l = len(mashups)
+ if l>0:
+ m1 = mashups[0]
+ if l>1:
+ m2 = mashups[1]
+ if l>2:
+ last_mashups = mashups[2:]
+ context = self.get_context_dict(request)
+ context.update({"mashups":last_mashups, "m1":m1, "m2":m2})
return self.render_to_response(context)
-class MashupEdit(TemplateResponseMixin, View):
+class MashupEdit(TemplateResponseMixin, MashupContextView):
# iri = default brand name
branding = "iri"
@@ -68,22 +95,19 @@
def get(self, request, branding="iri", **kwargs):
self.branding = branding
- context = {"branding":self.branding, "creator":request.user.username}
+ context = self.get_context_dict(request)
return self.render_to_response(context)
+
+# save mashup view, not include in generic views
def save_mashup(request, branding="iri"):
# First we use the project api to save the project
- logging.debug("save_mashup 1")
proj_api = ProjectResource()
- logging.debug("save_mashup 2 " + repr(proj_api))
rtrn = proj_api.dispatch_list(request)
- logging.debug("save_mashup 3 " + repr(rtrn))
if rtrn and rtrn['Location']:
- logging.debug("save_mashup 4 " + rtrn['Location'])
# The api return the api location of the created project (i.e. /a/b/ldt_id/). So we just get the id to get the project object.
proj_ldt_id = rtrn['Location'].split("/")[-2]
- logging.debug("save_mashup 5 proj_ldt_id = " + proj_ldt_id)
proj = None
try:
proj = Project.objects.get(ldt_id=proj_ldt_id)
@@ -91,18 +115,15 @@
raise ObjectDoesNotExist("Save Mashup : project not found. project_ldt_id = " + proj_ldt_id)
# Now that we have the project object, we can save the mashup object
brd = Branding.objects.get(name=branding)
- logging.debug("save_mashup 6" + repr(brd))
new_mashup = Mashup()
new_mashup.branding = brd
new_mashup.project = proj
- logging.debug("save_mashup 7 new_mashup = " + repr(new_mashup))
new_mashup.save()
- logging.debug("save_mashup 8")
return rtrn
-class MashupHashcut(TemplateResponseMixin, View):
+class MashupHashcut(TemplateResponseMixin, MashupContextView):
# iri = default brand name
branding = "iri"
@@ -129,12 +150,13 @@
self.branding = branding
if not ldt_id:
return HttpResponseNotFound("A project id must be given.")
- context = {"branding":self.branding, "ldt_id":ldt_id}
+ context = self.get_context_dict(request)
+ context.update({"ldt_id":ldt_id})
return self.render_to_response(context)
-class MashupContent(TemplateResponseMixin, View):
+class MashupContent(TemplateResponseMixin, MashupContextView):
# iri = default brand name
branding = "iri"
@@ -161,7 +183,8 @@
self.branding = branding
if not ctt_id:
return HttpResponseNotFound("A content id must be given.")
- context = {"branding":self.branding, "ctt_id":ctt_id}
+ context = self.get_context_dict(request)
+ context.update({"ctt_id":ctt_id})
return self.render_to_response(context)