2
0
Fork 0

Compare commits

..

No commits in common. "23001a3de37d6b41a03f4a384b54578b7cc3b676" and "7b4df14bee4d172624a05198de1d9074f91f0dc3" have entirely different histories.

7 changed files with 4 additions and 64 deletions

View File

@ -26,6 +26,7 @@ class RegisterForm(forms.Form):
name = forms.CharField( name = forms.CharField(
max_length=Helper.name.field.max_length, label="Name", widget=text_input() max_length=Helper.name.field.max_length, label="Name", widget=text_input()
) )
# actually verify phone number, lol
phone = PhoneNumberField( phone = PhoneNumberField(
max_length=Helper.phone.field.max_length, max_length=Helper.phone.field.max_length,
label="Handynummer für Benachrichtigungen", label="Handynummer für Benachrichtigungen",

View File

@ -29,9 +29,9 @@ class FallbackAssignmentInline(admin.TabularInline):
@admin.register(TeamMember) @admin.register(TeamMember)
class TeamMemberAdmin(admin.ModelAdmin): class TeamMemberAdmin(admin.ModelAdmin):
fields = ("id", "name", "comment", "url") fields = ("id", "name", "url")
readonly_fields = ("id", "url") readonly_fields = ("id", "url")
list_display = ("name", "comment", "shift_count") list_display = ("name", "shift_count")
ordering = ("name",) ordering = ("name",)
inlines = (FallbackAssignmentInline,) inlines = (FallbackAssignmentInline,)
actions = (assign_random_shifts, clear_shifts) # , reshuffle_shifts) actions = (assign_random_shifts, clear_shifts) # , reshuffle_shifts)

View File

@ -1,42 +0,0 @@
import sys
from django.core.management.base import BaseCommand, CommandError
from ...models import TeamMember
class Command(BaseCommand):
help = "Import a list of team members, optionally including their affiliations (stored in the comment field)"
def add_arguments(self, parser):
parser.add_argument(
"-d",
"--delimiter",
default=":",
help="character separating name from affiliations",
)
def handle(self, *args, **options):
try:
self._handle(*args, **options)
except KeyboardInterrupt:
self.stderr.write()
except Exception as e:
raise CommandError(e)
def _handle(self, *args, **options):
team_members = []
for line in sys.stdin.readlines():
line = line.strip()
if line == "" or line.startswith("#"):
continue
match line.split(options["delimiter"], maxsplit=1):
case [name, affiliations]:
team_members.append(
TeamMember(name=name, comment=affiliations.strip())
)
case [name]:
team_members.append(TeamMember(name=name))
TeamMember.objects.bulk_create(team_members)

View File

@ -1,18 +0,0 @@
# Generated by Django 5.0.4 on 2024-05-19 21:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("fallback", "0006_fallbackassignment_was_full"),
]
operations = [
migrations.AddField(
model_name="teammember",
name="comment",
field=models.CharField(default="", max_length=100),
),
]

View File

@ -18,7 +18,6 @@ def generate_id():
class TeamMember(models.Model): class TeamMember(models.Model):
id = models.IntegerField(default=generate_id, editable=False, primary_key=True) id = models.IntegerField(default=generate_id, editable=False, primary_key=True)
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
comment = models.CharField(max_length=100, default="")
fallback_shifts = models.ManyToManyField(Shift, through="FallbackAssignment") fallback_shifts = models.ManyToManyField(Shift, through="FallbackAssignment")
def url(self): def url(self):
@ -166,7 +165,7 @@ class TeamMember(models.Model):
assignment.delete() assignment.delete()
def __str__(self): def __str__(self):
return f"{self.name}{f': {self.comment}' if self.comment else ''}" return f"{self.name}"
class FallbackAssignment(models.Model): class FallbackAssignment(models.Model):