Align the roles edit buttons on a group's about page with the roles that the group edit GroupForm will accept. Avoids edit forms without any fields and some server 500 errors.

- Legacy-Id: 13296
This commit is contained in:
Henrik Levkowetz 2017-05-10 13:05:51 +00:00
parent 38bfdb4095
commit a59331dd63
4 changed files with 13 additions and 10 deletions

View file

@ -242,3 +242,11 @@ def construct_group_menu_context(request, group, selected, group_type, others):
d.update(others)
return d
def roles_for_group_type(group_type):
roles = ["chair", "secr", "techadv", "delegate", ]
if group_type == "dir":
roles.append("reviewer")
return roles

View file

@ -59,7 +59,7 @@ from ietf.group.models import Group, Role, ChangeStateGroupEvent
from ietf.name.models import GroupTypeName
from ietf.group.utils import (get_charter_text, can_manage_group_type,
milestone_reviewer_for_group_type, can_provide_status_update,
can_manage_materials, get_group_or_404,
can_manage_materials, get_group_or_404, roles_for_group_type,
construct_group_menu_context, get_group_materials)
from ietf.community.utils import docs_tracked_by_community_list
from ietf.community.models import CommunityList, EmailSubscription
@ -443,6 +443,7 @@ def group_about(request, acronym, group_type=None):
"can_provide_status_update": can_provide_update,
"status_update": status_update,
"charter_submit_url": charter_submit_url,
"editable_roles": roles_for_group_type(group_type),
}))
def all_status(request):

View file

@ -16,8 +16,8 @@ from ietf.doc.utils import get_tags_for_stream_id
from ietf.doc.utils_charter import charter_name_for_group
from ietf.group.models import ( Group, Role, GroupEvent, GroupHistory, GroupStateName,
GroupStateTransitions, GroupTypeName, GroupURL, ChangeStateGroupEvent )
from ietf.group.utils import save_group_in_history, can_manage_group, can_manage_group_type
from ietf.group.utils import get_group_or_404, setup_default_community_list_for_group
from ietf.group.utils import (save_group_in_history, can_manage_group, can_manage_group_type,
get_group_or_404, setup_default_community_list_for_group, roles_for_group_type, )
from ietf.ietfauth.utils import has_role
from ietf.person.fields import SearchableEmailsField
from ietf.person.models import Person, Email
@ -28,12 +28,6 @@ from ietf.utils.text import strip_suffix
MAX_GROUP_DELEGATES = 3
def roles_for_group_type(group_type):
roles = ["chair", "secr", "techadv", "delegate"]
if group_type == "dir":
roles.append("reviewer")
return roles
class GroupForm(forms.Form):
name = forms.CharField(max_length=80, label="Name", required=True)
acronym = forms.CharField(max_length=40, label="Acronym", required=True)

View file

@ -143,7 +143,7 @@
{% endif %}
<th>{{ label }}</th>
<td class="edit">
{% if can_edit_group and not slug == "ad" %}
{% if can_edit_group and slug in editable_roles %}
<a class="btn btn-default btn-xs" href="{% url 'ietf.group.views_edit.edit' acronym=group.acronym field=slug %}">Edit</a>
{% endif %}
</td>