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:
parent
ffac4753fc
commit
20083bcb16
5 changed files with 38 additions and 29 deletions
|
@ -3,7 +3,8 @@ from pinaxcon.raffle import views
|
|||
|
||||
|
||||
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/redraw/([0-9]+)/$', views.raffle_redraw, name="raffle-redraw"),
|
||||
url(r'^draw/', views.draw_raffle_ticket, name="raffle-draw"),
|
||||
|
|
|
@ -29,7 +29,12 @@ def draw_raffle_ticket(request, raffle_id=None):
|
|||
Raffle.objects.get(id=raffle_id).draw(user=request.user)
|
||||
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})
|
||||
|
||||
|
||||
|
@ -42,4 +47,3 @@ def raffle_redraw(request, redraw_ticket_id):
|
|||
prize.remove_winner(user=request.user)
|
||||
prize.raffle.draw(user=request.user)
|
||||
return HttpResponseRedirect(reverse('raffle-draw'))
|
||||
|
||||
|
|
|
@ -1,22 +1,31 @@
|
|||
{% extends "registrasion/base.html" %}
|
||||
{% extends "site_base.html" %}
|
||||
{% load registrasion_tags %}
|
||||
{% load lca2018_tags %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block header_title %}{% conference_name %}{% endblock %}
|
||||
{% block head_title %}Raffle Tickets{% endblock %}
|
||||
{% block page_title %}Raffle Tickets{% endblock %}
|
||||
|
||||
{% block proposals_body %}
|
||||
<h1 class="mb-5">Raffle Tickets</h1>
|
||||
|
||||
<p>You can buy more raffle tickets from the <a href="/dashboard">dashboard</a>.</p>
|
||||
{% block content %}
|
||||
<p>
|
||||
All of the raffles you are entered into and the tickets you have for each of them.
|
||||
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 %}
|
||||
{% if raffle.tickets %}
|
||||
<h2 class="mt-5">{{ raffle }}</h2>
|
||||
<h3 class="mt-3">{{ raffle }}</h3>
|
||||
<ul>
|
||||
{% for id, numbers in raffle.tickets %}
|
||||
<h4 class="mt-3"><strong>Ticket {{ id }}</strong></h4>
|
||||
<p>{% for number in numbers %}{{ number }}{% if not forloop.last %}, {% endif %}{% endfor %}</p>
|
||||
<li>
|
||||
<strong>Ticket {{ id }}</strong>
|
||||
<p>{% for number in numbers %}{{ number }}{% if not forloop.last %}, {% endif %}{% endfor %}</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
<p>You do not have tickets in any raffles.</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
{% extends "registrasion/base.html" %}
|
||||
{% extends "site_base.html" %}
|
||||
{% load registrasion_tags %}
|
||||
{% load lca2018_tags %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block header_title %}{% conference_name %}{% endblock %}
|
||||
|
||||
{% block proposals_body %}
|
||||
<h1 class="mb-5">Raffle Winners</h1>
|
||||
{% block head_title %}Raffle Winners{% endblock %}
|
||||
{% block page_title %}Raffle Winners{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% for raffle in raffles %}
|
||||
{% if raffle.hidden %}
|
||||
{% 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">
|
||||
{% for prize in raffle.prizes.all %}
|
||||
|
@ -21,7 +20,7 @@
|
|||
{% with prize.winning_ticket as winner %}
|
||||
{# this should be attendee name #}
|
||||
{% 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}}
|
||||
</p>
|
||||
{% endwith %}
|
||||
|
@ -47,9 +46,7 @@
|
|||
{% if raffle.is_open %}
|
||||
<form method="POST" action="{% url 'raffle-draw' raffle_id=raffle.id %}">
|
||||
{% csrf_token %}
|
||||
<p class="text-center">
|
||||
<button type="submit" class="btn btn-success">Draw tickets</button>
|
||||
</p>
|
||||
<button type="submit" class="btn btn-success">Draw tickets</button>
|
||||
<div class="clearfix"></div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
|
@ -131,15 +131,13 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if false %}
|
||||
{% flag "raffle_dashboard" %}
|
||||
<div class="col-md-6 mb-3">
|
||||
<h4>Raffle Tickets</h4>
|
||||
|
||||
<p><a href="/raffle/tickets/">View all my raffle tickets</a></p>
|
||||
{# REMOVE HARDCODED CATEGORY NUMBER!!!! #}
|
||||
<p><a href="/tickets/category/8">Buy raffle tickets</a></p>
|
||||
<p><a href="{% url "raffle-tickets" %}">View raffle tickets</a></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endflag %}
|
||||
|
||||
{% available_credit as credit %}
|
||||
{% if credit %}
|
||||
|
|
Loading…
Reference in a new issue