Skip to content

Commit 17eb95c

Browse files
committed
Tweaked code to correct access to document metadata and actions, adding RGs to the groups and group secretaries to the roles which are given access.
- Legacy-Id: 5939
2 parents 582be93 + e68e51c commit 17eb95c

5 files changed

Lines changed: 42 additions & 30 deletions

File tree

ietf/group/proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ class IETFWG(Group):
100100
group_acronym__acronym__in="acronym__in",
101101
group_acronym__acronym__contains="acronym__contains",
102102
email_archive__startswith="list_archive__startswith",
103-
group_type=lambda v: ("type", { 1: "wg" }[int(v)]),
103+
group_type=lambda v: ("type__in", { 1: ("wg", "rg") }[int(v)]),
104104
status=lambda v: ("state__in", { 1: ("active", "bof") }[int(v)]),
105105
areagroup__area__status=lambda v: ("parent__state", { 1: "active" }[v]),
106106
start_date__isnull=lambda v: None if v else ("groupevent__changestategroupevent__state__slug", "active"),
107107
),
108-
always_filter=dict(type__in=("wg", "individ", "area")))
108+
always_filter=dict(type__in=("wg", "rg", "individ", "area")))
109109

110110
def from_object(self, base):
111111
for f in base._meta.fields:

ietf/ietfworkflows/accounts.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ def is_wgchair(person):
2525
def is_wgchairREDESIGN(person):
2626
return bool(Role.objects.filter(name="chair", group__type="wg", group__state="active", person=person))
2727

28+
def is_rgchairREDESIGN(person):
29+
return bool(Role.objects.filter(name="chair", group__type="rg", group__state="active", person=person))
2830

2931
def is_wgdelegate(person):
3032
return bool(person.wgdelegate_set.all())
3133

3234
def is_wgdelegateREDESIGN(person):
3335
return bool(Role.objects.filter(name="delegate", group__type="wg", group__state="active", person=person))
3436

37+
def is_rgdelegateREDESIGN(person):
38+
return bool(Role.objects.filter(name="delegate", group__type="rg", group__state="active", person=person))
39+
3540
def is_delegate_of_stream(user, stream):
3641
if is_secretariat(user):
3742
return True
@@ -57,7 +62,6 @@ def is_chair_of_streamREDESIGN(user, stream):
5762
return False
5863
return user.is_authenticated() and bool(Role.objects.filter(group__acronym=stream.slug, name="chair", person__user=user))
5964

60-
6165
def is_authorized_in_draft_stream(user, draft):
6266
if is_secretariat(user):
6367
return True
@@ -92,16 +96,18 @@ def is_authorized_in_draft_streamREDESIGN(user, draft):
9296

9397
# must be a chair or delegate of the stream group (or draft group)
9498
group_req = Q(group__acronym=super(Document, draft).stream.slug)
95-
if draft.group and super(Document, draft).stream.slug == "ietf":
99+
if draft.group and super(Document, draft).stream.slug in ["ietf", "irtf"]:
96100
group_req |= Q(group=draft.group)
97101

98-
return user.is_authenticated() and bool(Role.objects.filter(name__in=("chair", "delegate"), person__user=user).filter(group_req))
102+
return user.is_authenticated() and bool(Role.objects.filter(name__in=("chair", "secr", "delegate"), person__user=user).filter(group_req))
99103

100104

101105
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
102106
from ietf.liaisons.accounts import is_secretariat, get_person_for_user
103107
is_wgdelegate = is_wgdelegateREDESIGN
104108
is_wgchair = is_wgchairREDESIGN
109+
is_rgdelegate = is_rgdelegateREDESIGN
110+
is_rgchair = is_rgchairREDESIGN
105111
is_chair_of_stream = is_chair_of_streamREDESIGN
106112
is_delegate_of_stream = is_delegate_of_streamREDESIGN
107113
is_authorized_in_draft_stream = is_authorized_in_draft_streamREDESIGN
@@ -116,11 +122,11 @@ def can_edit_stream(user, draft):
116122
return is_secretariat(user)
117123

