Be more careful in handling Document.stream now that it can be null
- Legacy-Id: 3865
This commit is contained in:
parent
df1a9156f6
commit
65e5298630
|
@ -8,10 +8,8 @@ def get_state_types(doc):
|
|||
|
||||
res.append(doc.type_id)
|
||||
|
||||
#if doc.type_id in ("agenda", "minutes", "slides", "liai-att"):
|
||||
# res.append(doc.type_id)
|
||||
if doc.type_id == "draft":
|
||||
if doc.stream_id != "legacy":
|
||||
if doc.stream_id and doc.stream_id != "legacy":
|
||||
res.append("draft-stream-%s" % doc.stream_id)
|
||||
|
||||
res.append("draft-iesg")
|
||||
|
|
|
@ -257,7 +257,6 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
time=datetime.datetime.now(),
|
||||
type_id="draft",
|
||||
title="Testing adding a draft",
|
||||
stream_id="ietf",
|
||||
group=Group.objects.get(acronym="mars"),
|
||||
abstract="Test test test.",
|
||||
rev="01",
|
||||
|
@ -297,7 +296,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
|
||||
r = self.client.post(url,
|
||||
dict(intended_std_level=str(draft.intended_std_level_id),
|
||||
stream=draft.stream_id,
|
||||
stream="ietf",
|
||||
via_rfc_editor="1",
|
||||
ad=ad.pk,
|
||||
create_in_state=State.objects.get(type="draft-iesg", slug="watching").pk,
|
||||
|
|
|
@ -83,8 +83,12 @@ def is_authorized_in_draft_streamREDESIGN(user, draft):
|
|||
if is_secretariat(user):
|
||||
return True
|
||||
|
||||
# must be a chair or delegate of the stream group (or draft group)
|
||||
from ietf.doc.models import Document
|
||||
|
||||
if not super(Document, draft).stream:
|
||||
return False
|
||||
|
||||
# must be a chair or delegate of the stream group (or draft group)
|
||||
group_req = Q(group__acronym=super(Document, draft).stream.slug)
|
||||
if draft.group and super(Document, draft).stream.slug == "ietf":
|
||||
group_req |= Q(group=draft.group)
|
||||
|
@ -118,7 +122,7 @@ def can_edit_stream(user, draft):
|
|||
return is_secretariat(user)
|
||||
|
||||
def can_adopt(user, draft):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES and (not draft.stream or draft.stream_id == "ietf") and draft.group.type_id == "individ":
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES and (not draft.stream_id or draft.stream_id == "ietf") and draft.group.type_id == "individ":
|
||||
person = get_person_for_user(user)
|
||||
if not person:
|
||||
return False
|
||||
|
|
|
@ -199,6 +199,9 @@ class DraftTagsStateForm(StreamDraftForm):
|
|||
|
||||
def get_next_states(self):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
if not self.draft.stream_id:
|
||||
return []
|
||||
|
||||
from ietf.doc.models import State
|
||||
state_type = "draft-stream-%s" % self.draft.stream_id
|
||||
s = self.draft.get_state(state_type)
|
||||
|
@ -226,6 +229,9 @@ class DraftTagsStateForm(StreamDraftForm):
|
|||
|
||||
def get_states(self):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
if not self.draft.stream_id:
|
||||
return []
|
||||
|
||||
from ietf.doc.models import State
|
||||
states = State.objects.filter(type="draft-stream-%s" % self.draft.stream_id)
|
||||
if self.draft.stream_id == "ietf" and self.draft.group:
|
||||
|
|
|
@ -141,6 +141,8 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
|
||||
def test_set_stream(self):
|
||||
draft = make_test_data()
|
||||
draft.stream = None
|
||||
draft.save()
|
||||
|
||||
url = urlreverse('edit_stream', kwargs=dict(name=draft.name))
|
||||
login_testing_unauthorized(self, "secretary", url)
|
||||
|
|
|
@ -390,7 +390,9 @@ def update_stream(request, doc, comment, person, to_stream, extra_notify=[]):
|
|||
doc.save()
|
||||
|
||||
e = DocEvent(type="changed_stream", time=doc.time, by=person, doc=doc)
|
||||
e.desc = u"Stream changed to <b>%s</b> from %s" % (to_stream.name, from_stream.name)
|
||||
e.desc = u"Stream changed to <b>%s</b>" % to_stream.name
|
||||
if from_stream:
|
||||
e.desc += u"from %s" % from_stream.name
|
||||
e.save()
|
||||
|
||||
receivers = get_notification_receivers(doc, extra_notify)
|
||||
|
|
Loading…
Reference in a new issue