Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/yummy/models.py b/yummy/models.py
- index 785b370..a673746 100644
- --- a/yummy/models.py
- +++ b/yummy/models.py
- @@ -283,18 +283,27 @@ class Recipe(models.Model):
- return groups
- -class RecipePhoto(models.Model):
- +class PhotoMixin(models.Model):
- - objects = managers.RecipePhotoManager()
- - recipe = models.ForeignKey(Recipe, verbose_name=_('Recipe'))
- +
- + class Meta:
- + abstract = True
- +
- photo = models.ForeignKey(Photo, verbose_name=_('Photo'))
- is_visible = models.BooleanField(_('Visible'), default=True)
- order = models.PositiveSmallIntegerField(_('Order'), default=1, db_index=True)
- + objects = managers.PhotoManager()
- +
- def __unicode__(self):
- return u"%d. %s" % (self.order, self.photo)
- +
- +class RecipePhoto(PhotoMixin):
- +
- + recipe = models.ForeignKey(Recipe, verbose_name=_('Recipe'))
- +
- class Meta:
- unique_together = (
- ('recipe', 'photo'),
- @@ -319,7 +328,8 @@ class RecipePhoto(models.Model):
- - if this value collides, bump following values
- (also make there a gap to fit more photos w/o reordering in there)
- """
- - photos = list(RecipePhoto.objects.filter(recipe=self.recipe).select_related('recipe', 'photo').order_by('order'))
- + photos = list(RecipePhoto.objects.filter(recipe=self.recipe).\
- + select_related('recipe', 'photo').order_by('order'))
- if not photos:
- return
Add Comment
Please, Sign In to add comment