Mercurial > public > sg101
comparison gpp/potd/models.py @ 532:ff67946fd4b0
For #242, move the updating of the POTD sequence into a new signals module.
When photos are deleted from the admin changelist in bulk, the individual
delete() functions on the photo objects is not called. However, the post_delete
signal is called for each object.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 25 Dec 2011 04:15:32 +0000 |
parents | ae89ba801e8b |
children | 4021ea1045f7 |
comparison
equal
deleted
inserted
replaced
531:1f92a53db575 | 532:ff67946fd4b0 |
---|---|
48 def save(self, *args, **kwargs): | 48 def save(self, *args, **kwargs): |
49 if not self.pk: | 49 if not self.pk: |
50 self.generate_thumb() | 50 self.generate_thumb() |
51 | 51 |
52 super(Photo, self).save(*args, **kwargs) | 52 super(Photo, self).save(*args, **kwargs) |
53 Sequence.objects.insert_photo(self.pk) | |
54 | |
55 def delete(self): | |
56 Sequence.objects.remove_photo(self.pk) | |
57 super(Photo, self).delete() | |
58 | 53 |
59 def can_comment_on(self): | 54 def can_comment_on(self): |
60 return Current.objects.get_current_id() == self.id | 55 return Current.objects.get_current_id() == self.id |
61 | 56 |
62 def generate_thumb(self): | 57 def generate_thumb(self): |
176 def __unicode__(self): | 171 def __unicode__(self): |
177 return self.seq | 172 return self.seq |
178 | 173 |
179 class Meta: | 174 class Meta: |
180 verbose_name_plural = 'Sequence' | 175 verbose_name_plural = 'Sequence' |
181 |