diff --git a/core/templates/core/markdown_textarea.jinja b/core/templates/core/widgets/markdown_textarea.jinja similarity index 100% rename from core/templates/core/markdown_textarea.jinja rename to core/templates/core/widgets/markdown_textarea.jinja diff --git a/core/templates/core/widgets/nfc.jinja b/core/templates/core/widgets/nfc.jinja new file mode 100644 index 00000000..04dc288d --- /dev/null +++ b/core/templates/core/widgets/nfc.jinja @@ -0,0 +1,33 @@ + + + + + + \ No newline at end of file diff --git a/core/views/forms.py b/core/views/forms.py index 5f950da0..90d24b7a 100644 --- a/core/views/forms.py +++ b/core/views/forms.py @@ -66,7 +66,7 @@ class SelectDate(DateInput): class MarkdownInput(Textarea): - template_name = "core/markdown_textarea.jinja" + template_name = "core/widgets/markdown_textarea.jinja" def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) @@ -100,6 +100,15 @@ class MarkdownInput(Textarea): return context +class NFCTextInput(TextInput): + template_name = "core/widgets/nfc.jinja" + + def get_context(self, name, value, attrs): + context = super().get_context(name, value, attrs) + context["translations"] = {"unsupported": _("Unsupported NFC card")} + return context + + class SelectFile(TextInput): def render(self, name, value, attrs=None, renderer=None): if attrs: diff --git a/counter/forms.py b/counter/forms.py index ce13568f..734cfcf6 100644 --- a/counter/forms.py +++ b/counter/forms.py @@ -3,7 +3,7 @@ from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultip from django import forms from django.utils.translation import gettext_lazy as _ -from core.views.forms import SelectDate, SelectDateTime +from core.views.forms import NFCTextInput, SelectDate, SelectDateTime from counter.models import ( BillingInfo, Counter, @@ -37,6 +37,9 @@ class StudentCardForm(forms.ModelForm): class Meta: model = StudentCard fields = ["uid"] + widgets = { + "uid": NFCTextInput, + } def clean(self): cleaned_data = super().clean() @@ -55,7 +58,10 @@ class GetUserForm(forms.Form): """ code = forms.CharField( - label="Code", max_length=StudentCard.UID_SIZE, required=False + label="Code", + max_length=StudentCard.UID_SIZE, + required=False, + widget=NFCTextInput, ) id = AutoCompleteSelectField( "users", required=False, label=_("Select user"), help_text=None @@ -86,6 +92,14 @@ class GetUserForm(forms.Form): return cleaned_data +class NFCCardForm(forms.Form): + student_card_uid = forms.CharField( + max_length=StudentCard.UID_SIZE, + required=False, + widget=NFCTextInput, + ) + + class RefillForm(forms.ModelForm): error_css_class = "error" required_css_class = "required" diff --git a/counter/templates/counter/counter_click.jinja b/counter/templates/counter/counter_click.jinja index ec018fe8..15de8ac7 100644 --- a/counter/templates/counter/counter_click.jinja +++ b/counter/templates/counter/counter_click.jinja @@ -2,12 +2,12 @@ {% from "core/macros.jinja" import user_mini_profile, user_subscription %} {% block title %} - {{ counter }} + {{ counter }} {% endblock %} {% block additional_js %} - - + + {% endblock %} {% block info_boxes %} @@ -18,180 +18,179 @@ {% endblock %} {% block content %} -
{% trans %}Amount: {% endtrans %}{{ customer.amount }} €
- -{{ student_cards }}
-{% trans %}Amount: {% endtrans %}{{ customer.amount }} €
+ +{% trans %}Basket: {% endtrans %}
+ +{% trans %}Basket: {% endtrans %}
-- Total: - - € -
- - - + : + + € + P+ Total: + + € +
-