118124
def can_adopt(user, draft):
119-
if settings.USE_DB_REDESIGN_PROXY_CLASSES and (not draft.stream_id or draft.stream_id == "ietf") and draft.group.type_id == "individ":
125+
if settings.USE_DB_REDESIGN_PROXY_CLASSES and (not draft.stream_id or draft.stream_id in ["ietf", "irtf"]) and draft.group.type_id == "individ":
120126
person = get_person_for_user(user)
121127
if not person:
122128
return False
123-
return is_wgchair(person) or is_wgdelegate(person) or is_secretariat(user)
129+
return is_wgchair(person) or is_rgchair(person) or is_wgdelegate(person) or is_rgdelegate() or is_secretariat(user)
124130
else:
125131
return is_secretariat(user)
126132

ietf/ietfworkflows/forms.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,32 @@ def __unicode__(self):
5353
class NoWorkflowStateForm(StreamDraftForm):
5454
comment = forms.CharField(widget=forms.Textarea, required=False)
5555
weeks = forms.IntegerField(required=False)
56-
wg = forms.ChoiceField(required=False)
56+
group = forms.ChoiceField(required=False)
5757

5858
template = 'ietfworkflows/noworkflow_state_form.html'
5959

6060
def __init__(self, *args, **kwargs):
6161
super(NoWorkflowStateForm, self).__init__(*args, **kwargs)
62-
self.wgs = None
62+
self.groups = None
6363
if is_secretariat(self.user):
64-
wgs = IETFWG.objects.all().order_by('group_acronym__acronym')
64+
groups = IETFWG.objects.all().order_by('group_acronym__acronym')
6565
else:
6666
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
67-
wgs = IETFWG.objects.filter(type="wg", state="active", role__name__in=("chair", "delegate"), role__person__user=self.user).order_by('acronym').distinct()
67+
groups = IETFWG.objects.filter(type__in=["wg", "rg"], state="active", role__name__in=("chair", "secr", "delegate"), role__person__user=self.user).order_by('acronym').distinct()
6868
else:
69-
wgs = set([i.group_acronym for i in self.person.wgchair_set.all()]).union(set([i.wg for i in self.person.wgdelegate_set.all()]))
70-
wgs = list(wgs)
71-
wgs.sort(lambda x, y: cmp(x.group_acronym.acronym, y.group_acronym.acronym))
72-
self.wgs = wgs
69+
groups = set([i.group_acronym for i in self.person.wgchair_set.all()]).union(set([i.wg for i in self.person.wgdelegate_set.all()]))
70+
groups = list(groups)
71+
groups.sort(lambda x, y: cmp(x.group_acronym.acronym, y.group_acronym.acronym))
72+
self.groups = groups
7373
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
74-
self.fields['wg'].choices = [(i.pk, '%s - %s' % (i.acronym, i.name)) for i in self.wgs]
74+
self.fields['group'].choices = [(i.pk, '%s - %s' % (i.acronym, i.name)) for i in self.groups]
7575
else:
76-
self.fields['wg'].choices = [(i.pk, '%s - %s' % (i.group_acronym.acronym, i.group_acronym.name)) for i in self.wgs]
76+
self.fields['group'].choices = [(i.pk, '%s - %s' % (i.group_acronym.acronym, i.group_acronym.name)) for i in self.groups]
7777

7878
def save(self):
7979
comment = self.cleaned_data.get('comment').strip()
8080
weeks = self.cleaned_data.get('weeks')
81-
wg = IETFWG.objects.get(pk=self.cleaned_data.get('wg'))
81+
group = IETFWG.objects.get(pk=self.cleaned_data.get('group'))
8282
estimated_date = None
8383
if weeks:
8484
now = datetime.date.today()
@@ -90,7 +90,10 @@ def save(self):
9090

9191
doc.time = datetime.datetime.now()
9292

93-
new_stream = StreamName.objects.get(slug="ietf")
93+
if group.type.slug == "rg":
94+
new_stream = StreamName.objects.get(slug="irtf")
95+
else:
96+
new_stream = StreamName.objects.get(slug="ietf")
9497

