Permalink
Browse files

Use waffle almost everywhere.

  • Loading branch information...
1 parent 3d50fc3 commit e35b45505c4e4d903b3120827786e46d3501f1c3 James Socol committed Mar 16, 2011
@@ -1,18 +1,19 @@
+{% load waffle_tags %}
{% extends "games/base.html" %}
{% block content %}
<h3>
{% if settings.FINALIST_LIST %}
<a href="{% url games.view_list %}">See all the entries &raquo;</a><br/>
{% endif %}
- {% if settings.ALLOW_VOTING %}
+ {% waffle allow_voting %}
<a href="{% url vote.ballot %}">Vote on the Community Prize &raquo;</a>
- {% endif %}
+ {% endwaffle %}
</h3>
<h1>Finalists</h1>
<article class="tile-list">
{% for game in games %}
{% include "games/game_listing.html" %}
{% endfor %}
</article>
-{% endblock %}
+{% endblock %}
@@ -1,3 +1,4 @@
+{% load waffle_tags %}
{% extends "games/base.html" %}
{% block content %}
@@ -9,7 +10,7 @@
<h2>You haven't submitted any games yet.</h2>
{% endfor %}
</article>
- {% if settings.ALLOW_SUBMISSIONS %}
+ {% waffle allow_submissions %}
<h3><a href='{% url games.create %}'>Submit a new game</a></h3>
- {% endif %}
+ {% endwaffle %}
{% endblock %}
View
@@ -8,13 +8,14 @@
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
-from core.decorators import enabled_or_404
+from waffle.decorators import waffle
+
from core.template import render
from games.forms import GameForm, ScreenshotForm
from games.models import Game, Screenshot
-@enabled_or_404('ALLOW_SUBMISSIONS')
+@waffle('allow_submissions')
@login_required
def create(request):
"""Create a new game."""
@@ -33,7 +34,7 @@ def create(request):
return render(request, 'games/create.html', {'form': form})
-@enabled_or_404('ALLOW_EDITING')
+@waffle('allow_editing')
@login_required
def edit(request, game_id):
"""Edit an existing game."""
@@ -60,7 +61,7 @@ def edit(request, game_id):
return render(request, 'games/edit.html', c)
-@enabled_or_404('ALLOW_DELETING')
+@waffle('allow_deleting')
@login_required
def delete(request, game_id):
"""Delete an existing game."""
@@ -92,7 +93,7 @@ def view(request, game_id, slug=None):
return render(request, 'games/view.html', {'game': game})
-@enabled_or_404('ALLOW_GALLERY')
+@waffle('allow_gallery')
def view_list(request):
"""View a list of games."""
# TODO: Paginate.
@@ -107,15 +108,15 @@ def view_list(request):
return render(request, 'games/list.html', {'games': games})
-@enabled_or_404('ALLOW_GALLERY')
+@waffle('allow_gallery')
def finalists(request):
"""View the list of finalists."""
games = (Game.objects.filter(id__in=settings.FINALIST_LIST)
.order_by('name'))
return render(request, 'games/finalists.html', {'games': games})
-@enabled_or_404('ALLOW_GALLERY')
+@waffle('allow_gallery')
def winners(request):
"""View the list of winners."""
return render(request, 'games/winners.html')
View
@@ -3,14 +3,15 @@
from django.shortcuts import get_object_or_404
from django.views.decorators.http import require_POST
+from waffle.decorators import waffle
+
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')
+@waffle('allow_voting')
@login_required
def ballot(request):
"""Display the list of games this user can vote on."""
@@ -19,7 +20,7 @@ def ballot(request):
return render(request, 'vote/ballot.html', {'ballot': ballot})
-@enabled_or_404('ALLOW_VOTING')
+@waffle('allow_voting')
@login_required
@require_POST
def vote(request):
@@ -0,0 +1,8 @@
+INSERT INTO waffle_flag
+(name, everyone, percent, superusers, staff, authenticated, rollout)
+VALUES
+('allow_submissions', NULL, NULL, 0, 0, 0, 0),
+('allow_editing', NULL, NULL, 0, 0, 0, 0),
+('allow_deleting', NULL, NULL, 0, 0, 0, 0),
+('allow_gallery', NULL, NULL, 0, 0, 0, 0),
+('allow_voting', NULL, NULL, 0, 0, 0, 0);
View
@@ -1,5 +1,6 @@
{% load tags %}
{% load bundler_tags %}
+{% load waffle_tags %}
<!-- You are in a twisting series of little tubes, all alike. -->
<!DOCTYPE html>
<html lang="en">
@@ -25,12 +26,16 @@
<section id="auth">
{% if user.is_authenticated %}
signed in as {{ user.username }} |
- {% if settings.ALLOW_SUBMISSIONS or user.game_set.all %}
+ {% waffle allow_submissions %}
<a href="{% url games.mine %}">your games</a>|
- {% endif %}
- {% if settings.ALLOW_VOTING %}
+ {% else %}
+ {% if user.game_set.exists %}
+ <a href="{% url games.mine %}">your games</a>|
+ {% endif %}
+ {% endwaffle %}
+ {% waffle allow_voting %}
<a href="{% url vote.ballot %}">your votes</a>|
- {% endif %}
+ {% endwaffle %}
<a href="{% url auth_logout %}?next=/">logout</a>
{% else %}
<a class="login" href="{% url auth_login %}">login</a>

0 comments on commit e35b455

Please sign in to comment.