Updated code and templates to use the new docman and groupman group features.
- Legacy-Id: 15922
This commit is contained in:
parent
237d0ed64e
commit
b57ad67041
|
@ -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 []
|
||||
|
||||
|
|
|
@ -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"))
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 @@
|
|||
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>WG chair</li>
|
||||
<li><a href="{% url "ietf.submit.views.approvals" %}">Approve a draft</a></li>
|
||||
|
||||
{% for g in user|managed_groups %}
|
||||
{% for g in user|docman_groups %}
|
||||
<li><a href="{% url "ietf.group.views.group_documents" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>
|
||||
{% endfor %}
|
||||
{% for g in user|managed_groups %}
|
||||
{% for g in user|matman_groups %}
|
||||
<li><a href="{% url "ietf.group.views.meetings" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} meetings</a></li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
@ -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 %}
|
||||
<tr>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</td>
|
||||
|
||||
{% if session.status_id == 'canceled' %}
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<td colspan="6"><span class="label label-danger">Session cancelled</span></td>
|
||||
{% else %}
|
||||
<td colspan="5"><span class="label label-danger">Session cancelled</span></td>
|
||||
|
@ -88,7 +88,7 @@
|
|||
{{ session.last_update|utc|date:"Y-m-d" }}<br><small>{{ session.last_update|utc|date:"H:i:s" }} UTC</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<td>
|
||||
<div>{% include "meeting/edit_materials_button.html" %}</div>
|
||||
</td>
|
||||
|
|
|
@ -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 @@
|
|||
<table class="table table-condensed table-striped tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<th class="col-md-1">Group</th>
|
||||
<th class="col-md-1">Agenda</th>
|
||||
<th class="col-md-1">Minutes</th>
|
||||
|
@ -77,7 +77,7 @@
|
|||
<table class="table table-condensed table-striped tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<th class="col-md-1">Group</th>
|
||||
<th class="col-md-1">Agenda</th>
|
||||
<th class="col-md-1">Minutes</th>
|
||||
|
@ -113,7 +113,7 @@
|
|||
<table class="table table-condensed table-striped tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<th class="col-md-1">Group</th>
|
||||
<th class="col-md-1">Agenda</th>
|
||||
<th class="col-md-1">Minutes</th>
|
||||
|
@ -149,7 +149,7 @@
|
|||
<table class="table table-condensed table-striped tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<th class="col-md-1">Group</th>
|
||||
<th class="col-md-1">Agenda</th>
|
||||
<th class="col-md-1">Minutes</th>
|
||||
|
@ -184,7 +184,7 @@
|
|||
<table class="table table-condensed table-striped tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<th class="col-md-1">Group</th>
|
||||
<th class="col-md-1">Agenda</th>
|
||||
<th class="col-md-1">Minutes</th>
|
||||
|
@ -218,7 +218,7 @@
|
|||
<table class="table table-condensed table-striped tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if user|has_role:"Secretariat" or user|managed_groups %}
|
||||
{% if user|has_role:"Secretariat" or user|matman_groups %}
|
||||
<th class="col-md-1">Group</th>
|
||||
<th class="col-md-1">Agenda</th>
|
||||
<th class="col-md-1">Minutes</th>
|
||||
|
|
|
@ -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 %}
|
||||
<h1>IETF {{ meeting_num }} meeting materials that you can edit</h1>
|
||||
|
||||
{% 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 %}
|
||||
<p><a href="{% url 'ietf.meeting.views.session_details' num=meeting_num acronym=g.acronym %}">{{ g.acronym }}</a></p>
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in a new issue