From b57ad67041d2445431a82cd33418c166e2190583 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Wed, 30 Jan 2019 15:59:00 +0000 Subject: [PATCH] Updated code and templates to use the new docman and groupman group features. - Legacy-Id: 15922 --- ietf/doc/templatetags/managed_groups.py | 17 ++++++++++++++++- ietf/doc/views_doc.py | 5 +++-- ietf/doc/views_draft.py | 19 ++++++++++++------- ietf/group/utils.py | 2 +- ietf/ietfauth/utils.py | 17 ++++++++++------- ietf/submit/utils.py | 5 +++-- ietf/submit/views.py | 4 ++-- ietf/templates/base/menu.html | 6 +++--- ietf/templates/meeting/group_materials.html | 6 +++--- ietf/templates/meeting/materials.html | 14 +++++++------- .../meeting/materials_editable_groups.html | 6 +++--- 11 files changed, 63 insertions(+), 38 deletions(-) diff --git a/ietf/doc/templatetags/managed_groups.py b/ietf/doc/templatetags/managed_groups.py index 0db6b1367..225d892d4 100644 --- a/ietf/doc/templatetags/managed_groups.py +++ b/ietf/doc/templatetags/managed_groups.py @@ -1,3 +1,7 @@ +# Copyright The IETF Trust 2016-2019, All Rights Reserved +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + from django import template import debug # pyflakes:ignore @@ -8,7 +12,18 @@ from ietf.group.utils import group_features_group_filter register = template.Library() @register.filter -def managed_groups(user): +def docman_groups(user): + if not (user and hasattr(user, "is_authenticated") and user.is_authenticated): + return [] + + groups = Group.objects.filter( role__person=user.person, + type__features__has_documents=True, + state__slug__in=('active', 'bof')) + groups = group_features_group_filter(groups, user.person, 'docman_roles') + return groups + +@register.filter +def matman_groups(user): if not (user and hasattr(user, "is_authenticated") and user.is_authenticated): return [] diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 9d79f3551..e4166edd5 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2016-2018, All Rights Reserved +# Copyright The IETF Trust 2016-2019, All Rights Reserved # -*- coding: utf-8 -*- # Parts Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). @@ -165,9 +165,10 @@ def document_main(request, name, rev=None): # which causes problems in the filter() below. Work around this: if request.user.is_authenticated: roles = Role.objects.filter(group__acronym__in=stream_slugs, person__user=request.user) - roles = group_features_role_filter(roles, request.user.person, 'matman_roles') + roles = group_features_role_filter(roles, request.user.person, 'docman_roles') else: roles = [] + can_change_stream = bool(can_edit or roles) can_edit_iana_state = has_role(request.user, ("Secretariat", "IANA")) diff --git a/ietf/doc/views_draft.py b/ietf/doc/views_draft.py index eb6ad7b39..fc8507af1 100644 --- a/ietf/doc/views_draft.py +++ b/ietf/doc/views_draft.py @@ -1,4 +1,5 @@ # Copyright The IETF Trust 2010-2019, All Rights Reserved +# -*- coding: utf-8 -*- # changing state and metadata on Internet Drafts @@ -1312,21 +1313,25 @@ class AdoptDraftForm(forms.Form): if has_role(user, "Secretariat"): state_types.update(['draft-stream-ietf','draft-stream-irtf']) else: - if has_role(user, "IRTF Chair") or Group.objects.filter(type="rg", state="active", role__person__user=user, role__name__in=rg_features.matman_roles).exists(): + if (has_role(user, "IRTF Chair") + or Group.objects.filter(type="rg", + state="active", + role__person__user=user, + role__name__in=rg_features.docman_roles).exists()): state_types.add('draft-stream-irtf') - if Group.objects.filter(type="wg", state="active", role__person__user=user, role__name__in=wg_features.matman_roles).exists(): + if Group.objects.filter( type="wg", + state="active", + role__person__user=user, + role__name__in=wg_features.docman_roles).exists(): state_types.add('draft-stream-ietf') - - - state_choices = State.objects.filter(type__in=state_types, used=True).exclude(slug__in=settings.GROUP_STATES_WITH_EXTRA_PROCESSING) if not has_role(user, "Secretariat"): if has_role(user, "IRTF Chair"): - group_queryset = self.fields["group"].queryset.filter(Q(role__person__user=user, role__name__in=rg_features.matman_roles)|Q(type="rg", state="active")).distinct() + group_queryset = self.fields["group"].queryset.filter(Q(role__person__user=user, role__name__in=rg_features.docman_roles)|Q(type="rg", state="active")).distinct() else: - group_queryset = self.fields["group"].queryset.filter(role__person__user=user, role__name__in=wg_features.matman_roles).distinct() + group_queryset = self.fields["group"].queryset.filter(role__person__user=user, role__name__in=wg_features.docman_roles).distinct() self.fields["group"].queryset = group_queryset self.fields['group'].choices = [(g.pk, '%s - %s' % (g.acronym, g.name)) for g in self.fields["group"].queryset] diff --git a/ietf/group/utils.py b/ietf/group/utils.py index b71ab5f38..f504cef21 100644 --- a/ietf/group/utils.py +++ b/ietf/group/utils.py @@ -131,7 +131,7 @@ def can_manage_materials(user, group): def can_provide_status_update(user, group): if not group.features.acts_like_wg: return False - return has_role(user, 'Secretariat') or group.has_role(user, group.features.matman_roles) + return has_role(user, 'Secretariat') or group.has_role(user, group.features.groupman_roles) def get_group_or_404(acronym, group_type): """Helper to overcome the schism between group-type prefixed URLs and generic.""" diff --git a/ietf/ietfauth/utils.py b/ietf/ietfauth/utils.py index d317dcd9e..010f3fbd2 100644 --- a/ietf/ietfauth/utils.py +++ b/ietf/ietfauth/utils.py @@ -13,7 +13,7 @@ from django.utils.decorators import available_attrs import debug # pyflakes:ignore -from ietf.group.models import Group, Role +from ietf.group.models import Role, GroupFeatures from ietf.person.models import Person def user_is_person(user, person): @@ -136,20 +136,23 @@ def is_authorized_in_doc_stream(user, doc): if doc.stream.slug == "ietf" and doc.group.type_id == "individ": return False - matman_roles = doc.group.features.matman_roles + docman_roles = doc.group.features.docman_roles if doc.stream.slug == "ietf": group_req = Q(group=doc.group) elif doc.stream.slug == "irtf": group_req = Q(group__acronym=doc.stream.slug) | Q(group=doc.group) - elif doc.stream.slug in ("iab", "ise"): + elif doc.stream.slug == "iab": + if doc.group.type.slug == 'individ' or doc.group.acronym == 'iab': + docman_roles = GroupFeatures.objects.get(type_id="iab").docman_roles + group_req = Q(group__acronym=doc.stream.slug) + elif doc.stream.slug == "ise": if doc.group.type.slug == 'individ': - # A lot of special cases here, for stream slugs and group acronyms - matman_roles = Group.objects.get(acronym=doc.stream.slug).features.matman_roles + docman_roles = GroupFeatures.objects.get(type_id="ietf").docman_roles group_req = Q(group__acronym=doc.stream.slug) else: group_req = Q() - return Role.objects.filter(Q(name__in=matman_roles, person__user=user) & group_req).exists() + return Role.objects.filter(Q(name__in=docman_roles, person__user=user) & group_req).exists() def is_authorized_in_group(user, group): """Return whether user is authorized to perform duties on @@ -169,7 +172,7 @@ def is_authorized_in_group(user, group): if group.parent.acronym == 'iab' and has_role(user, ['IAB','IAB Executive Director',]): return True - return Role.objects.filter(name__in=group.features.matman_roles, person__user=user,group=group ).exists() + return Role.objects.filter(name__in=group.features.groupman_roles, person__user=user,group=group ).exists() def is_individual_draft_author(user, doc): diff --git a/ietf/submit/utils.py b/ietf/submit/utils.py index 0a7335b24..3aa6c05db 100644 --- a/ietf/submit/utils.py +++ b/ietf/submit/utils.py @@ -1,4 +1,5 @@ -# Copyright The IETF Trust 2011, All Rights Reserved +# Copyright The IETF Trust 2011-2019, All Rights Reserved +# -*- coding: utf-8 -*- import os import datetime @@ -556,7 +557,7 @@ def preapprovals_for_user(user): if has_role(user, "Secretariat"): return res - acronyms = [g.acronym for g in Group.objects.filter(role__person__user=user, type__features__acts_like_wg=True)] + acronyms = [g.acronym for g in Group.objects.filter(role__person__user=user, type__features__req_subm_approval=True)] res = res.filter(name__regex="draft-[^-]+-(%s)-.*" % "|".join(acronyms)) diff --git a/ietf/submit/views.py b/ietf/submit/views.py index 3984f3f8c..a08c39035 100644 --- a/ietf/submit/views.py +++ b/ietf/submit/views.py @@ -512,10 +512,10 @@ def approvals(request): @role_required("Secretariat", "Area Director", "WG Chair", "RG Chair") def add_preapproval(request): - groups = Group.objects.filter(type__features__acts_like_wg=True).exclude(state__in=["conclude","bof-conc"]).order_by("acronym").distinct() + groups = Group.objects.filter(type__features__req_subm_approval=True).exclude(state__in=["conclude","bof-conc"]).order_by("acronym").distinct() if not has_role(request.user, "Secretariat"): - groups = group_features_group_filter(groups, request.user.person, 'matman_roles') + groups = group_features_group_filter(groups, request.user.person, 'docman_roles') if request.method == "POST": form = PreapprovalForm(request.POST) diff --git a/ietf/templates/base/menu.html b/ietf/templates/base/menu.html index bcaefc8e0..1af5a14e1 100644 --- a/ietf/templates/base/menu.html +++ b/ietf/templates/base/menu.html @@ -1,4 +1,4 @@ -{# Copyright The IETF Trust 2015, All Rights Reserved #}{% load origin %}{% origin %} +{# Copyright The IETF Trust 2015-2019, All Rights Reserved #}{% load origin %}{% origin %} {% load ietf_filters managed_groups wg_menu streams_menu active_groups_menu group_filters %} {% if flavor != "top" %} @@ -63,10 +63,10 @@
  • WG chair
  • Approve a draft
  • - {% for g in user|managed_groups %} + {% for g in user|docman_groups %}
  • {{ g.acronym }} {{ g.type.slug }} docs
  • {% endfor %} - {% for g in user|managed_groups %} + {% for g in user|matman_groups %}
  • {{ g.acronym }} {{ g.type.slug }} meetings
  • {% endfor %} {% endif %} diff --git a/ietf/templates/meeting/group_materials.html b/ietf/templates/meeting/group_materials.html index 2149b7e91..fb9de95d1 100644 --- a/ietf/templates/meeting/group_materials.html +++ b/ietf/templates/meeting/group_materials.html @@ -1,4 +1,4 @@ -{# Copyright The IETF Trust 2015, All Rights Reserved #}{% load origin %}{% origin %} +{# Copyright The IETF Trust 2015-2019, All Rights Reserved #}{% load origin %}{% origin %} {% load ietf_filters proceedings_filters managed_groups %} {% load tz %} @@ -19,7 +19,7 @@ {% if session.status_id == 'canceled' %} - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} Session cancelled {% else %} Session cancelled @@ -88,7 +88,7 @@ {{ session.last_update|utc|date:"Y-m-d" }}
    {{ session.last_update|utc|date:"H:i:s" }} UTC {% endif %} - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %}
    {% include "meeting/edit_materials_button.html" %}
    diff --git a/ietf/templates/meeting/materials.html b/ietf/templates/meeting/materials.html index 9f397d124..545319097 100644 --- a/ietf/templates/meeting/materials.html +++ b/ietf/templates/meeting/materials.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{# Copyright The IETF Trust 2015, All Rights Reserved #} +{# Copyright The IETF Trust 2015-2019, All Rights Reserved #} {% load origin %} {% load ietf_filters staticfiles managed_groups %} @@ -43,7 +43,7 @@ - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} @@ -77,7 +77,7 @@
    Group Agenda Minutes
    - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} @@ -113,7 +113,7 @@
    Group Agenda Minutes
    - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} @@ -149,7 +149,7 @@
    Group Agenda Minutes
    - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} @@ -184,7 +184,7 @@
    Group Agenda Minutes
    - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} @@ -218,7 +218,7 @@
    Group Agenda Minutes
    - {% if user|has_role:"Secretariat" or user|managed_groups %} + {% if user|has_role:"Secretariat" or user|matman_groups %} diff --git a/ietf/templates/meeting/materials_editable_groups.html b/ietf/templates/meeting/materials_editable_groups.html index 2ed94854c..2a0f79c48 100644 --- a/ietf/templates/meeting/materials_editable_groups.html +++ b/ietf/templates/meeting/materials_editable_groups.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{# Copyright The IETF Trust 2016, All Rights Reserved #} +{# Copyright The IETF Trust 2016-2019, All Rights Reserved #} {% load origin %} {% load ietf_filters managed_groups group_filters %} @@ -7,8 +7,8 @@ {% block content %}

    IETF {{ meeting_num }} meeting materials that you can edit

    - {% if user and user.is_authenticated and user|managed_groups %} - {% for g in user|managed_groups %} + {% if user and user.is_authenticated and user|matman_groups %} + {% for g in user|matman_groups %} {% if g|has_sessions:meeting_num %}

    {{ g.acronym }}

    {% else %}
    Group Agenda Minutes