Compare commits
No commits in common. "23001a3de37d6b41a03f4a384b54578b7cc3b676" and "7b4df14bee4d172624a05198de1d9074f91f0dc3" have entirely different histories.
23001a3de3
...
7b4df14bee
|
@ -26,6 +26,7 @@ class RegisterForm(forms.Form):
|
|||
name = forms.CharField(
|
||||
max_length=Helper.name.field.max_length, label="Name", widget=text_input()
|
||||
)
|
||||
# actually verify phone number, lol
|
||||
phone = PhoneNumberField(
|
||||
max_length=Helper.phone.field.max_length,
|
||||
label="Handynummer für Benachrichtigungen",
|
||||
|
|
|
@ -29,9 +29,9 @@ class FallbackAssignmentInline(admin.TabularInline):
|
|||
|
||||
@admin.register(TeamMember)
|
||||
class TeamMemberAdmin(admin.ModelAdmin):
|
||||
fields = ("id", "name", "comment", "url")
|
||||
fields = ("id", "name", "url")
|
||||
readonly_fields = ("id", "url")
|
||||
list_display = ("name", "comment", "shift_count")
|
||||
list_display = ("name", "shift_count")
|
||||
ordering = ("name",)
|
||||
inlines = (FallbackAssignmentInline,)
|
||||
actions = (assign_random_shifts, clear_shifts) # , reshuffle_shifts)
|
||||
|
|
|
@ -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)
|
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -18,7 +18,6 @@ def generate_id():
|
|||
class TeamMember(models.Model):
|
||||
id = models.IntegerField(default=generate_id, editable=False, primary_key=True)
|
||||
name = models.CharField(max_length=100)
|
||||
comment = models.CharField(max_length=100, default="")
|
||||
fallback_shifts = models.ManyToManyField(Shift, through="FallbackAssignment")
|
||||
|
||||
def url(self):
|
||||
|
@ -166,7 +165,7 @@ class TeamMember(models.Model):
|
|||
assignment.delete()
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}{f': {self.comment}' if self.comment else ''}"
|
||||
return f"{self.name}"
|
||||
|
||||
|
||||
class FallbackAssignment(models.Model):
|
||||
|
|
Loading…
Reference in New Issue