is_active_today should be only be triggered when new revisions are made

This commit is contained in:
Sean McArthur 2011-09-29 17:30:14 -05:00
Родитель 71e6518168
Коммит 1111618063
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -1471,7 +1471,7 @@ class Package(BaseModel, SearchMixin):
# activity
year_of_activity = models.CharField(max_length=365, default='0'*365)
is_active_today = models.BooleanField(default=False, blank=True)
is_active_today = models.BooleanField(default=False)
class Meta:
" Set the ordering of objects "
@ -2239,8 +2239,10 @@ def index_package(instance, **kwargs):
post_save.connect(index_package, sender=Package)
def mark_active_today(instance, **kw):
instance.is_active_today = True
pre_save.connect(mark_active_today, sender=Package)
if instance.package:
instance.package.is_active_today = True
instance.package.save()
pre_save.connect(mark_active_today, sender=PackageRevision)
unindex_package = lambda instance, **kwargs: instance.remove_from_index()
post_delete.connect(unindex_package, sender=Package)