1616from ietf .doc .utils_charter import charter_name_for_group
1717from ietf .group .models import ( Group , Role , GroupEvent , GroupHistory , GroupStateName ,
1818 GroupStateTransitions , GroupTypeName , GroupURL , ChangeStateGroupEvent )
19- from ietf .group .utils import save_group_in_history , can_manage_group_type , can_manage_team_group
19+ from ietf .group .utils import save_group_in_history , can_manage_group
2020from ietf .group .utils import get_group_or_404
2121from ietf .ietfauth .utils import has_role
2222from ietf .person .fields import SearchableEmailsField
@@ -186,7 +186,7 @@ def submit_initial_charter(request, group_type=None, acronym=None):
186186 # This is where we start ignoring the passed in group_type
187187 group_type = group .type_id
188188
189- if not can_manage_group_type (request .user , group_type ):
189+ if not can_manage_group (request .user , group ):
190190 return HttpResponseForbidden ("You don't have permission to access this view" )
191191
192192 if not group .charter :
@@ -199,18 +199,6 @@ def submit_initial_charter(request, group_type=None, acronym=None):
199199def edit (request , group_type = None , acronym = None , action = "edit" ):
200200 """Edit or create a group, notifying parties as
201201 necessary and logging changes as group events."""
202- group = get_group_or_404 (acronym , group_type )
203- if not group_type and group :
204- group_type = group .type_id
205-
206- if group_type == "team" :
207- can_edit = can_manage_team_group (request .user , group ) or group .has_role (request .user , "chair" )
208- else :
209- can_edit = can_manage_group_type (request .user , group_type )
210-
211- if not can_edit :
212- return HttpResponseForbidden ("You don't have permission to access this view" )
213-
214202 if action == "edit" :
215203 new_group = False
216204 elif action in ("create" ,"charter" ):
@@ -219,6 +207,13 @@ def edit(request, group_type=None, acronym=None, action="edit"):
219207 else :
220208 raise Http404
221209
210+ if not new_group :
211+ group = get_group_or_404 (acronym , group_type )
212+ if not group_type and group :
213+ group_type = group .type_id
214+ if not (can_manage_group (request .user , group ) or group .has_role (request .user , "chair" )):
215+ return HttpResponseForbidden ("You don't have permission to access this view" )
216+
222217 if request .method == 'POST' :
223218 form = GroupForm (request .POST , group = group , group_type = group_type )
224219 if form .is_valid ():
@@ -369,7 +364,7 @@ def conclude(request, acronym, group_type=None):
369364 """Request the closing of group, prompting for instructions."""
370365 group = get_group_or_404 (acronym , group_type )
371366
372- if not can_manage_group_type (request .user , group . type_id ):
367+ if not can_manage_group (request .user , group ):
373368 return HttpResponseForbidden ("You don't have permission to access this view" )
374369
375370 if request .method == 'POST' :
0 commit comments