Commit 268a4fdd authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Impose pending application limit on owner

We used to check the limit on applicant; however we would like to
to control pending applications per the original applicant, i.e the
owner. The check is ignored when the applicant is a project admin.
parent 6480122e
......@@ -692,8 +692,9 @@ def submit_application(kw, request_user=None):
m = _(astakos_messages.NOT_ALLOWED)
raise PermissionDenied(m)
reached, limit = reached_pending_application_limit(request_user.id, precursor)
if reached:
owner = kw['owner']
reached, limit = reached_pending_application_limit(owner.id, precursor)
if not request_user.is_project_admin() and reached:
m = _(astakos_messages.REACHED_PENDING_APPLICATION_LIMIT) % limit
raise PermissionDenied(m)
......@@ -860,7 +861,7 @@ def _reached_pending_application_limit(user_id):
PENDING = ProjectApplication.PENDING
pending = ProjectApplication.objects.filter(
applicant__id=user_id, state=PENDING).count()
owner__id=user_id, state=PENDING).count()
return pending >= limit, limit
......
......@@ -1055,7 +1055,7 @@ def project_add(request):
user = request.user
reached, limit = reached_pending_application_limit(user.id)
if reached:
if not user.is_project_admin() and reached:
m = _(astakos_messages.PENDING_APPLICATION_LIMIT_ADD) % limit
messages.error(request, m)
next = reverse('astakos.im.views.project_list')
......@@ -1174,8 +1174,9 @@ def project_modify(request, application_id):
m = _(astakos_messages.NOT_ALLOWED)
raise PermissionDenied(m)
reached, limit = reached_pending_application_limit(user.id, app)
if reached:
owner_id = app.owner_id
reached, limit = reached_pending_application_limit(owner_id, app)
if not user.is_project_admin() and reached:
m = _(astakos_messages.PENDING_APPLICATION_LIMIT_MODIFY) % limit
messages.error(request, m)
next = reverse('astakos.im.views.project_list')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment