Author: leidel
Date: Sat Oct 4 12:18:54 2008
New Revision: 1013
Modified:
trunk/apps/core_apps/photos/models.py
trunk/apps/core_apps/photos/urls.py
trunk/apps/core_apps/photos/views.py
trunk/projects/complete_project/templates/photos/photo_right_panel.html
Log:
Updated photos app to use a real get_absolute_url for revers url lookup
Modified: trunk/apps/core_apps/photos/models.py
==============================================================================
--- trunk/apps/core_apps/photos/models.py (original)
+++ trunk/apps/core_apps/photos/models.py Sat Oct 4 12:18:54 2008
@@ -15,7 +15,9 @@
)
class PhotoSets(models.Model):
- """docstring for phototribes"""
+ """
+ A set of photos
+ """
name = models.CharField(_('name'), max_length=200)
description = models.TextField(_('description'))
publish_type = models.IntegerField(_('publish_type'),
choices=PUBLISH_CHOICES, default=1)
@@ -26,7 +28,9 @@
verbose_name_plural = _('photo sets')
class Photos(ImageModel):
- """docstring for MemberPhotos"""
+ """
+ A photo with its details
+ """
SAFETY_LEVEL = (
(1, _('Safe')),
(2, _('Not Safe')),
@@ -43,6 +47,10 @@
def __unicode__(self):
return self.title
+
+ def get_absolute_url(self):
+ return ("photo_details", [self.pk])
+ get_absolute_url = models.permalink(get_absolute_url)
class Pool(models.Model):
"""
Modified: trunk/apps/core_apps/photos/urls.py
==============================================================================
--- trunk/apps/core_apps/photos/urls.py (original)
+++ trunk/apps/core_apps/photos/urls.py Sat Oct 4 12:18:54 2008
@@ -1,14 +1,10 @@
from django.conf.urls.defaults import *
-from photos import views, models
-from photos.forms import *
-
-
urlpatterns = patterns('',
# all photos or latest photos
url(r'^$', 'photos.views.photos', name="photos"),
# a photos details
- url(r'^details/(?P<id>\d+)/$', 'photos.views.details', name="details"),
+ url(r'^details/(?P<id>\d+)/$', 'photos.views.details',
name="photo_details"),
# upload photos
url(r'^upload/$', 'photos.views.upload', name="photo_upload"),
# your photos
Modified: trunk/apps/core_apps/photos/views.py
==============================================================================
--- trunk/apps/core_apps/photos/views.py (original)
+++ trunk/apps/core_apps/photos/views.py Sat Oct 4 12:18:54 2008
@@ -26,7 +26,7 @@
photo.member = request.user
photo.save()
request.user.message_set.create(message=_("Successfully
uploaded photo '%s'") % photo.title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
return render_to_response(template_name, {
"photo_form": photo_form,
@@ -102,7 +102,7 @@
# TODO: this applies to pinax in general. dont use
ugettext_lazy here. its usage is fragile.
request.user.message_set.create(message=_("Did not add
photo '%s' to project because it already exists.") % title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
if request.method == "POST":
if request.POST["action"] == "addtotribe":
@@ -115,7 +115,7 @@
# TODO: this applies to pinax in general. dont use
ugettext_lazy here. its usage is fragile.
request.user.message_set.create(message=_("Did not add
photo '%s' to tribe because it already exists.") % title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
if request.POST["action"] == "removefromtribe":
tribeid = request.POST["tribe"]
@@ -127,7 +127,7 @@
# TODO: this applies to pinax in general. dont use
ugettext_lazy here. its usage is fragile.
request.user.message_set.create(message=_("Did not
remove photo '%s' from tribe.") % title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
if request.POST["action"] == "addtoproject":
projectid = request.POST["project"]
@@ -139,7 +139,7 @@
# TODO: this applies to pinax in general. dont use
ugettext_lazy here. its usage is fragile.
request.user.message_set.create(message=_("Did not add
photo '%s' to project because it already exists.") % title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
if request.POST["action"] == "removefromproject":
projectid = request.POST["project"]
@@ -151,7 +151,7 @@
# TODO: this applies to pinax in general. dont use
ugettext_lazy here. its usage is fragile.
request.user.message_set.create(message=_("Did not
remove photo '%s' from project.") % title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
return render_to_response(template_name, {
"host": host,
@@ -183,7 +183,7 @@
if request.method == "POST":
if photo.member != request.user:
request.user.message_set.create(message="You can't edit photos
that aren't yours")
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
if request.POST["action"] == "update":
photo_form = form_class(request.user, request.POST,
instance=photo)
if photo_form.is_valid():
@@ -191,7 +191,7 @@
photoobj.save()
request.user.message_set.create(message=_("Successfully
updated photo '%s'") % photo.title)
- return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ return HttpResponseRedirect(reverse('photo_details',
args=(photo.id,)))
else:
photo_form = form_class(instance=photo)
Modified:
trunk/projects/complete_project/templates/photos/photo_right_panel.html
==============================================================================
--- trunk/projects/complete_project/templates/photos/photo_right_panel.html
(original)
+++ trunk/projects/complete_project/templates/photos/photo_right_panel.html
Sat Oct 4 12:18:54 2008
@@ -54,7 +54,7 @@
{% if tribes %}
<h2>Add photo to tribe</h2>
{% for tribe in tribes %}
- <form action="{% url details photo.id %}" method="POST">
+ <form action="{{ photo.get_absolute_url }}" method="POST">
<input type="hidden" name="tribe" value="{{ tribe.id }}"/>
{% if tribe.has_photo %}
<input type="hidden" name="action"
value="removefromtribe"/>
@@ -72,7 +72,7 @@
{% if projects %}
<h2>Add photo to project</h2>
{% for project in projects %}
- <form action="{% url details photo.id %}" method="POST">
+ <form action="{{ photo.get_absolute_url }}" method="POST">
<input type="hidden" name="project" value="{{ project.id
}}"/>
{% if project.has_photo %}
<input type="hidden" name="action"
value="removefromproject"/>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---