# HG changeset patch # User cavaliet # Date 1354204897 -3600 # Node ID 3515d39ce155f7ecf2a1094ecf2557299716363b # Parent e21284fab296ac743c041c869368144aec46e06a Home with real links to branding hashcut. diff -r e21284fab296 -r 3515d39ce155 src/hashcut/templates/bpi_mashup_home.html --- 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 %}
- Bibliothèque centre Pompidou + Bibliothèque centre Pompidou
@@ -60,21 +60,25 @@

Hashcuts à la Une

- {% thumbnail p1.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} -

{{ p1.title }} par {{ p1.created_by }} | 02:24

+ {% if m1 %} + {% thumbnail m1.project.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} +

{{ m1.project.title }} par {{ m1.creator }} | 02:24

+ {% endif %}
- {% thumbnail p2.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} -

{{ p2.title }} par {{ p1.created_by }} | 02:24

+ {% if m2 %} + {% thumbnail m2.project.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} +

{{ m2.project.title }} par {{ m2.creator }} | 02:24

+ {% endif %}

Derniers Hashcuts

- {% for p in projects %} + {% for m in mashups %}
- {% thumbnail p.image "142x95" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} -

{% if p.title|length > 30 %}{{p.title|slice:":30"}}...{% else %}{{p.title}}{% endif %} par {{ p.created_by }} | 02:24

+ {% thumbnail m.project.image "142x95" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} +

{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %} par {{ m.creator }} | 02:24

{% endfor %}
diff -r e21284fab296 -r 3515d39ce155 src/hashcut/templates/iri_mashup_home.html --- 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 %}
- Institut de recherche et d'innovation + Institut de recherche et d'innovation
@@ -60,21 +60,25 @@

Hashcuts à la Une

- {% thumbnail p1.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} -

{{ p1.title }} par {{ p1.created_by }} | 02:24

+ {% if m1 %} + {% thumbnail m1.project.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} +

{{ m1.project.title }} par {{ m1.creator }} | 02:24

+ {% endif %}
- {% thumbnail p2.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} -

{{ p2.title }} par {{ p1.created_by }} | 02:24

+ {% if m2 %} + {% thumbnail m2.project.image "302x202" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} +

{{ m2.project.title }} par {{ m2.creator }} | 02:24

+ {% endif %}

Derniers Hashcuts

- {% for p in projects %} + {% for m in mashups %}
- {% thumbnail p.image "142x95" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} -

{% if p.title|length > 30 %}{{p.title|slice:":30"}}...{% else %}{{p.title}}{% endif %} par {{ p.created_by }} | 02:24

+ {% thumbnail m.project.image "142x95" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} +

{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %} par {{ m.creator }} | 02:24

{% endfor %}
diff -r e21284fab296 -r 3515d39ce155 src/hashcut/templates/partial/bpi_hashcut_logo.html --- 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 %} -

+

Hashcut Le Mashup
Cliquable

\ No newline at end of file diff -r e21284fab296 -r 3515d39ce155 src/hashcut/templates/partial/bpi_mashup_popin_user.html --- 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 @@

{{creator}}

-

mash@cinecast.fr

- 12 Hashcuts +

{{email_creator}}

+ {{nb_mashup_creator}} Hashcuts

diff -r e21284fab296 -r 3515d39ce155 src/hashcut/templates/partial/iri_hashcut_logo.html --- 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 %} -

+

Hashcut Le Mashup
Cliquable

\ No newline at end of file diff -r e21284fab296 -r 3515d39ce155 src/hashcut/templates/partial/iri_mashup_popin_user.html --- 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 @@

{{creator}}

-

mash@cinecast.fr

- 12 Hashcuts +

{{email_creator}}

+ {{nb_mashup_creator}} Hashcuts

diff -r e21284fab296 -r 3515d39ce155 src/hashcut/views.py --- 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)