diff --git a/src/marketplace/authorization/proj.py b/src/marketplace/authorization/proj.py index c73a5fd..7eb4b9a 100644 --- a/src/marketplace/authorization/proj.py +++ b/src/marketplace/authorization/proj.py @@ -6,7 +6,7 @@ add_perm('project.view', marketplace.project.user.can_view) -add_perm('project.information_edit', marketplace.project.user.is_owner) +add_perm('project.information_edit', marketplace.project.user.can_edit_information) add_perm('project.publish', marketplace.project.user.is_owner) add_perm('project.approve_as_completed', marketplace.project.user.can_complete) add_perm('project.scope_view', marketplace.project.user.can_view) diff --git a/src/marketplace/domain/proj.py b/src/marketplace/domain/proj.py index c5cde24..09b83f1 100644 --- a/src/marketplace/domain/proj.py +++ b/src/marketplace/domain/proj.py @@ -169,21 +169,6 @@ def is_reviewer(user, proj): ) -@ProjectUserDomain._method_ -def can_view_tasks(self, user, proj): - return self.is_member(user, proj) or self.is_reviewer(user, proj) - - -@ProjectUserDomain._method_ -def can_review_tasks(self, user, proj): - return self.is_owner(user, proj) or self.is_reviewer(user, proj) - - -@ProjectUserDomain._method_ -def can_complete(self, user, proj): - return self.is_official(user, proj) # or self.is_reviewer(user, proj) - - @ProjectUserDomain def is_volunteer_official(user, proj): return user.is_authenticated and user.projecttaskrole_set.filter( @@ -235,6 +220,26 @@ def can_view(self, user, project): return True +@ProjectUserDomain._method_ +def can_view_tasks(self, user, proj): + return self.is_member(user, proj) or self.is_reviewer(user, proj) + + +@ProjectUserDomain._method_ +def can_review_tasks(self, user, proj): + return self.is_owner(user, proj) or self.is_reviewer(user, proj) + + +@ProjectUserDomain._method_ +def can_edit_information(self, user, project): + return self.is_owner(user, project) or self.is_scoper(user, project) + + +@ProjectUserDomain._method_ +def can_complete(self, user, proj): + return self.is_official(user, proj) # or self.is_reviewer(user, proj) + + class ProjectService: @staticmethod diff --git a/src/marketplace/views/proj.py b/src/marketplace/views/proj.py index 7931c03..eef9e76 100644 --- a/src/marketplace/views/proj.py +++ b/src/marketplace/views/proj.py @@ -360,28 +360,28 @@ def get_context_data(self, **kwargs): return context +@require_GET @permission_required('project.scope_view', raise_exception=True, fn=objectgetter(Project, 'proj_pk')) def project_scope_view(request, proj_pk, scope_pk=None): - if request.method == 'GET': - project = get_project(request, proj_pk) - project_scopes = ProjectService.get_all_project_scopes(request.user, proj_pk) - scopes_page = paginate(request, project_scopes, page_size=10) - if scope_pk: - current_scope = get_project_scope(request, proj_pk, scope_pk) - showing_current_scope = current_scope == ProjectService.get_current_project_scope(request.user, proj_pk) - else: - current_scope = ProjectService.get_current_project_scope(request.user, proj_pk) - showing_current_scope = True - return render(request, 'marketplace/proj_scope.html', - add_project_common_context(request, project, 'scope', - { - 'breadcrumb': project_breadcrumb(project, ('Scope', None)), - 'current_scope': current_scope, - 'project_scopes': scopes_page, - 'showing_current_scope': showing_current_scope - })) + project = get_project(request, proj_pk) + project_scopes = ProjectService.get_all_project_scopes(request.user, proj_pk) + scopes_page = paginate(request, project_scopes, page_size=10) + + if scope_pk: + current_scope = get_project_scope(request, proj_pk, scope_pk) + showing_current_scope = current_scope == ProjectService.get_current_project_scope(request.user, proj_pk) else: - raise Http404 + current_scope = ProjectService.get_current_project_scope(request.user, proj_pk) + showing_current_scope = True + + return render(request, 'marketplace/proj_scope.html', + add_project_common_context(request, project, 'scope', + { + 'breadcrumb': project_breadcrumb(project, ('Scope', None)), + 'current_scope': current_scope, + 'project_scopes': scopes_page, + 'showing_current_scope': showing_current_scope + })) class EditProjectScopeForm(ModelForm):