forked from DGNum/gestioCOF
Merge remote-tracking branch 'origin/master' into Aufinal/change_shotgun
This commit is contained in:
commit
b15dc6d9dc
7 changed files with 70 additions and 18 deletions
|
@ -219,10 +219,10 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
||||||
list_display = ("spectacle", "seller", "date", "soldTo")
|
list_display = ("spectacle", "seller", "date", "soldTo")
|
||||||
raw_id_fields = ("attribution",)
|
raw_id_fields = ("attribution",)
|
||||||
readonly_fields = ("expiration_time",)
|
readonly_fields = ("expiration_time",)
|
||||||
search_fields = ("spectacle__title",
|
search_fields = ['attribution__spectacle__title',
|
||||||
"seller__user__username",
|
'seller__user__username',
|
||||||
"seller__user__firstname",
|
'seller__user__first_name',
|
||||||
"seller__user__lastname",)
|
'seller__user__last_name']
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(CategorieSpectacle)
|
admin.site.register(CategorieSpectacle)
|
||||||
|
|
|
@ -254,7 +254,7 @@ class SpectacleRevente(models.Model):
|
||||||
def expiration_time_str(self):
|
def expiration_time_str(self):
|
||||||
return self.expiration_time \
|
return self.expiration_time \
|
||||||
.astimezone(timezone.get_current_timezone()) \
|
.astimezone(timezone.get_current_timezone()) \
|
||||||
.strftime('%D à %H:%M')
|
.strftime('%d/%m/%y à %H:%M')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s -- %s" % (self.seller,
|
return "%s -- %s" % (self.seller,
|
||||||
|
|
14
bda/templates/bda-shotgun.html
Normal file
14
bda/templates/bda-shotgun.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends "base_title.html" %}
|
||||||
|
|
||||||
|
{% block realcontent %}
|
||||||
|
<h2>Places disponibles immédiatement</h2>
|
||||||
|
{% if shotgun %}
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
{% for spectacle in shotgun %}
|
||||||
|
<li><a href="{% url "bda-buy-revente" spectacle.id %}">{{spectacle}}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<p> Pas de places disponibles immédiatement, désolé !</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -11,16 +11,29 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form action="" class="form-horizontal" method="post">
|
<form action="" class="form-horizontal" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{form | bootstrap}}
|
<div class="form-group">
|
||||||
|
<h3>Spectacles</h3>
|
||||||
|
<br/>
|
||||||
|
<button type="button" class="btn btn-primary" onClick="select(true)">Tout sélectionner</button>
|
||||||
|
<button type="button" class="btn btn-primary" onClick="select(false)">Tout désélectionner</button>
|
||||||
|
|
||||||
|
<div class="multiple-checkbox">
|
||||||
|
<ul>
|
||||||
|
{% for checkbox in form.spectacles %}
|
||||||
|
<li>{{checkbox}}</li>
|
||||||
|
{%endfor%}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<input type="submit" class="btn btn-primary" value="S'inscrire pour les places sélectionnées">
|
<input type="submit" class="btn btn-primary" value="S'inscrire pour les places sélectionnées">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% if shotgun %}
|
<script language="JavaScript">
|
||||||
<br>
|
function select(check) {
|
||||||
<h3>Places disponibles immédiatement</h3>
|
checkboxes = document.getElementsByName("spectacles");
|
||||||
<ul class="list-unstyled">
|
for(var i=0, n=checkboxes.length;i<n;i++) {
|
||||||
{% for spectacle in shotgun %}
|
checkboxes[i].checked = check;
|
||||||
<li><a href="{% url "bda-buy-revente" spectacle.id %}">{{spectacle}}</a></li>
|
}
|
||||||
{% endfor %}
|
}
|
||||||
{% endif %}
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -33,14 +33,17 @@ urlpatterns = [
|
||||||
views.unpaid,
|
views.unpaid,
|
||||||
name="bda-unpaid"),
|
name="bda-unpaid"),
|
||||||
url(r'^liste-revente/(?P<tirage_id>\d+)$',
|
url(r'^liste-revente/(?P<tirage_id>\d+)$',
|
||||||
"bda.views.list_revente",
|
views.list_revente,
|
||||||
name="bda-liste-revente"),
|
name="bda-liste-revente"),
|
||||||
url(r'^buy-revente/(?P<spectacle_id>\d+)$',
|
url(r'^buy-revente/(?P<spectacle_id>\d+)$',
|
||||||
"bda.views.buy_revente",
|
views.buy_revente,
|
||||||
name="bda-buy-revente"),
|
name="bda-buy-revente"),
|
||||||
url(r'^revente-interested/(?P<revente_id>\d+)$',
|
url(r'^revente-interested/(?P<revente_id>\d+)$',
|
||||||
"bda.views.revente_interested",
|
views.revente_interested,
|
||||||
name='bda-revente-interested'),
|
name='bda-revente-interested'),
|
||||||
|
url(r'^revente-immediat/(?P<tirage_id>\d+)$',
|
||||||
|
views.revente_shotgun,
|
||||||
|
name="bda-shotgun"),
|
||||||
url(r'^mails-rappel/(?P<spectacle_id>\d+)$', views.send_rappel),
|
url(r'^mails-rappel/(?P<spectacle_id>\d+)$', views.send_rappel),
|
||||||
url(r'^descriptions/(?P<tirage_id>\d+)$', views.descriptions_spectacles,
|
url(r'^descriptions/(?P<tirage_id>\d+)$', views.descriptions_spectacles,
|
||||||
name='bda-descriptions'),
|
name='bda-descriptions'),
|
||||||
|
|
23
bda/views.py
23
bda/views.py
|
@ -435,7 +435,7 @@ def buy_revente(request, spectacle_id):
|
||||||
if reventes.filter(seller=participant).exists():
|
if reventes.filter(seller=participant).exists():
|
||||||
revente = reventes.filter(seller=participant)[0]
|
revente = reventes.filter(seller=participant)[0]
|
||||||
revente.delete()
|
revente.delete()
|
||||||
return HttpResponseRedirect(reverse("bda-liste-revente",
|
return HttpResponseRedirect(reverse("bda-shotgun",
|
||||||
args=[tirage.id]))
|
args=[tirage.id]))
|
||||||
reventes_shotgun = reventes.filter(shotgun=True)
|
reventes_shotgun = reventes.filter(shotgun=True)
|
||||||
|
|
||||||
|
@ -467,6 +467,27 @@ Contacte-moi si tu es toujours intéressé·e !
|
||||||
"user": request.user})
|
"user": request.user})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def revente_shotgun(request, tirage_id):
|
||||||
|
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||||
|
spectacles = tirage.spectacle_set.filter(
|
||||||
|
date__gte=timezone.now())
|
||||||
|
shotgun = []
|
||||||
|
for spectacle in spectacles:
|
||||||
|
revente_objects = SpectacleRevente.objects.filter(
|
||||||
|
attribution__spectacle=spectacle,
|
||||||
|
soldTo__isnull=True)
|
||||||
|
revente_count = 0
|
||||||
|
for revente in revente_objects:
|
||||||
|
if revente.shotgun:
|
||||||
|
revente_count += 1
|
||||||
|
if revente_count:
|
||||||
|
shotgun.append(spectacle)
|
||||||
|
|
||||||
|
return render(request, "bda-shotgun.html",
|
||||||
|
{"shotgun": shotgun})
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def spectacle(request, tirage_id, spectacle_id):
|
def spectacle(request, tirage_id, spectacle_id):
|
||||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
<li><a href="{% url "bda-places-attribuees" tirage.id %}">Mes places</a></li>
|
<li><a href="{% url "bda-places-attribuees" tirage.id %}">Mes places</a></li>
|
||||||
<li><a href="{% url "bda-revente" tirage.id %}">Revendre une place</a></li>
|
<li><a href="{% url "bda-revente" tirage.id %}">Revendre une place</a></li>
|
||||||
<li><a href="{% url "bda-liste-revente" tirage.id %}">S'inscrire à BdA-Revente</a></li>
|
<li><a href="{% url "bda-liste-revente" tirage.id %}">S'inscrire à BdA-Revente</a></li>
|
||||||
|
<li><a href="{% url "bda-shotgun" tirage.id %}">Places disponibles immédiatement</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue