Skip to content

Commit

Permalink
allow project scopers to edit general project information
Browse files Browse the repository at this point in the history
resolves #59
  • Loading branch information
jesteria committed Dec 10, 2020
1 parent a5c2aac commit e6cd551
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/marketplace/authorization/proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 20 additions & 15 deletions src/marketplace/domain/proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
38 changes: 19 additions & 19 deletions src/marketplace/views/proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e6cd551

Please sign in to comment.