diff options
-rw-r--r-- | pgcommitfest/commitfest/models.py | 4 | ||||
-rw-r--r-- | pgcommitfest/commitfest/templates/commitfest.html | 2 | ||||
-rw-r--r-- | pgcommitfest/commitfest/views.py | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/pgcommitfest/commitfest/models.py b/pgcommitfest/commitfest/models.py index 145efab..44dd884 100644 --- a/pgcommitfest/commitfest/models.py +++ b/pgcommitfest/commitfest/models.py @@ -34,6 +34,10 @@ class CommitFest(models.Model): def statusstring(self): return [v for k,v in self._STATUS_CHOICES if k==self.status][0] + @property + def isopen(self): + return self.status == self.STATUS_OPEN + def __unicode__(self): return self.name diff --git a/pgcommitfest/commitfest/templates/commitfest.html b/pgcommitfest/commitfest/templates/commitfest.html index dc34653..fc31f69 100644 --- a/pgcommitfest/commitfest/templates/commitfest.html +++ b/pgcommitfest/commitfest/templates/commitfest.html @@ -39,7 +39,9 @@ This is commitfest {{cf}}. </tbody> </table> +{%if cf.isopen or user.is_staff %} <p> <a class="btn" href="new/">New patch</a> </p> +{%endif%} {%endblock%} diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 1701028..30d8f2f 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -97,6 +97,9 @@ def patchform(request, cfid, patchid): @transaction.commit_on_success def newpatch(request, cfid): cf = get_object_or_404(CommitFest, pk=cfid) + if not cf.status == CommitFest.STATUS_OPEN and not request.user.is_staff: + raise Http404("This commitfest is not open!") + if request.method == 'POST': form = NewPatchForm(data=request.POST) if form.is_valid(): |