Bugfixes : add staticfiles and typo

This commit is contained in:
Ludovic Stephan 2019-01-07 15:27:41 +01:00
parent 519ef9dc20
commit 010ce0df3e
4 changed files with 32 additions and 33 deletions

View file

@ -39,6 +39,36 @@ class TokenForm(forms.Form):
token = forms.CharField(widget=forms.widgets.Textarea())
class TemplateLabelField(forms.ModelMultipleChoiceField):
"""
Extends ModelMultipleChoiceField to offer two more customization options :
- `label_from_instance` can be used with a template file
- the widget rendering template can be specified with `option_template_name`
"""
def __init__(
self,
label_template_name=None,
context_object_name="obj",
option_template_name=None,
*args,
**kwargs
):
super().__init__(*args, **kwargs)
self.label_template_name = label_template_name
self.context_object_name = context_object_name
if option_template_name is not None:
self.widget.option_template_name = option_template_name
def label_from_instance(self, obj):
if self.label_template_name is None:
return super().label_from_instance(obj)
else:
return loader.render_to_string(
self.label_template_name, context={self.context_object_name: obj}
)
class AttributionModelMultipleChoiceField(forms.ModelMultipleChoiceField):
def label_from_instance(self, obj):
return str(obj.spectacle)
@ -107,36 +137,6 @@ class AnnulForm(forms.Form):
)
class TemplateLabelField(forms.ModelMultipleChoiceField):
"""
Extends ModelMultipleChoiceField to offer two more customization options :
- `label_from_instance` can be used with a template file
- the widget rendering template can be specified with `option_template_name`
"""
def __init__(
self,
label_template_name=None,
context_object_name="obj",
option_template_name=None,
*args,
**kwargs
):
super().__init__(*args, **kwargs)
self.label_template_name = label_template_name
self.context_object_name = context_object_name
if option_template_name is not None:
self.widget.option_template_name = option_template_name
def label_from_instance(self, obj):
if self.label_template_name is None:
return super().label_from_instance(obj)
else:
return loader.render_to_string(
self.label_template_name, context={self.context_object_name: obj}
)
class InscriptionReventeForm(forms.Form):
def __init__(self, tirage, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -194,7 +194,7 @@ class ReventeTirageForm(forms.Form):
class SoldForm(forms.Form):
def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["reventes"].queryset = ReventeModelMultipleChoiceField(
self.fields["reventes"] = ReventeModelMultipleChoiceField(
own=True,
label="",
queryset=participant.original_shows.filter(soldTo__isnull=False)

View file

@ -1,5 +1,6 @@
{% extends "base_title.html" %}
{% load bootstrap %}
{% load staticfiles %}
{% block realcontent %}

View file

@ -42,7 +42,6 @@
value="S'inscrire pour les places sélectionnées">
</form>
<script type="text/javascript" src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
<script language="JavaScript">
function select(check) {
checkboxes = document.getElementsByName("spectacles");

View file

@ -81,7 +81,6 @@
</div>
{% endif %}
<script type="text/javascript" src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
<script language="JavaScript">
$(function(){
$("table.stupidtable").stupidtable();