Registration includes regtime, opname and location

This commit is contained in:
Sebastian Lohff 2017-01-28 05:05:21 +01:00
parent 8eccbb5442
commit 58d1e76a0c
5 changed files with 75 additions and 5 deletions

2
TODO
View File

@ -1,6 +1,5 @@
- calculate "claimed points" - calculate "claimed points"
- listviews mit pagination evaluieren - listviews mit pagination evaluieren
- registered datum, name und "genauer standort" für benutzer und shadowbenutzer?
(Partially) Done (Partially) Done
- bootstrap muss gelernt sein (sieht aber noch an vielen stellen crappy aus) - bootstrap muss gelernt sein (sieht aber noch an vielen stellen crappy aus)
@ -26,6 +25,7 @@
- rearrange login index: contest content rüberziehen; exchange registration nach rechts in der nav - rearrange login index: contest content rüberziehen; exchange registration nach rechts in der nav
- cbr parser zum hochladen - cbr parser zum hochladen
- link/funktion um qsos erneut gegeneinander checken zu lassen - link/funktion um qsos erneut gegeneinander checken zu lassen
- registered datum, name und "genauer standort" für benutzer und shadowbenutzer?
Glaube nich, dass ich das mache Glaube nich, dass ich das mache
- call dupe validation könnte ins model wandern - call dupe validation könnte ins model wandern

View File

@ -17,8 +17,12 @@ class CustomUserCreationForm(UserCreationForm):
username = forms.CharField(max_length=50, validators=[CallUsernameValidator()]) username = forms.CharField(max_length=50, validators=[CallUsernameValidator()])
class UpdateRefForm(forms.Form): class UpdateRefForm(forms.Form):
existingRef = forms.ModelChoiceField(label="Existing Reference", queryset=Reference.objects.all(), help_text="If reference already exists, select it here.", required=False) existingRef = forms.ModelChoiceField(label="Existing Exchange", queryset=Reference.objects.all(), help_text="If exchange already exists, select it here.", required=False)
newRefName = forms.CharField(max_length=50, label="New Reference", help_text="Enter name of new ref, if we should create a new", required=False) newRefName = forms.CharField(max_length=50, label="New Exchange", help_text="Enter name of new exchange, if we should create a new", required=False)
location = forms.CharField(max_length=128, label='Exact Location', help_text="E.g. MAR bei den Fahrstuehlen, TEL 15. OG", required=False)
opName = forms.CharField(max_length=128, label='Operators', help_text="Name of operator(s)", required=False)
regTime = forms.DateTimeField(label="Registration time", help_text="Time of Registration")
def clean_newRefName(self): def clean_newRefName(self):
data = self.cleaned_data["newRefName"].strip().upper() data = self.cleaned_data["newRefName"].strip().upper()
@ -34,9 +38,9 @@ class UpdateRefForm(forms.Form):
newRefName = cleaned_data.get("newRefName") newRefName = cleaned_data.get("newRefName")
if existingRef and newRefName: if existingRef and newRefName:
raise forms.ValidationError("Select an existing ref or create a new one, not both!") raise forms.ValidationError("Select an existing exchange or create a new one, not both!")
if not existingRef and not newRefName: if not existingRef and not newRefName:
raise forms.ValidationError("Select either an existing ref or create a new one!") raise forms.ValidationError("Select either an existing exchange or create a new one!")
class UpdateCategoryForm(forms.Form): class UpdateCategoryForm(forms.Form):
entry = forms.ModelChoiceField(label="Entry category", queryset=EntryCategory.objects.all()) entry = forms.ModelChoiceField(label="Entry category", queryset=EntryCategory.objects.all())

View File

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-01-27 18:33
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contest', '0016_auto_20170127_1154'),
]
operations = [
migrations.AddField(
model_name='shadowcall',
name='location',
field=models.CharField(blank=True, default='', max_length=128),
),
migrations.AddField(
model_name='shadowcall',
name='opName',
field=models.CharField(blank=True, default='', max_length=128),
),
migrations.AddField(
model_name='shadowcall',
name='regTime',
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
model_name='user',
name='location',
field=models.CharField(blank=True, default='', max_length=128),
),
migrations.AddField(
model_name='user',
name='opName',
field=models.CharField(blank=True, default='', max_length=128),
),
migrations.AddField(
model_name='user',
name='regTime',
field=models.DateTimeField(default=None, null=True),
),
]

View File

@ -36,6 +36,10 @@ class ShadowCall(models.Model):
username = models.CharField(max_length=20, unique=True, db_index=True, validators=[CallUsernameValidator()]) username = models.CharField(max_length=20, unique=True, db_index=True, validators=[CallUsernameValidator()])
ref = models.ForeignKey(Reference, models.SET_NULL,null=True, blank=True) ref = models.ForeignKey(Reference, models.SET_NULL,null=True, blank=True)
location = models.CharField(max_length=128, default="", blank=True)
opName = models.CharField(max_length=128, default="", blank=True)
regTime = models.DateTimeField(null=True, default=None)
def __str__(self): def __str__(self):
return self.username return self.username
@ -43,6 +47,10 @@ class User(AbstractUser):
ref = models.ForeignKey(Reference, models.SET_NULL, null=True, blank=True) ref = models.ForeignKey(Reference, models.SET_NULL, null=True, blank=True)
cat = models.ForeignKey(EntryCategory, models.SET_NULL, null=True, blank=True) cat = models.ForeignKey(EntryCategory, models.SET_NULL, null=True, blank=True)
location = models.CharField(max_length=128, default="", blank=True)
opName = models.CharField(max_length=128, default="", blank=True)
regTime = models.DateTimeField(null=True, default=None)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(User, self).__init__(*args, **kwargs) super(User, self).__init__(*args, **kwargs)
self._meta.get_field("username").validators = [CallUsernameValidator()] self._meta.get_field("username").validators = [CallUsernameValidator()]

View File

@ -9,6 +9,8 @@ from django.contrib import messages
from django.urls import reverse from django.urls import reverse
from django.contrib.auth import login as auth_login from django.contrib.auth import login as auth_login
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.utils import timezone
import datetime import datetime
@ -184,6 +186,9 @@ def updateRef(request, shadow, uid):
messages.info(request, "New Ref '%s' created" % ref) messages.info(request, "New Ref '%s' created" % ref)
user.ref = ref user.ref = ref
user.regTime = form.cleaned_data["regTime"]
user.location = form.cleaned_data["location"]
user.opName = form.cleaned_data["opName"]
user.save() user.save()
messages.success(request, "%s%s ref set to %s" % ("(shadow) " if shadow else "", user, ref)) messages.success(request, "%s%s ref set to %s" % ("(shadow) " if shadow else "", user, ref))
return HttpResponseRedirect(reverse("contest:registerRefs")) return HttpResponseRedirect(reverse("contest:registerRefs"))
@ -191,6 +196,14 @@ def updateRef(request, shadow, uid):
data = {} data = {}
if user.ref: if user.ref:
data["existingRef"] = user.ref data["existingRef"] = user.ref
if user.regTime:
data["regTime"] = user.regTime
else:
data["regTime"] = timezone.now()
data["opName"] = user.opName
data["location"] = user.location
form = UpdateRefForm(initial=data) form = UpdateRefForm(initial=data)
return render(request, 'contest/updateRef.html', {'userobj': user, 'form': form, "shadow": shadow}) return render(request, 'contest/updateRef.html', {'userobj': user, 'form': form, "shadow": shadow})