added method for determining if section is open for proposals and redirect away from form if not
This commit is contained in:
parent
25a8088984
commit
e00b646f20
2 changed files with 13 additions and 0 deletions
|
@ -44,6 +44,16 @@ class ProposalSection(models.Model):
|
||||||
Q(closed=False) | Q(closed=None),
|
Q(closed=False) | Q(closed=None),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def is_available(self):
|
||||||
|
if self.closed:
|
||||||
|
return False
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
if self.start and self.start > now:
|
||||||
|
return False
|
||||||
|
if self.end and self.end < now:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.section.name
|
return self.section.name
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,9 @@ def proposal_submit_kind(request, kind_slug):
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
return redirect("dashboard")
|
return redirect("dashboard")
|
||||||
|
|
||||||
|
if not kind.section.proposalsection.is_available():
|
||||||
|
return redirect("proposal_submit")
|
||||||
|
|
||||||
form_class = get_form(settings.PROPOSAL_FORMS[kind_slug])
|
form_class = get_form(settings.PROPOSAL_FORMS[kind_slug])
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
|
Loading…
Reference in a new issue