Raffle improvements

Add flag to enable/disable raffle display on dashboard.
Add link from raffle winner to attendee profile.
Add URL for single raffle and base raffle path.
This commit is contained in:
Joel Addison 2020-01-23 14:52:28 +10:00
parent ffac4753fc
commit 20083bcb16
5 changed files with 38 additions and 29 deletions

View file

@ -3,7 +3,8 @@ from pinaxcon.raffle import views
urlpatterns = [ urlpatterns = [
url(r'^tickets/', views.raffle_view), url(r"^$", views.raffle_view, name="raffle-home"),
url(r'^tickets/', views.raffle_view, name="raffle-tickets"),
url(r'^draw/(?P<raffle_id>[0-9]+)/$', views.draw_raffle_ticket, name="raffle-draw"), url(r'^draw/(?P<raffle_id>[0-9]+)/$', views.draw_raffle_ticket, name="raffle-draw"),
url(r'^draw/redraw/([0-9]+)/$', views.raffle_redraw, name="raffle-redraw"), url(r'^draw/redraw/([0-9]+)/$', views.raffle_redraw, name="raffle-redraw"),
url(r'^draw/', views.draw_raffle_ticket, name="raffle-draw"), url(r'^draw/', views.draw_raffle_ticket, name="raffle-draw"),

View file

@ -29,7 +29,12 @@ def draw_raffle_ticket(request, raffle_id=None):
Raffle.objects.get(id=raffle_id).draw(user=request.user) Raffle.objects.get(id=raffle_id).draw(user=request.user)
return HttpResponseRedirect(reverse('raffle-draw')) return HttpResponseRedirect(reverse('raffle-draw'))
raffles = Raffle.objects.prefetch_related('draws', 'prizes') if raffle_id is not None:
raffle = Raffle.objects.prefetch_related('draws', 'prizes').get(
id=raffle_id)
raffles = (raffle,)
else:
raffles = Raffle.objects.prefetch_related('draws', 'prizes')
return render(request, 'raffle_draw.html', {'raffles': raffles}) return render(request, 'raffle_draw.html', {'raffles': raffles})
@ -42,4 +47,3 @@ def raffle_redraw(request, redraw_ticket_id):
prize.remove_winner(user=request.user) prize.remove_winner(user=request.user)
prize.raffle.draw(user=request.user) prize.raffle.draw(user=request.user)
return HttpResponseRedirect(reverse('raffle-draw')) return HttpResponseRedirect(reverse('raffle-draw'))

View file

@ -1,22 +1,31 @@
{% extends "registrasion/base.html" %} {% extends "site_base.html" %}
{% load registrasion_tags %} {% load registrasion_tags %}
{% load lca2018_tags %} {% load lca2018_tags %}
{% load staticfiles %} {% load staticfiles %}
{% block header_title %}{% conference_name %}{% endblock %} {% block head_title %}Raffle Tickets{% endblock %}
{% block page_title %}Raffle Tickets{% endblock %}
{% block proposals_body %} {% block content %}
<h1 class="mb-5">Raffle Tickets</h1> <p>
All of the raffles you are entered into and the tickets you have for each of them.
<p>You can buy more raffle tickets from the <a href="/dashboard">dashboard</a>.</p> If available, you will be able to purchase additional raffle tickets from the <a href="{% url "dashboard" %}">Dashboard</a>.
</p>
<h2>Your Raffle Tickets</h2>
{% for raffle in raffles %} {% for raffle in raffles %}
{% if raffle.tickets %} {% if raffle.tickets %}
<h2 class="mt-5">{{ raffle }}</h2> <h3 class="mt-3">{{ raffle }}</h3>
<ul>
{% for id, numbers in raffle.tickets %} {% for id, numbers in raffle.tickets %}
<h4 class="mt-3"><strong>Ticket {{ id }}</strong></h4> <li>
<p>{% for number in numbers %}{{ number }}{% if not forloop.last %}, {% endif %}{% endfor %}</p> <strong>Ticket {{ id }}</strong>
<p>{% for number in numbers %}{{ number }}{% if not forloop.last %}, {% endif %}{% endfor %}</p>
</li>
{% endfor %} {% endfor %}
</ul>
{% endif %} {% endif %}
{% empty %}
<p>You do not have tickets in any raffles.</p>
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

View file

@ -1,17 +1,16 @@
{% extends "registrasion/base.html" %} {% extends "site_base.html" %}
{% load registrasion_tags %} {% load registrasion_tags %}
{% load lca2018_tags %} {% load lca2018_tags %}
{% load staticfiles %} {% load staticfiles %}
{% block header_title %}{% conference_name %}{% endblock %} {% block head_title %}Raffle Winners{% endblock %}
{% block page_title %}Raffle Winners{% endblock %}
{% block proposals_body %}
<h1 class="mb-5">Raffle Winners</h1>
{% block content %}
{% for raffle in raffles %} {% for raffle in raffles %}
{% if raffle.hidden %} {% if raffle.hidden %}
{% else %} {% else %}
<h2 class="mt-5">{{ raffle }}</h2> <h2 class="mt-3"><a href="{% url "raffle-draw" raffle.id %}">{{ raffle }}</a></h2>
<dl class="row my-4"> <dl class="row my-4">
{% for prize in raffle.prizes.all %} {% for prize in raffle.prizes.all %}
@ -21,7 +20,7 @@
{% with prize.winning_ticket as winner %} {% with prize.winning_ticket as winner %}
{# this should be attendee name #} {# this should be attendee name #}
{% with winner.lineitem.invoice.user.attendee.attendeeprofilebase as profile %} {% with winner.lineitem.invoice.user.attendee.attendeeprofilebase as profile %}
<p><strong>Winning ticket {{ winner.ticket }}, {{ profile.attendee_name }}</strong><br /> <p><strong>Winning ticket {{ winner.ticket }}, <a href="{% url "attendee" winner.lineitem.invoice.user.id %}">{{ profile.attendee_name }}</a></strong><br />
Drawn by {{ winner.draw.drawn_by }}, {{ winner.draw.drawn_time}} Drawn by {{ winner.draw.drawn_by }}, {{ winner.draw.drawn_time}}
</p> </p>
{% endwith %} {% endwith %}
@ -47,9 +46,7 @@
{% if raffle.is_open %} {% if raffle.is_open %}
<form method="POST" action="{% url 'raffle-draw' raffle_id=raffle.id %}"> <form method="POST" action="{% url 'raffle-draw' raffle_id=raffle.id %}">
{% csrf_token %} {% csrf_token %}
<p class="text-center"> <button type="submit" class="btn btn-success">Draw tickets</button>
<button type="submit" class="btn btn-success">Draw tickets</button>
</p>
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
{% endif %} {% endif %}

View file

@ -131,15 +131,13 @@
</div> </div>
{% endif %} {% endif %}
{% if false %} {% flag "raffle_dashboard" %}
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<h4>Raffle Tickets</h4> <h4>Raffle Tickets</h4>
<p><a href="/raffle/tickets/">View all my raffle tickets</a></p> <p><a href="{% url "raffle-tickets" %}">View raffle tickets</a></p>
{# REMOVE HARDCODED CATEGORY NUMBER!!!! #}
<p><a href="/tickets/category/8">Buy raffle tickets</a></p>
</div> </div>
{% endif %} {% endflag %}
{% available_credit as credit %} {% available_credit as credit %}
{% if credit %} {% if credit %}