9598
if doc.stream != new_stream:
9699
e = DocEvent(type="changed_stream")
@@ -103,16 +106,16 @@ def save(self):
103106
e.save()
104107
doc.stream = new_stream
105108

106-
if doc.group.pk != wg.pk:
109+
if doc.group.pk != group.pk:
107110
e = DocEvent(type="changed_group")
108111
e.time = doc.time
109112
e.by = self.user.get_profile()
110113
e.doc = doc
111-
e.desc = u"Changed group to <b>%s (%s)</b>" % (wg.name, wg.acronym.upper())
114+
e.desc = u"Changed group to <b>%s (%s)</b>" % (group.name, group.acronym.upper())
112115
if doc.group.type_id != "individ":
113116
e.desc += " from %s (%s)" % (doc.group.name, doc.group.acronym)
114117
e.save()
115-
doc.group_id = wg.pk
118+
doc.group_id = group.pk
116119

117120
doc.save()
118121
self.draft = InternetDraft.objects.get(pk=doc.pk) # make sure proxy object is updated
@@ -130,7 +133,10 @@ def save(self):
130133

131134
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
132135
from ietf.doc.models import State
133-
to_state = State.objects.get(used=True, slug="c-adopt", type="draft-stream-%s" % self.draft.stream_id)
136+
if self.draft.stream_id == "irtf":
137+
to_state = State.objects.get(used=True, slug="active", type="draft-stream-irtf")
138+
else:
139+
to_state = State.objects.get(used=True, slug="c-adopt", type="draft-stream-%s" % self.draft.stream_id)
134140
else:
135141
to_state = get_state_by_name(CALL_FOR_ADOPTION)
136142
update_state(self.request, self.draft,

ietf/ietfworkflows/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def test_adopt_document(self):
3636
self.assertEquals(r.status_code, 200)
3737
q = PyQuery(r.content)
3838
self.assertEquals(len(q('form input[type=submit][value*=adopt]')), 1)
39-
self.assertEquals(len(q('form select[name="wg"] option')), 1) # we can only select "mars"
39+
self.assertEquals(len(q('form select[name="group"] option')), 1) # we can only select "mars"
4040

4141
# adopt in mars WG
4242
mailbox_before = len(outbox)
4343
events_before = draft.docevent_set.count()
4444
r = self.client.post(url,
4545
dict(comment="some comment",
46-
wg=Group.objects.get(acronym="mars").pk,
46+
group=Group.objects.get(acronym="mars").pk,
4747
weeks="10"))
4848
self.assertEquals(r.status_code, 302)
4949

ietf/templates/ietfworkflows/noworkflow_state_form.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<form action="" method="post">
22
<table class="ietf-table edit-form" style="width: 100%;">
33
<tr>
4-
<th>Adopt this draft in your WG</th>
4+
<th>Adopt this draft in your group</th>
55
</tr>
66
<tr style="vertical-align: top;"><td style="width: 50%;">
77
<div class="field{% if form.errors.comment %} error{% endif %}">
@@ -11,11 +11,11 @@
1111
</div>
1212
<div class="field{% if form.errors.weeks %} error{% endif %}">
1313
{{ form.weeks.errors }}
14-
Estimated time in 'Call for Adoption by WG Issued': <input type="text" name="weeks" value="{{ form.data.weeks }}" /> (in weeks)
14+
Estimated time in 'Call for Adoption by WG/RG Issued': <input type="text" name="weeks" value="{{ form.data.weeks }}" /> (in weeks)
1515
</div>
16-
<div class="field{% if form.errors.wg %} error{% endif %}">
17-
Adopt in WG: {{ form.wg }}
18-
{{ form.wg.errors }}
16+
<div class="field{% if form.errors.group %} error{% endif %}">
17+
Adopt in Group: {{ form.group }}
18+
{{ form.group.errors }}
1919
</div>
2020
<input type="submit" name="change" value="Call for adoption" />
2121
</td></tr>

0 commit comments

Comments
 (0)