diff --git a/contest/forms.py b/contest/forms.py index 862fe9c..0cc4965 100644 --- a/contest/forms.py +++ b/contest/forms.py @@ -42,18 +42,6 @@ class QSOForm(forms.ModelForm): model = QSO fields = ["ownNo", "band", "call", "reportTX", "reportRX", "otherNo", "refStr", "remarks"] - widgets = { - "time": forms.DateTimeInput(attrs={"placeholder": "Current time"}) - } - - labels = { - 'ownNo': 'Nr-S', - 'reportTX': 'RST-S', - 'reportRX': 'RST-R', - 'otherNo': 'Nr-R', - 'refStr': 'EXC', - } - def __init__(self, user, *args, **kwargs): super(QSOForm, self).__init__(*args, **kwargs) self.user = user @@ -105,3 +93,9 @@ class QSOForm(forms.ModelForm): def clean_refStr(self): return self.cleaned_data["refStr"].upper() + +class QSOFormWithTime(QSOForm): + class Meta: + model = QSO + fields = ["time", "ownNo", "band", "call", "reportTX", "reportRX", "otherNo", "refStr", "remarks"] + diff --git a/contest/models.py b/contest/models.py index bb7abe9..534859a 100644 --- a/contest/models.py +++ b/contest/models.py @@ -52,13 +52,13 @@ class QSO(models.Model): call = models.CharField(max_length=20) band = models.ForeignKey(Band) - reportTX = models.CharField(max_length=7, default=59) - reportRX = models.CharField(max_length=7, default=59) + reportTX = models.CharField(max_length=7, default=59, verbose_name='RST-S') + reportRX = models.CharField(max_length=7, default=59, verbose_name='RST-R') - ownNo = models.IntegerField() - otherNo = models.IntegerField() + ownNo = models.IntegerField(verbose_name='Nr-S') + otherNo = models.IntegerField(verbose_name='Nr-R') - refStr = models.CharField(max_length=20) + refStr = models.CharField(max_length=20, verbose_name="Exc") ref = models.ForeignKey(Reference, null=True, blank=True) remarks = models.CharField(max_length=50, blank=True) diff --git a/contest/views.py b/contest/views.py index ca3b1ef..cdcefe6 100644 --- a/contest/views.py +++ b/contest/views.py @@ -11,7 +11,7 @@ from django.urls import reverse import datetime from .models import User, Contest, Frequency, Reference, QSO -from .forms import UpdateRefForm, QSOForm +from .forms import UpdateRefForm, QSOForm, QSOFormWithTime def index(request): if request.user.is_authenticated(): @@ -72,14 +72,14 @@ def logEdit(request, qsoid): form = None if request.method == 'POST': - form = QSOForm(user=request.user, instance=qso, data=request.POST) + form = QSOFormWithTime(user=request.user, instance=qso, data=request.POST) if form.is_valid(): form.instance.save() messages.info(request, "QSO has been edited") return HttpResponseRedirect(reverse("contest:log")) else: - form = QSOForm(user=request.user, instance=qso) + form = QSOFormWithTime(user=request.user, instance=qso) return render(request, 'contest/logEdit.html', {'form': form, "qso": qso}) diff --git a/templates/contest/logEdit.html b/templates/contest/logEdit.html index cd3db09..c9ecf84 100644 --- a/templates/contest/logEdit.html +++ b/templates/contest/logEdit.html @@ -1,20 +1,20 @@ {% extends "base.html" %} +{% load crispy_forms_tags %} + {% block content %}
- We have the User {{ user }}, create a ref for them or choose an existing ref! - -
- {% csrf_token %} - - - - - {{ form.as_table }} -
User{{ user }}
- -
+
+
Edit QSO
+
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+
{% endblock %} diff --git a/templates/contest/updateRef.html b/templates/contest/updateRef.html index 0ec5871..8dc0859 100644 --- a/templates/contest/updateRef.html +++ b/templates/contest/updateRef.html @@ -1,20 +1,28 @@ {% extends "base.html" %} +{% load crispy_forms_tags %} + {% block content %}
- We have the User {{ user }}, create a ref for them or choose an existing ref! +
+
Edit Exchange for User
+
+

+ Create a ref for user {{ user }} or choose an existing ref! +

-
- {% csrf_token %} - - - - - {{ form.as_table }} -
User{{ user }}
- -
+
+ {% csrf_token %} +
+ +
{{ user }}
+
+ {{ form|crispy }} + +
+
+