projects
/
pgcommitfest2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e70b670
)
Only CF managers (=staff users) can add patches to != open fests
author
Magnus Hagander
<magnus@hagander.net>
Fri, 19 Jul 2013 15:13:38 +0000
(17:13 +0200)
committer
Magnus Hagander
<magnus@hagander.net>
Fri, 19 Jul 2013 15:13:38 +0000
(17:13 +0200)
pgcommitfest/commitfest/models.py
patch
|
blob
|
blame
|
history
pgcommitfest/commitfest/templates/commitfest.html
patch
|
blob
|
blame
|
history
pgcommitfest/commitfest/views.py
patch
|
blob
|
blame
|
history
diff --git
a/pgcommitfest/commitfest/models.py
b/pgcommitfest/commitfest/models.py
index 145efab209c55012d2c006836463178a70e5fc14..44dd8842103bdae6c5f8e9fe35dd056c2b31e182 100644
(file)
--- 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 dc34653771ed255205dc7871e3cf587192717c14..fc31f69d6a13b0739acf559add2d017255d8689e 100644
(file)
--- 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 170102809ff719ec86edb2b57526adccb57ed7d6..30d8f2fb8d23fa0e4295ac5f482e9a28ab53d23d 100644
(file)
--- 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():