Permalink
Browse files

ALLOW_VOTING setting added

  • Loading branch information...
1 parent 4353ead commit a4a47e9c4b81625131f333c65c056bbf4f9fbdeb @potch potch committed Jan 11, 2011
Showing with 17 additions and 5 deletions.
  1. +9 −2 apps/core/context_processors.py
  2. +3 −0 apps/vote/views.py
  3. +2 −0 settings.py
  4. +3 −3 templates/base.html
@@ -1,7 +1,8 @@
from django.core.urlresolvers import reverse
+from django.conf import settings
def nav(request):
- return {
+ menu = {
'menu' : [
('Home', 'home'),
('Gallery', 'games.view_list'),
@@ -11,4 +12,10 @@ def nav(request):
('Resources', 'resources'),
],
'location' : request.path,
- }
+ }
+ if not settings.ALLOW_GALLERY:
+ menu['menu'].pop(1)
+ return menu
+
+def global_settings(request):
+ return {'settings': settings}
View
@@ -4,11 +4,13 @@
from django.views.decorators.http import require_POST
from core.template import render
+from core.decorators import enabled_or_404
from games.models import Game
from vote.forms import VoteForm
from vote.models import Ballot, Vote
+@enabled_or_404('ALLOW_VOTING')
@login_required
def ballot(request):
"""Display the list of games this user can vote on."""
@@ -17,6 +19,7 @@ def ballot(request):
return render(request, 'vote/ballot.html', {'ballot': ballot})
+@enabled_or_404('ALLOW_VOTING')
@login_required
@require_POST
def vote(request):
View
@@ -123,11 +123,13 @@
'django.core.context_processors.csrf',
'django.core.context_processors.request',
'core.context_processors.nav',
+ 'core.context_processors.global_settings',
)
ALLOW_SUBMISSIONS = True
ALLOW_EDITING = True
ALLOW_DELETING = True
+ALLOW_VOTING = False
ALLOW_GALLERY = False
# Account activation period
View
@@ -25,11 +25,11 @@
<section id="auth">
{% if user.is_authenticated %}
signed in as {{ user.username }} |
- {% if settings.ALLOW_SUBMISSIONS or user.game_set.all %}
- <a href="{% url games.mine %}">your games</a>|
+ {% if settings.ALLOW_SUBMISSIONS or user.game_set.all() %}
+ <a href="{% url games.mine %}">your games</a>|
{% endif %}
{% if settings.ALLOW_VOTING %}
- <a href="{% url vote.ballot %}">your votes</a>|
+ <a href="{% url vote.ballot %}">your votes</a>|
{% endif %}
<a href="{% url auth_logout %}?next=/">logout</a>
{% else %}

0 comments on commit a4a47e9

Please sign in to comment.