Commits

Anonymous committed 1d7f838

[project @ 369]
Some cleanups to use simpler APIs

Comments (0)

Files changed (2)

cciw/cciwmain/models/forums.py

     description = models.CharField("Description", blank=True, maxlength=100)
     gallery = models.ForeignKey(Gallery,
         verbose_name="gallery",
-        related_name="photo")
+        related_name="photos")
     checked_by = models.ForeignKey(User,
         null=True, blank=True, related_name="photos_checked")
     approved = models.BooleanField("Approved", null=True, blank=True)

cciw/cciwmain/views/forums.py

         prev_and_next += '« '
         
     try:
-        next_photo = Photo.all_objects.filter(id__gt=photo.id, \
+        next_photo = Photo.objects.filter(id__gt=photo.id, \
             gallery__id__exact = photo.gallery_id).order_by('id')[0]
         prev_and_next += '<a href="%s" title="Next photo">&raquo;</a> ' % next_photo.get_absolute_url()
     except IndexError:
     forum = _get_forum_or_404(request.path, '')
     
     ### TOPICS ###
-    topics = Topic.objects.filter(forum__id__exact=forum.id)
+    topics = forum.topics.get_query_set()
     
     ### FEED ###
     resp = feeds.handle_feed_request(request, feeds.forum_topic_feed(forum), query_set=topics)
     except Topic.DoesNotExist:
         raise Http404
 
-    posts = Post.objects.filter(topic__id__exact=topic.id)
+    posts = topic.posts.get_query_set()
 
     ### Feed: ###
     # Requires 'topic' and 'posts'
     "Displays an a gallery of photos"
     
     ### PHOTOS ###
-    photos = Photo.objects.filter(gallery__id__exact=gallery.id)
+    photos = gallery.photos.get_query_set()
     
     ### FEED ###
     resp = feeds.handle_feed_request(request, 
     "Displays a photo"
     
     ## POSTS ###
-    posts = Post.objects.filter(photo__id__exact=photo.id)
+    posts = photo.posts.get_query_set()
 
     ### Feed: ###
     resp = feeds.handle_feed_request(request, feeds.photo_post_feed(photo), query_set=posts)