diff --git a/ietf/community/display.py b/ietf/community/display.py index a6f293a41..142c81d3d 100644 --- a/ietf/community/display.py +++ b/ietf/community/display.py @@ -182,14 +182,14 @@ class PublicationSort(SortMethod): description = 'Date of publication of current version of the document' def get_sort_field(self): - return '-documentchangedates__new_version_date' + return '-time' # FIXME: latest revision date class ChangeSort(SortMethod): codename = 'recent_change' description = 'Date of most recent change of status of any type' def get_sort_field(self): - return '-documentchangedates__normal_change_date' + return '-time' # FIXME: latest doc event class SignificantSort(SortMethod): @@ -197,7 +197,7 @@ class SignificantSort(SortMethod): description = 'Date of most recent significant change of status' def get_sort_field(self): - return '-documentchangedates__significant_change_date' + return '-time' # FIXME: latest significant state change TYPES_OF_SORT = [(i.codename, i.description) for i in SortMethod.__subclasses__()] diff --git a/ietf/community/management/commands/update_doc_change_dates.py b/ietf/community/management/commands/update_doc_change_dates.py deleted file mode 100644 index 5f946cf04..000000000 --- a/ietf/community/management/commands/update_doc_change_dates.py +++ /dev/null @@ -1,38 +0,0 @@ -import sys - -from django.core.management.base import BaseCommand - -from ietf.community.constants import SIGNIFICANT_STATES -from ietf.community.models import DocumentChangeDates -from ietf.doc.models import Document - - -class Command(BaseCommand): - help = (u"Update drafts in community lists by reviewing their rules") - - def handle(self, *args, **options): - documents = Document.objects.filter(type='draft') - index = 1 - total = documents.count() - - for doc in documents.iterator(): - (changes, created) = DocumentChangeDates.objects.get_or_create(document=doc) - new_version = doc.latest_event(type='new_revision') - normal_change = doc.latest_event() - significant_change = None - for event in doc.docevent_set.filter(type='changed_document'): - for state in SIGNIFICANT_STATES: - if ('%s' % state) in event.desc: - significant_change = event - break - - changes.new_version_date = new_version and new_version.time.date() - changes.normal_change_date = normal_change and normal_change.time.date() - changes.significant_change_date = significant_change and significant_change.time.date() - - changes.save() - - sys.stdout.write('Document %s/%s\r' % (index, total)) - sys.stdout.flush() - index += 1 - print diff --git a/ietf/community/models.py b/ietf/community/models.py index 394d084c6..aeed6e9d4 100644 --- a/ietf/community/models.py +++ b/ietf/community/models.py @@ -203,29 +203,15 @@ def notify_events(sender, instance, **kwargs): return if instance.doc.type.slug != 'draft' or instance.type == 'added_comment': return - (changes, created) = DocumentChangeDates.objects.get_or_create(document=instance.doc) - changes.normal_change_date = instance.time significant = False if instance.type == 'changed_document' and 'tate changed' in instance.desc: for i in SIGNIFICANT_STATES: if ('%s' % i) in instance.desc: significant = True - changes.significant_change_date = instance.time break - elif instance.type == 'new_revision': - changes.new_version_date = instance.time - changes.save() notification = ListNotification.objects.create( event=instance, significant=significant, ) notification.notify_by_email() signals.post_save.connect(notify_events) - - -class DocumentChangeDates(models.Model): - - document = models.ForeignKey(Document) - new_version_date = models.DateTimeField(blank=True, null=True) - normal_change_date = models.DateTimeField(blank=True, null=True) - significant_change_date = models.DateTimeField(blank=True, null=True) diff --git a/ietf/community/resources.py b/ietf/community/resources.py index 3316fb8a7..8446aff67 100644 --- a/ietf/community/resources.py +++ b/ietf/community/resources.py @@ -88,20 +88,3 @@ class EmailSubscriptionResource(ModelResource): "community_list": ALL_WITH_RELATIONS, } api.community.register(EmailSubscriptionResource()) - -from ietf.doc.resources import DocumentResource -class DocumentChangeDatesResource(ModelResource): - document = ToOneField(DocumentResource, 'document') - class Meta: - queryset = DocumentChangeDates.objects.all() - serializer = api.Serializer() - #resource_name = 'documentchangedates' - filtering = { - "id": ALL, - "new_version_date": ALL, - "normal_change_date": ALL, - "significant_change_date": ALL, - "document": ALL_WITH_RELATIONS, - } -api.community.register(DocumentChangeDatesResource()) -