summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks2011-10-25 01:13:25 +0200
committerÉtienne Loks2011-10-25 01:13:25 +0200
commit023f8571e1386a08e25d779252c221ca939d1f1d (patch)
treefb438eab21ff42eb026201cb130b77898d2ddf90
parent229e7616b16ee1f316b9a9ab5442631ff5033668 (diff)
Allow disabling frontpage polls (closes #311)
-rw-r--r--.gitignore1
-rw-r--r--papillon/polls/forms.py4
-rw-r--r--papillon/polls/views.py6
-rw-r--r--papillon/settings.py.tpl1
-rw-r--r--papillon/templates/base.html2
-rw-r--r--papillon/templates/main.html3
6 files changed, 12 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 2b0f79c..0363bf8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
*.pyc
*.db
*.swp
+*.mo
papillon/settings.py
diff --git a/papillon/polls/forms.py b/papillon/polls/forms.py
index 3a151aa..2e9b75d 100644
--- a/papillon/polls/forms.py
+++ b/papillon/polls/forms.py
@@ -28,7 +28,7 @@ from django.contrib.admin import widgets as adminwidgets
from django.utils.translation import gettext_lazy as _
from papillon.polls.models import Poll, Category, Choice, Comment
-from papillon import settings
+from django.conf import settings
class TextareaWidget(forms.Textarea):
"""
@@ -73,6 +73,8 @@ class AdminPollForm(PollForm):
'dated_choices', 'type']
if not Category.objects.all():
exclude.append('category')
+ if not settings.ALLOW_FRONTPAGE_POLL:
+ exclude.append('public')
enddate = SplitDateTimeJSField(widget=adminwidgets.AdminSplitDateTime(),
required=False, label=Poll._meta.get_field('enddate').verbose_name,
help_text=Poll._meta.get_field('enddate').help_text)
diff --git a/papillon/polls/views.py b/papillon/polls/views.py
index 1022f58..26b3b34 100644
--- a/papillon/polls/views.py
+++ b/papillon/polls/views.py
@@ -58,8 +58,10 @@ def index(request):
response_dct, redirect = getBaseResponse(request)
if redirect:
return redirect
- response_dct['polls'] = Poll.objects.filter(public=True, category=None)
- response_dct['categories'] = Category.objects.all()
+ response_dct['public'] = settings.ALLOW_FRONTPAGE_POLL
+ if response_dct['public']:
+ response_dct['polls'] = Poll.objects.filter(public=True, category=None)
+ response_dct['categories'] = Category.objects.all()
error = ''
if 'bad_poll' in request.GET:
response_dct['error'] = _("The poll requested don't exist (anymore?)")
diff --git a/papillon/settings.py.tpl b/papillon/settings.py.tpl
index b40a37e..f83dcb2 100644
--- a/papillon/settings.py.tpl
+++ b/papillon/settings.py.tpl
@@ -15,6 +15,7 @@ BASE_SITE = SERVER_URL + EXTRA_URL
TINYMCE_URL = 'http://localhost/tinymce/'
MAX_COMMENT_NB = 10 # max number of comments by poll - 0 to disable comments
+ALLOW_FRONTPAGE_POLL = False # disabled is recommanded for public instance
# time to live in days
DAYS_TO_LIVE = 30
diff --git a/papillon/templates/base.html b/papillon/templates/base.html
index 5da20fb..30b1bf3 100644
--- a/papillon/templates/base.html
+++ b/papillon/templates/base.html
@@ -19,7 +19,7 @@
{% block content %}{% endblock %}
</div>
<div id="footer">
-<a href='http://blog.peacefrogs.net/nim/papillon/'>Papillon</a> - <a href='http://www.gnu.org/licenses/gpl.html'>Copyright</a> © 2008 <a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon project</a>
+<a href='http://blog.peacefrogs.net/nim/papillon/'>Papillon</a> - <a href='http://www.gnu.org/licenses/gpl.html'>Copyright</a> © 2008-2011 <a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon project</a>
</div>
</div>
</body>
diff --git a/papillon/templates/main.html b/papillon/templates/main.html
index f27a97b..696ab47 100644
--- a/papillon/templates/main.html
+++ b/papillon/templates/main.html
@@ -6,6 +6,7 @@
<h2><a href='{% url create%}'>{%trans "Create a poll"%}</a></h2>
<p>{% trans "Create a new sondage for take a decision, find a date for a meeting, etc." %} <a href='create'>{% trans "It's here!" %}</a></p>
+{% if public %}
{% if polls %}<h2>{%trans "Public polls"%}</h2>{%endif%}
{% for poll in polls %}
<div class='poll-description'>
@@ -18,5 +19,5 @@
{% for category in categories %}
<h3><a href='{% url category category.id%}'>{{category.name}}</a></h3>
{% endfor %}
-
+{% endif %}
{% endblock %}