From 8d6bcc8ff5779b4deba358d25fe844d52417f46f Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Tue, 24 Jan 2012 13:11:03 +0000 Subject: [PATCH] Fix adoption test to unset the stream, fix bugs with non-stream drafts - Legacy-Id: 3852 --- ietf/ietfworkflows/accounts.py | 2 +- ietf/ietfworkflows/forms.py | 4 +++- ietf/ietfworkflows/streams.py | 3 ++- ietf/ietfworkflows/tests.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ietf/ietfworkflows/accounts.py b/ietf/ietfworkflows/accounts.py index 669da3dcb..7c26fb916 100644 --- a/ietf/ietfworkflows/accounts.py +++ b/ietf/ietfworkflows/accounts.py @@ -118,7 +118,7 @@ def can_edit_stream(user, draft): return is_secretariat(user) def can_adopt(user, draft): - if settings.USE_DB_REDESIGN_PROXY_CLASSES and draft.stream_id == "ietf" and draft.group.type_id == "individ": + if settings.USE_DB_REDESIGN_PROXY_CLASSES and (not draft.stream or draft.stream_id == "ietf") and draft.group.type_id == "individ": person = get_person_for_user(user) if not person: return False diff --git a/ietf/ietfworkflows/forms.py b/ietf/ietfworkflows/forms.py index b63efc57f..952e8c248 100644 --- a/ietf/ietfworkflows/forms.py +++ b/ietf/ietfworkflows/forms.py @@ -97,7 +97,9 @@ class NoWorkflowStateForm(StreamDraftForm): e.time = doc.time e.by = self.user.get_profile() e.doc = doc - e.desc = u"Stream changed to %s from %s" % (new_stream.name, doc.stream.name) + e.desc = u"Changed to %s" % new_stream.name + if doc.stream: + e.desc += u" from %s" % doc.stream.name e.save() doc.stream = new_stream diff --git a/ietf/ietfworkflows/streams.py b/ietf/ietfworkflows/streams.py index 084243d73..9540a2825 100644 --- a/ietf/ietfworkflows/streams.py +++ b/ietf/ietfworkflows/streams.py @@ -27,7 +27,8 @@ def get_streamed_draft(draft): def get_stream_from_draft(draft): if settings.USE_DB_REDESIGN_PROXY_CLASSES: s = super(InternetDraft, draft).stream - s.with_groups = s.slug in ["ietf", "irtf"] + if s: + s.with_groups = s.slug in ["ietf", "irtf"] return s streamedid = get_streamed_draft(draft) diff --git a/ietf/ietfworkflows/tests.py b/ietf/ietfworkflows/tests.py index 1e03ac1b1..cca1b41f9 100644 --- a/ietf/ietfworkflows/tests.py +++ b/ietf/ietfworkflows/tests.py @@ -23,10 +23,10 @@ class EditStreamInfoTestCase(django.test.TestCase): def test_adopt_document(self): draft = make_test_data() - draft.stream_id = "ise" + draft.stream = None draft.group = Group.objects.get(type="individ") - draft.unset_state("draft-stream-ietf") draft.save() + draft.unset_state("draft-stream-ietf") url = urlreverse('edit_adopt', kwargs=dict(name=draft.name)) login_testing_unauthorized(self, "marschairman", url)