Commit c9285b7a authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Fix membership admin actions

- Require POST request in membership reject/remove views
- Fix members table actions cell content
- Fix reject/remove actions urls
parent 243e51dc
......@@ -1177,6 +1177,9 @@ class ProjectApplication(models.Model):
objects = ProjectApplicationManager()
def __unicode__(self):
return "%s applied by %s" % (self.name, self.applicant)
def add_resource_policy(self, service, resource, uplimit):
"""Raises ObjectDoesNotExist, IntegrityError"""
q = self.projectresourcegrant_set
......
......@@ -31,6 +31,8 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from collections import defaultdict
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.template import Context, Template
......@@ -142,6 +144,8 @@ class RichLinkColumn(tables.TemplateColumn):
'confirm': self.get_confirm(record, table)
}
# decide whether to return dict or a list of dicts in case we want to
# display multiple actions within a cell.
if self.extra_context:
contexts = []
extra_contexts = self.extra_context(record, table, self)
......@@ -152,6 +156,7 @@ class RichLinkColumn(tables.TemplateColumn):
contexts.append(newcontext)
else:
context.update(extra_contexts)
contexts = [context]
else:
contexts = [context]
......@@ -237,7 +242,8 @@ class UserProjectApplicationsTable(UserTable):
def member_action_extra_context(membership, table, col):
urls, actions, prompts, confirms = [], [], [], []
context = []
if membership.state == ProjectMembership.REQUESTED:
urls = ['astakos.im.views.project_reject_member',
......@@ -254,6 +260,13 @@ def member_action_extra_context(membership, table, col):
confirms = [True, True]
for i, url in enumerate(urls):
context.append(dict(url=reverse(url, args=(table.project.pk,
membership.person.pk)),
action=actions[i], prompt=prompts[i],
confirm=confirms[i]))
return context
class ProjectApplicationMembersTable(UserTable):
name = tables.Column(accessor="person.last_name", verbose_name=_('Name'))
status = tables.Column(accessor="state", verbose_name=_('Status'))
......
......@@ -1262,7 +1262,7 @@ def project_accept_member(request, application_id, user_id):
transaction.commit()
return redirect(reverse('project_detail', args=(application_id,)))
@require_http_methods(["GET"])
@require_http_methods(["POST"])
@signed_terms_required
@login_required
@transaction.commit_manually
......@@ -1289,7 +1289,7 @@ def project_remove_member(request, application_id, user_id):
transaction.commit()
return redirect(reverse('project_detail', args=(application_id,)))
@require_http_methods(["GET"])
@require_http_methods(["POST"])
@signed_terms_required
@login_required
@transaction.commit_manually
......
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