add profile page.
--- a/src/hashcut/models.py Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/models.py Fri Nov 30 14:21:52 2012 +0100
@@ -17,7 +17,7 @@
branding = models.ForeignKey(Branding)
def __unicode__(self):
- return unicode(self.id) + u"::" + unicode(self.branding.name) + u"::" + unicode(self.project.ldt_id)
+ return unicode(self.id) + u"::" + unicode(self.branding.name) + u"::" + unicode(self.project.owner) + u"::" + unicode(self.project.ldt_id)
def creator(): #@NoSelf
def fget(self):
--- a/src/hashcut/templates/bpi_mashup_hashcut.html Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/templates/bpi_mashup_hashcut.html Fri Nov 30 14:21:52 2012 +0100
@@ -27,7 +27,7 @@
<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext" title="Partager sur Google+"></a>
<a href="#" target="_blank" class="Ldt-Social-Mail" title="Partager par mail"></a>
</div>
- <p class="title-video" href="#">Hashcut » {{proj.title}}</p>
+ <p class="title-video">Hashcut » {{proj.title}}</p>
</div>
<div class="profil-wrap">
<ul>
@@ -127,7 +127,7 @@
<tbody>
<tr class="info-title">
<th>Titre :</th>
- <td><a href="#">{{proj.title}}</a></td>
+ <td><a>{{proj.title}}</a></td>
</tr>
<tr class="info-duration">
<th>Durée :</th>
--- a/src/hashcut/templates/bpi_mashup_home.html Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/templates/bpi_mashup_home.html Fri Nov 30 14:21:52 2012 +0100
@@ -64,13 +64,13 @@
<div class="video-item">
{% 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>
+ <h3><strong>{{ m1.project.title }}</strong> par <a href="{% url mashup_profile branding=branding username=m1.creator %}">{{ m1.creator }}</a> | <span>02:24</span> </h3>
{% endif %}
</div>
<div class="video-item">
{% 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>
+ <h3><strong>{{ m2.project.title }}</strong> par <a href="{% url mashup_profile branding=branding username=m2.creator %}">{{ m2.creator }}</a> | <span>02:24</span> </h3>
{% endif %}
</div>
</div>
@@ -80,7 +80,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 %} {% 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>
+ <h3><strong>{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %}</strong> par <a href="{% url mashup_profile branding=branding username=m.creator %}">{{ m.creator }}</a> | <span>02:24</span> </h3>
</div>
{% endfor %}
</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hashcut/templates/bpi_mashup_profile.html Fri Nov 30 14:21:52 2012 +0100
@@ -0,0 +1,51 @@
+{% extends "bpi_mashup_home.html" %}
+{% load static %}
+{% load i18n %}
+{% load analytics %}
+{% load thumbnail %}
+ {% block title %}Hashcut Profile - BPI{% 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">Tous les Hashcuts</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">Hashcuts de <a>{{username}}</a></h2>
+
+ <div class="hashcut-video-wrap profil">
+ {% 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 "302x202" 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 {{ m.creator }} | <span>02:24</span> </h3>
+ </div>
+ {% endfor %}
+ </div>
+ <!--div class="pagination">
+ <a href="#" class="active">1</a>
+ <a href="#">2</a>
+ <a href="#">3</a>
+ <a href="#">4</a>
+ <a href="#">5</a>
+ <a href="#">6</a>
+ <a href="#">Suivant</a>
+ </div-->
+</div><!-- content -->
+{% endblock %}
+
--- a/src/hashcut/templates/iri_mashup_hashcut.html Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/templates/iri_mashup_hashcut.html Fri Nov 30 14:21:52 2012 +0100
@@ -27,7 +27,7 @@
<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext" title="Partager sur Google+"></a>
<a href="#" target="_blank" class="Ldt-Social-Mail" title="Partager par mail"></a>
</div>
- <p class="title-video" href="#">Hashcut » {{proj.title}}</p>
+ <p class="title-video">Hashcut » {{proj.title}}</p>
</div>
<div class="profil-wrap">
<ul>
--- a/src/hashcut/templates/iri_mashup_home.html Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/templates/iri_mashup_home.html Fri Nov 30 14:21:52 2012 +0100
@@ -64,13 +64,13 @@
<div class="video-item">
{% 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>
+ <h3><strong>{{ m1.project.title }}</strong> par <a href="{% url mashup_profile branding=branding username=m1.creator %}">{{ m1.creator }}</a> | <span>02:24</span> </h3>
{% endif %}
</div>
<div class="video-item">
{% 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>
+ <h3><strong>{{ m2.project.title }}</strong> par <a href="{% url mashup_profile branding=branding username=m2.creator %}">{{ m2.creator }}</a> | <span>02:24</span> </h3>
{% endif %}
</div>
</div>
@@ -80,7 +80,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 %} {% 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>
+ <h3><strong>{% if m.project.title|length > 30 %}{{m.project.title|slice:":30"}}...{% else %}{{m.project.title}}{% endif %}</strong> par <a href="{% url mashup_profile branding=branding username=m.creator %}">{{ m.creator }}</a> | <span>02:24</span> </h3>
</div>
{% endfor %}
</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hashcut/templates/iri_mashup_profile.html Fri Nov 30 14:21:52 2012 +0100
@@ -0,0 +1,51 @@
+{% extends "iri_mashup_home.html" %}
+{% load static %}
+{% load i18n %}
+{% load analytics %}
+{% load thumbnail %}
+ {% block title %}Hashcut Profile - IRI{% 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">Tous les Hashcuts</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">Hashcuts de <a>{{username}}</a></h2>
+
+ <div class="hashcut-video-wrap profil">
+ {% 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 "302x202" 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 {{ m.creator }} | <span>02:24</span> </h3>
+ </div>
+ {% endfor %}
+ </div>
+ <!--div class="pagination">
+ <a href="#" class="active">1</a>
+ <a href="#">2</a>
+ <a href="#">3</a>
+ <a href="#">4</a>
+ <a href="#">5</a>
+ <a href="#">6</a>
+ <a href="#">Suivant</a>
+ </div-->
+</div><!-- content -->
+{% endblock %}
+
--- a/src/hashcut/templates/partial/bpi_mashup_popin_user.html Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/templates/partial/bpi_mashup_popin_user.html Fri Nov 30 14:21:52 2012 +0100
@@ -5,7 +5,7 @@
<div class="popin-content">
<h2>{{creator}}</h2>
<h3>{{email_creator}}</h3>
- <a href="#" class="nb-hashcut">{{nb_mashup_creator}} Hashcuts</a>
+ <a href="{% url mashup_profile branding=branding username=creator %}" 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_mashup_popin_user.html Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/templates/partial/iri_mashup_popin_user.html Fri Nov 30 14:21:52 2012 +0100
@@ -5,7 +5,7 @@
<div class="popin-content">
<h2>{{creator}}</h2>
<h3>{{email_creator}}</h3>
- <a href="#" class="nb-hashcut">{{nb_mashup_creator}} Hashcuts</a>
+ <a href="{% url mashup_profile branding=branding username=creator %}" class="nb-hashcut">{{nb_mashup_creator}} Hashcuts</a>
<p>
<a href="#" class="change-account button">Changer de compte</a>
</p>
--- a/src/hashcut/urls.py Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/urls.py Fri Nov 30 14:21:52 2012 +0100
@@ -1,11 +1,12 @@
from django.conf.urls.defaults import patterns, url
-from hashcut.views import MashupHome, MashupEdit, MashupHashcut, MashupContent
+from hashcut.views import MashupHome, MashupEdit, MashupHashcut, MashupContent, MashupProfile
urlpatterns = patterns('',
url(r'^(?P<branding>.*)/edit/$', MashupEdit.as_view(), name="mashup_edit"),
url(r'^(?P<branding>.*)/save/$', 'hashcut.views.save_mashup', name="mashup_save"),
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>.*)/$', MashupHome.as_view(), name="mashup_home"),
url(r'^$', MashupHome.as_view()),
)
--- a/src/hashcut/views.py Thu Nov 29 19:28:10 2012 +0100
+++ b/src/hashcut/views.py Fri Nov 30 14:21:52 2012 +0100
@@ -5,6 +5,7 @@
from ldt.ldt_utils.models import Project, Content
import logging
from hashcut.models import Mashup, Branding
+from django.contrib.auth.models import User
class MashupContextView(View):
@@ -108,7 +109,6 @@
if rtrn and 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]
- proj = None
try:
proj = Project.objects.get(ldt_id=proj_ldt_id)
except Project.DoesNotExist:
@@ -150,7 +150,10 @@
self.branding = branding
if not ldt_id:
return HttpResponseNotFound("A project id must be given.")
- proj = Project.objects.get(ldt_id=ldt_id)
+ try:
+ proj = Project.objects.get(ldt_id=ldt_id)
+ except Project.DoesNotExist:
+ raise ObjectDoesNotExist("MashupHashcut : project not found. project_ldt_id = " + ldt_id)
context = self.get_context_dict(request)
context.update({"ldt_id":ldt_id, "proj": proj})
return self.render_to_response(context)
@@ -184,14 +187,53 @@
self.branding = branding
if not ctt_id:
return HttpResponseNotFound("A content id must be given.")
- content = Content.objects.get(iri_id=ctt_id)
+ try:
+ content = Content.objects.get(iri_id=ctt_id)
+ except Content.DoesNotExist:
+ raise ObjectDoesNotExist("MashupContent : content not found. ctt_id = " + ctt_id)
context = self.get_context_dict(request)
context.update({"ctt_id":ctt_id, "content": content})
return self.render_to_response(context)
+
+
+class MashupProfile(TemplateResponseMixin, MashupContextView):
+ # iri = default brand name
+ branding = "iri"
+ template_suffix = "mashup_profile.html"
+ template_name = "iri_mashup_profile.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(MashupProfile, self).get_template_names()
+ except ImproperlyConfigured:
+ raise ImproperlyConfigured("Class MashupContent 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", username=None, **kwargs):
+ self.branding = branding
+ if not username or username=="":
+ return HttpResponseNotFound("A username must be given.")
+ brd = Branding.objects.get(name=self.branding)
+ try:
+ user = User.objects.get(username=username)
+ except:
+ return HttpResponseNotFound("User not found.")
+ mashups = Mashup.objects.filter(branding=brd, project__owner=user)
+
+ context = self.get_context_dict(request)
+ context.update({"username":username, "mashups":mashups})
+ return self.render_to_response(context)
\ No newline at end of file