google-code-export / django-syncr

Automatically exported from code.google.com/p/django-syncr
0 stars 0 forks source link

Surfacing photoset with an individual photo #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, when you try and render an individual photo with a URL like this:

/photos/2006/06/17/bar/

There is no info on what photoset it belongs to. Thus, when you render the
photo, you have no way to grab 'previous' or 'next' in relation to a photoset.

I'm off to write a quick function to identify what photoset a photo belongs
to, unless there's something like this already built in, that I can't find?

Thanks!

Original issue reported on code.google.com by intellin...@gmail.com on 26 Mar 2009 at 7:22

GoogleCodeExporter commented 9 years ago
This is cool. You can use the automatic reverse relation on the Photo model 
(photo_obj.photoset_set.all()) to get 
PhotoSets it belongs to, but a next and previous is tricky. We don't store the 
photos in anything more than a 
ManyToManyField inside PhotoSet models right now. If Flickr exports ordering 
properties for photos in a 
photoset, it could be done.

If you don't care about the order matching Flickr precisely, a simple loop over 
the photoset_set field objects 
would work.

Original comment by jesse.l...@gmail.com on 29 Mar 2009 at 3:45

GoogleCodeExporter commented 9 years ago
Ah, yeah, makes sense. What I ended up implementing was rather naive, but works:

photoset = PhotoSet.objects.get(photos=photo)

That's in my view before I render output. Since I know that there won't be a 
photo
that belongs to two photosets, it's fairly reliable.

The next / prev also works well as long as I sort the photosets by post date. 
See my
implementation here:

http://nywcc.dumbwaiterdesign.com/photos/

Similar YouTube implementation here:

http://nywcc.dumbwaiterdesign.com/videos/

Original comment by intellin...@gmail.com on 29 Mar 2009 at 4:05

GoogleCodeExporter commented 9 years ago

Original comment by jesse.l...@gmail.com on 15 Apr 2009 at 12:48