From 757397330c12ad66c4755d2bc9d5a07dc84f9034 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Mon, 25 Jan 2016 19:40:35 +0000 Subject: [PATCH] Addresses issues uncovered by the test-crawler. Adds missing DocAlias records for several document types. Creates DocAlias objects when createing Document objects for those document types. Identifies places in code to touch when we are ready to expose the bluesheets and recording document types at /doc/. (The data rows and the content store need work before doing so). - Legacy-Id: 10731 --- .../migrations/0011_add_missing_docaliases.py | 23 +++++++++++++++++++ ietf/doc/models.py | 2 +- ietf/doc/tests.py | 3 +++ ietf/doc/views_doc.py | 2 ++ ietf/liaisons/forms.py | 4 +++- ietf/secr/proceedings/proc_utils.py | 2 ++ ietf/templates/meeting/session_details.html | 14 ++++++----- ietf/utils/test_data.py | 3 +++ 8 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 ietf/doc/migrations/0011_add_missing_docaliases.py diff --git a/ietf/doc/migrations/0011_add_missing_docaliases.py b/ietf/doc/migrations/0011_add_missing_docaliases.py new file mode 100644 index 000000000..11ccc1662 --- /dev/null +++ b/ietf/doc/migrations/0011_add_missing_docaliases.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations +from django.db.models import F + +def reverse(apps, schema_editor): + pass + +def forward(apps, schema_editor): + Document = apps.get_model('doc','Document') + for doc in Document.objects.filter(type__in=['recording','liaison','liai-att']).exclude(docalias__name=F('name')): + doc.docalias_set.create(name=doc.name) + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0010_auto_20150930_0251'), + ] + + operations = [ + migrations.RunPython(forward,reverse) + ] diff --git a/ietf/doc/models.py b/ietf/doc/models.py index ddc20b297..5f62c4c05 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -234,7 +234,7 @@ class DocumentInfo(models.Model): def meeting_related(self): answer = False - if self.type_id in ("agenda","minutes","bluesheets","slides"): + if self.type_id in ("agenda","minutes","bluesheets","slides","recording"): answer = (self.name.split("-")[1] == "interim" or (self if isinstance(self, Document) else self.doc).session_set.exists()) if self.type_id in ("slides",): diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index 12bd84888..c44278414 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -558,6 +558,9 @@ Man Expires September 22, 2015 [Page 3] "agenda-42-mars", "minutes-42-mars", "slides-42-mars-1", + # TODO: add + #"bluesheets-42-mars-1", + #"recording-42-mars-1-00", ]: doc = Document.objects.get(name=docname) # give it some history diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 5b8eb4092..725e3dfc5 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -522,6 +522,8 @@ def document_main(request, name, rev=None): ), context_instance=RequestContext(request)) + # TODO : Add "recording", and "bluesheets" here when those documents are appropriately + # created and content is made available on disk if doc.type_id in ("slides", "agenda", "minutes"): can_manage_material = can_manage_materials(request.user, doc.group) presentations = None diff --git a/ietf/liaisons/forms.py b/ietf/liaisons/forms.py index 9c09414ff..646864382 100644 --- a/ietf/liaisons/forms.py +++ b/ietf/liaisons/forms.py @@ -346,7 +346,7 @@ class LiaisonModelForm(BetterModelForm): extension = '' written += 1 name = self.instance.name() + ("-attachment-%s" % written) - attach, _ = Document.objects.get_or_create( + attach, created = Document.objects.get_or_create( name = name, defaults=dict( title = attachment_title, @@ -354,6 +354,8 @@ class LiaisonModelForm(BetterModelForm): external_url = name + extension, # strictly speaking not necessary, but just for the time being ... ) ) + if created: + attach.docalias_set.create(name=attach.name) LiaisonStatementAttachment.objects.create(statement=self.instance,document=attach) attach_file = open(os.path.join(settings.LIAISON_ATTACH_PATH, attach.name + extension), 'w') attach_file.write(attached_file.read()) diff --git a/ietf/secr/proceedings/proc_utils.py b/ietf/secr/proceedings/proc_utils.py index 70c9296ae..56d20b449 100644 --- a/ietf/secr/proceedings/proc_utils.py +++ b/ietf/secr/proceedings/proc_utils.py @@ -76,6 +76,8 @@ def create_recording(session,meeting,group,url): rev='00', type_id='recording') doc.set_state(State.objects.get(type='recording', slug='active')) + + doc.docalias_set.create(name=name) # create DocEvent NewRevisionDocEvent.objects.create(type='new_revision', diff --git a/ietf/templates/meeting/session_details.html b/ietf/templates/meeting/session_details.html index 08925df22..b18065991 100644 --- a/ietf/templates/meeting/session_details.html +++ b/ietf/templates/meeting/session_details.html @@ -16,12 +16,14 @@ {% for pres in session.filtered_sessionpresentation_set %} - - - + {% if pres.document.type_id != 'bluesheets' and pres.document.type_id != 'recording' %} + + + + {% endif %} {% endfor %}
- {{pres.document.title}} ({{ pres.document.name }}-{{ pres.rev }}) - -
+ {{pres.document.title}} ({{ pres.document.name }}-{{ pres.rev }}) + +
{% endif %} diff --git a/ietf/utils/test_data.py b/ietf/utils/test_data.py index babb54784..7d04ff6f1 100644 --- a/ietf/utils/test_data.py +++ b/ietf/utils/test_data.py @@ -351,5 +351,8 @@ def make_test_data(): other_doc_factory('agenda','agenda-42-mars') other_doc_factory('minutes','minutes-42-mars') other_doc_factory('slides','slides-42-mars-1') + # TODO: add + #other_doc_factory('bluesheets','bluesheets-42-mars-1') + #other_doc_factory('recording','recording-42-mars-1-00') return draft