Author: gregoryjnewman
Date: Fri Sep 12 04:03:04 2008
New Revision: 876
Modified:
trunk/pinax/local_apps/photos/views.py
trunk/pinax/templates/photos/photo_right_panel.html
trunk/pinax/templates/projects/project.html
Log:
adding photo pool tools for photo to project
Modified: trunk/pinax/local_apps/photos/views.py
==============================================================================
--- trunk/pinax/local_apps/photos/views.py (original)
+++ trunk/pinax/local_apps/photos/views.py Fri Sep 12 04:03:04 2008
@@ -52,8 +52,9 @@
tribes = Tribe.objects.filter(members=request.user)
projects = Project.objects.filter(members=request.user)
photo = get_object_or_404(Photos, id=id)
- t = []
+ # Build a list of tribes and the photos from the pool
+ t = []
if tribes:
for tribe in tribes:
phototribe = Tribe.objects.get(pk=tribe.id)
@@ -62,6 +63,17 @@
else:
t.append({"name":tribe.name, "slug":tribe.slug, "id":tribe.id,
"has_photo":False})
+ # Build a list of projects and the photos from the pool
+ p = []
+ if projects:
+ for project in projects:
+ photoproject = Project.objects.get(pk=tribe.id)
+ if photoproject.photos.filter(photo=photo).count():
+
p.append({"name":project.name, "slug":project.slug, "id":project.id,
"has_photo":True})
+ else:
+
p.append({"name":project.name, "slug":project.slug, "id":project.id,
"has_photo":False})
+
+
# @@@ is there a better way?
# TODO: redo this exif routine
photo_path = os.path.join(settings.MEDIA_ROOT, "photologue/photos",
photo.image_filename())
@@ -112,6 +124,31 @@
return HttpResponseRedirect(reverse('details',
args=(photo.id,)))
+ if request.POST["action"] == "addtoproject":
+ projectid = request.POST["project"]
+ myproject = Project.objects.get(pk=projectid)
+ if not myproject.photos.filter(photo=photo).count():
+ myproject.photos.create(photo=photo)
+
request.user.message_set.create(message=_("Successfully add photo '%s' to
project") % title)
+ else:
+ # 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,)))
+
+ if request.POST["action"] == "removefromproject":
+ projectid = request.POST["project"]
+ myproject = Project.objects.get(pk=projectid)
+ if myproject.photos.filter(photo=photo).count():
+ myproject.photos.filter(photo=photo).delete()
+
request.user.message_set.create(message=_("Successfully removed photo '%s'
from project") % title)
+ else:
+ # 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 render_to_response("photos/details.html", {
@@ -120,7 +157,7 @@
"exif": exif,
"is_me": is_me,
"other_user": other_user,
- "projects": projects,
+ "projects": p,
"tribes": t
}, context_instance=RequestContext(request))
Modified: trunk/pinax/templates/photos/photo_right_panel.html
==============================================================================
--- trunk/pinax/templates/photos/photo_right_panel.html (original)
+++ trunk/pinax/templates/photos/photo_right_panel.html Fri Sep 12 04:03:04
2008
@@ -48,18 +48,6 @@
</div>
{% if is_me %}
<div class="photo-right-profile ">
- {% if projects %}
- <h2>Add photo to project</h2>
- {% for project in projects %}
- <form action="{% url details photo.id %}" method="POST">
- <input type="hidden" name="action" value="add_to_project"/>
- <input type="hidden" name="project" value="{{ project.id
}}"/>
- <input type="submit" value="add"/>
- <a href="{% url projects.views.project project.slug %}">{{
project.name }}</a>
- </form>
- {% endfor %}
- {% endif %}
-
{% if tribes %}
<h2>Add photo to tribe</h2>
{% for tribe in tribes %}
@@ -77,6 +65,25 @@
</form>
{% endfor %}
{% endif %}
+
+ {% if projects %}
+ <h2>Add photo to project</h2>
+ {% for project in projects %}
+ <form action="{% url details photo.id %}" method="POST">
+ <input type="hidden" name="project" value="{{ project.id
}}"/>
+ {% if project.has_photo %}
+ <input type="hidden" name="action"
value="removefromproject"/>
+ <input type="submit" value="remove"/>
+ {{ project.name }}
+ {% else %}
+ <input type="hidden" name="action" value="addtoproject"/>
+ <input type="submit" value="add"/>
+ {{ project.name }}
+ {% endif %}
+ </form>
+ {% endfor %}
+ {% endif %}
+
</div>
{% endif %}
Modified: trunk/pinax/templates/projects/project.html
==============================================================================
--- trunk/pinax/templates/projects/project.html (original)
+++ trunk/pinax/templates/projects/project.html Fri Sep 12 04:03:04 2008
@@ -142,8 +142,8 @@
<div class="thumb-row clearfix">
{% for photo in photos %}
<div class="gallery-photo-thumb">
- <a href="/photos/details/{{ photo.id }}/"><img
src="{{ photo.get_thumbnail_url }}" alt="{{ photo.title }}"/></a><br />
- <img src="/site_media/comment.png" border="0"
class="noborder" align="absmiddle" /><a href="/photos/details/{{ photo.id
}}/">{% get_comment_count for photo as commentcount %} {{ commentcount }}
Comments</a>
+ <a href="/photos/details/{{ photo.photo.id
}}/"><img src="{{ photo.photo.get_thumbnail_url }}" alt="{{
photo.photo.title }}"/></a><br />
+ <img src="/site_media/comment.png" border="0"
class="noborder" align="absmiddle" /><a href="/photos/details/{{
photo.photo.id }}/">{% get_comment_count for photo.photo as commentcount %}
{{ commentcount }} Comments</a>
</div>
{% endfor %}
</div>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---