diff --git a/accounts/__pycache__/admin.cpython-313.pyc b/accounts/__pycache__/admin.cpython-313.pyc index 3699747..2cf9cb3 100644 Binary files a/accounts/__pycache__/admin.cpython-313.pyc and b/accounts/__pycache__/admin.cpython-313.pyc differ diff --git a/accounts/__pycache__/apps.cpython-313.pyc b/accounts/__pycache__/apps.cpython-313.pyc index 52d3823..16e99c1 100644 Binary files a/accounts/__pycache__/apps.cpython-313.pyc and b/accounts/__pycache__/apps.cpython-313.pyc differ diff --git a/accounts/__pycache__/forms.cpython-313.pyc b/accounts/__pycache__/forms.cpython-313.pyc index 90fb9f6..28b5292 100644 Binary files a/accounts/__pycache__/forms.cpython-313.pyc and b/accounts/__pycache__/forms.cpython-313.pyc differ diff --git a/accounts/__pycache__/models.cpython-313.pyc b/accounts/__pycache__/models.cpython-313.pyc index 41adae9..22c5d9f 100644 Binary files a/accounts/__pycache__/models.cpython-313.pyc and b/accounts/__pycache__/models.cpython-313.pyc differ diff --git a/accounts/__pycache__/signals.cpython-313.pyc b/accounts/__pycache__/signals.cpython-313.pyc new file mode 100644 index 0000000..7f8e323 Binary files /dev/null and b/accounts/__pycache__/signals.cpython-313.pyc differ diff --git a/accounts/__pycache__/urls.cpython-313.pyc b/accounts/__pycache__/urls.cpython-313.pyc index c024d90..be27102 100644 Binary files a/accounts/__pycache__/urls.cpython-313.pyc and b/accounts/__pycache__/urls.cpython-313.pyc differ diff --git a/accounts/__pycache__/views.cpython-313.pyc b/accounts/__pycache__/views.cpython-313.pyc index fc7da10..ee2fd6a 100644 Binary files a/accounts/__pycache__/views.cpython-313.pyc and b/accounts/__pycache__/views.cpython-313.pyc differ diff --git a/accounts/admin.py b/accounts/admin.py index 8c38f3f..9d87a67 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -1,3 +1,13 @@ from django.contrib import admin +from django.contrib.auth.admin import UserAdmin +from .models import CustomUser, AbsencePeriod -# Register your models here. +class CustomUserAdmin(UserAdmin): + model = CustomUser + list_display = ['email', 'username', 'team', 'is_staff'] + fieldsets = UserAdmin.fieldsets + ( + (None, {'fields': ('team',)}), + ) + +admin.site.register(CustomUser, CustomUserAdmin) +admin.site.register(AbsencePeriod) \ No newline at end of file diff --git a/accounts/apps.py b/accounts/apps.py index 3e3c765..4f3f51c 100644 --- a/accounts/apps.py +++ b/accounts/apps.py @@ -1,6 +1,8 @@ from django.apps import AppConfig - class AccountsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'accounts' + + def ready(self): + import accounts.signals \ No newline at end of file diff --git a/accounts/forms.py b/accounts/forms.py index d7ab0e9..6fe6bb7 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -26,3 +26,12 @@ class CustomUserChangeForm(forms.ModelForm): class Meta: model = CustomUser fields = ('username', 'first_name', 'last_name', 'email', 'birth_date', 'player_number', 'team') + +class PlayerCreationForm(forms.ModelForm): + parent1_email = forms.EmailField(required=False) + parent2_email = forms.EmailField(required=False) + birth_date = forms.DateField(input_formats=['%d.%m.%Y'], widget=forms.DateInput(format='%d.%m.%Y')) + + class Meta: + model = CustomUser + fields = ('username', 'first_name', 'last_name', 'email', 'birth_date', 'player_number', 'team') diff --git a/accounts/migrations/0003_absenceperiod.py b/accounts/migrations/0003_absenceperiod.py new file mode 100644 index 0000000..350dabe --- /dev/null +++ b/accounts/migrations/0003_absenceperiod.py @@ -0,0 +1,24 @@ +# Generated by Django 5.2.6 on 2025-10-01 07:05 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0002_customuser_team'), + ] + + operations = [ + migrations.CreateModel( + name='AbsencePeriod', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('start_date', models.DateField()), + ('end_date', models.DateField()), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='absence_periods', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/accounts/migrations/__pycache__/0003_absenceperiod.cpython-313.pyc b/accounts/migrations/__pycache__/0003_absenceperiod.cpython-313.pyc new file mode 100644 index 0000000..be680c5 Binary files /dev/null and b/accounts/migrations/__pycache__/0003_absenceperiod.cpython-313.pyc differ diff --git a/accounts/models.py b/accounts/models.py index 4d87b3a..fad17c1 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -30,4 +30,9 @@ class InvitationCode(models.Model): return True def __str__(self): - return self.code \ No newline at end of file + return self.code + +class AbsencePeriod(models.Model): + user = models.ForeignKey(CustomUser, on_delete=models.CASCADE, related_name='absence_periods') + start_date = models.DateField() + end_date = models.DateField() \ No newline at end of file diff --git a/accounts/signals.py b/accounts/signals.py new file mode 100644 index 0000000..5e9dcc6 --- /dev/null +++ b/accounts/signals.py @@ -0,0 +1,19 @@ +from django.db.models.signals import post_save +from django.dispatch import receiver +from .models import AbsencePeriod +from calendars.models import Event, EventParticipation + +@receiver(post_save, sender=AbsencePeriod) +def handle_absence_period(sender, instance, **kwargs): + user = instance.user + events_in_period = Event.objects.filter( + team=user.team, + start_time__date__gte=instance.start_date, + start_time__date__lte=instance.end_date + ) + for event in events_in_period: + EventParticipation.objects.update_or_create( + user=user, + event=event, + defaults={'status': 'rejected'} + ) diff --git a/accounts/templates/accounts/logout.html b/accounts/templates/accounts/logout.html new file mode 100644 index 0000000..099733f --- /dev/null +++ b/accounts/templates/accounts/logout.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block content %} +
Are you sure you want to log out?
+ +{% endblock %} diff --git a/accounts/templates/accounts/player_form.html b/accounts/templates/accounts/player_form.html new file mode 100644 index 0000000..51c8100 --- /dev/null +++ b/accounts/templates/accounts/player_form.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block content %} +