diff -r e36c35fb4468 -r fa742e491ce1 src/hashcut/templates/partial/iri_mashup_popin_user.html
--- 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 @@
{{creator}}
{{email_creator}}
-
{{nb_mashup_creator}} Hashcuts
+
{{nb_mashup_creator}} Hashcuts
Changer de compte
diff -r e36c35fb4468 -r fa742e491ce1 src/hashcut/urls.py
--- 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
.*)/edit/$', MashupEdit.as_view(), name="mashup_edit"),
url(r'^(?P.*)/save/$', 'hashcut.views.save_mashup', name="mashup_save"),
url(r'^(?P.*)/hashcut/(?P.*)/$', MashupHashcut.as_view(), name="mashup_hashcut"),
url(r'^(?P.*)/media/(?P.*)/$', MashupContent.as_view(), name="mashup_content"),
+ url(r'^(?P.*)/profile/(?P.*)/$', MashupProfile.as_view(), name="mashup_profile"),
url(r'^(?P.*)/$', MashupHome.as_view(), name="mashup_home"),
url(r'^$', MashupHome.as_view()),
)
diff -r e36c35fb4468 -r fa742e491ce1 src/hashcut/views.py
--- 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