Commit 0787ba5c authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Specify reason when denying project application

Add field `response' in ProjectApplication model.
Add option `-m' in project-control command.

Refs #3493
parent d2e16c8d
......@@ -738,7 +738,7 @@ def dismiss_application(application_id, request_user=None):
application.dismiss()
def deny_application(application_id):
def deny_application(application_id, reason=None):
application = get_application_for_update(application_id)
if not application.can_deny():
......@@ -746,7 +746,9 @@ def deny_application(application_id):
application.id, application.state_display()))
raise PermissionDenied(m)
application.deny()
if reason is None:
reason = ""
application.deny(reason)
application_deny_notify(application)
def approve_application(app_id):
......
......@@ -73,10 +73,17 @@ class Command(BaseCommand):
dest='terminate_expired',
default=False,
help="Terminate all expired projects"),
make_option('--message', '-m',
dest='message',
metavar='<msg>',
help=("Specify reason of action, "
"e.g. when denying a project")),
)
def handle(self, *args, **options):
message = options['message']
pid = options['terminate']
if pid is not None:
self.run_command(terminate, pid)
......@@ -99,7 +106,7 @@ class Command(BaseCommand):
appid = options['deny']
if appid is not None:
self.run_command(deny_application, appid)
self.run_command(deny_application, appid, message)
return
if options['check_expired']:
......
......@@ -1606,6 +1606,7 @@ class ProjectApplication(models.Model):
comments = models.TextField(null=True, blank=True)
issue_date = models.DateTimeField(auto_now_add=True)
response_date = models.DateTimeField(null=True, blank=True)
response = models.TextField(null=True, blank=True)
objects = ProjectApplicationManager()
......@@ -1775,7 +1776,7 @@ class ProjectApplication(models.Model):
def can_deny(self):
return self.state == self.PENDING
def deny(self):
def deny(self, reason):
if not self.can_deny():
m = _("cannot deny: application '%s' in state '%s'") % (
self.id, self.state)
......@@ -1783,6 +1784,7 @@ class ProjectApplication(models.Model):
self.state = self.DENIED
self.response_date = datetime.now()
self.response = reason
self.save()
def can_approve(self):
......
......@@ -5,3 +5,6 @@
--
Your project application request ({{object.name}}) has been denied.
Comment:
{{object.response}}
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