Skip to content

Commit

Permalink
Changed the signature of can_manage_all_groups_of_type to only take a…
Browse files Browse the repository at this point in the history
… type_id. Removed the logic that tried to distinguish permissions for teams by parent - that should be modeled as separate type_ids instead. Commit ready for merge.

 - Legacy-Id: 19258
  • Loading branch information
rjsparks committed Jul 22, 2021
1 parent 7ede094 commit 359889c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions ietf/doc/views_charter.py
Expand Up @@ -70,7 +70,7 @@ def change_state(request, name, option=None):
charter = get_object_or_404(Document, type="charter", name=name)
group = charter.group

if not can_manage_all_groups_of_type(request.user, group):
if not can_manage_all_groups_of_type(request.user, group.type_id):
permission_denied(request, "You don't have permission to access this view.")

chartering_type = get_chartering_type(charter)
Expand Down Expand Up @@ -261,7 +261,7 @@ def change_title(request, name, option=None):
logging the title as a comment."""
charter = get_object_or_404(Document, type="charter", name=name)
group = charter.group
if not can_manage_all_groups_of_type(request.user, group):
if not can_manage_all_groups_of_type(request.user, group.type_id):
permission_denied(request, "You don't have permission to access this view.")
by = request.user.person
if request.method == 'POST':
Expand Down Expand Up @@ -374,7 +374,7 @@ def submit(request, name, option=None):
charter_canonical_name = name
charter_rev = "00-00"

if not can_manage_all_groups_of_type(request.user, group) or not group.features.has_chartering_process:
if not can_manage_all_groups_of_type(request.user, group.type_id) or not group.features.has_chartering_process:
permission_denied(request, "You don't have permission to access this view.")


Expand Down
2 changes: 1 addition & 1 deletion ietf/doc/views_doc.py
Expand Up @@ -510,7 +510,7 @@ def document_main(request, name, rev=None):
if chartering and not snapshot:
milestones = doc.group.groupmilestone_set.filter(state="charter")

can_manage = can_manage_all_groups_of_type(request.user, doc.group)
can_manage = can_manage_all_groups_of_type(request.user, doc.group.type_id)

return render(request, "doc/document_charter.html",
dict(doc=doc,
Expand Down
2 changes: 1 addition & 1 deletion ietf/group/milestones.py
Expand Up @@ -112,7 +112,7 @@ def edit_milestones(request, acronym, group_type=None, milestone_set="current"):
needs_review = False
if can_manage_group(request.user, group):
can_change_uses_milestone_dates = True
if not can_manage_all_groups_of_type(request.user, group):
if not can_manage_all_groups_of_type(request.user, group.type_id):
# The user is chair or similar, not AD:
can_change_uses_milestone_dates = False
if milestone_set == "current":
Expand Down
11 changes: 3 additions & 8 deletions ietf/group/utils.py
Expand Up @@ -106,21 +106,16 @@ def save_milestone_in_history(milestone):
return h

# TODO: rework this using features.groupman_authroles
def can_manage_all_groups_of_type(user, group, type_id=None):
def can_manage_all_groups_of_type(user, type_id):
if not user.is_authenticated:
return False
if type_id is None:
type_id = group.type_id
log.assertion("isinstance(type_id, (type(''), type(u'')))")
if type_id == "rg":
return has_role(user, ('IRTF Chair', 'Secretariat'))
elif type_id == "wg":
return has_role(user, ('Area Director', 'Secretariat'))
elif type_id == "team":
if group and group.is_decendant_of("ietf"):
return has_role(user, ('Area Director', 'Secretariat'))
elif group and group.is_decendant_of("irtf"):
return has_role(user, ('IRTF Chair', 'Secretariat'))
return has_role(user, ('Area Director', 'Secretariat'))
elif type_id == "program":
return has_role(user, ('IAB', 'Secretariat',))
return has_role(user, ('Secretariat'))
Expand Down Expand Up @@ -261,7 +256,7 @@ def construct_group_menu_context(request, group, selected, group_type, others):
if group.features.customize_workflow and can_manage:
actions.append(("Customize workflow", urlreverse("ietf.group.views.customize_workflow", kwargs=kwargs)))

if group.state_id in ("active", "dormant") and group.type_id in ["wg", "rg", ] and can_manage_all_groups_of_type(request.user, group):
if group.state_id in ("active", "dormant") and group.type_id in ["wg", "rg", ] and can_manage_all_groups_of_type(request.user, group.type_id):
actions.append(("Request closing group", urlreverse("ietf.group.views.conclude", kwargs=kwargs)))

d = {
Expand Down
6 changes: 3 additions & 3 deletions ietf/group/views.py
Expand Up @@ -392,7 +392,7 @@ def chartering_groups(request):

for t in group_types:
t.chartering_groups = Group.objects.filter(type=t, charter__states__in=charter_states,state_id__in=('active','bof','proposed','dormant')).select_related("state", "charter").order_by("acronym")
t.can_manage = can_manage_all_groups_of_type(request.user, None, t.slug)
t.can_manage = can_manage_all_groups_of_type(request.user, t.slug)

for g in t.chartering_groups:
g.chartering_type = get_chartering_type(g.charter)
Expand Down Expand Up @@ -523,7 +523,7 @@ def group_about(request, acronym, group_type=None):
if group.state_id == "conclude":
e = group.latest_event(type='closing_note')

can_manage = can_manage_all_groups_of_type(request.user, group)
can_manage = can_manage_all_groups_of_type(request.user, group.type_id)
charter_submit_url = ""
if group.features.has_chartering_process:
charter_submit_url = urlreverse('ietf.doc.views_charter.submit', kwargs={ "name": charter_name_for_group(group) })
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def conclude(request, acronym, group_type=None):
"""Request the closing of group, prompting for instructions."""
group = get_group_or_404(acronym, group_type)

if not can_manage_all_groups_of_type(request.user, group):
if not can_manage_all_groups_of_type(request.user, group.type_id):
permission_denied(request, "You don't have permission to access this view")

if request.method == 'POST':
Expand Down

0 comments on commit 359889c

Please sign in to comment.