diff --git a/calendars/__pycache__/forms.cpython-313.pyc b/calendars/__pycache__/forms.cpython-313.pyc index 8af97fd..7c42813 100644 Binary files a/calendars/__pycache__/forms.cpython-313.pyc and b/calendars/__pycache__/forms.cpython-313.pyc differ diff --git a/calendars/__pycache__/models.cpython-313.pyc b/calendars/__pycache__/models.cpython-313.pyc index e1c44e0..b6336c4 100644 Binary files a/calendars/__pycache__/models.cpython-313.pyc and b/calendars/__pycache__/models.cpython-313.pyc differ diff --git a/calendars/__pycache__/views.cpython-313.pyc b/calendars/__pycache__/views.cpython-313.pyc index a9417b5..432848a 100644 Binary files a/calendars/__pycache__/views.cpython-313.pyc and b/calendars/__pycache__/views.cpython-313.pyc differ diff --git a/calendars/forms.py b/calendars/forms.py index 7150976..790a394 100644 --- a/calendars/forms.py +++ b/calendars/forms.py @@ -19,9 +19,11 @@ class TrainingForm(forms.ModelForm): class GameForm(forms.ModelForm): start_time = forms.DateTimeField(input_formats=['%d.%m.%Y %H:%M', '%Y-%m-%dT%H:%M'], widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M', attrs={'type': 'datetime-local'})) end_time = forms.DateTimeField(input_formats=['%d.%m.%Y %H:%M', '%Y-%m-%dT%H:%M'], widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M', attrs={'type': 'datetime-local'}), required=False) + is_home_game = forms.BooleanField(required=False) + class Meta: model = Game - fields = ['title', 'description', 'start_time', 'end_time', 'location_address', 'team', 'opponent', 'meeting_minutes_before_game', 'season', 'min_players'] + fields = ['title', 'description', 'start_time', 'end_time', 'location_address', 'team', 'opponent', 'meeting_minutes_before_game', 'season', 'min_players', 'is_home_game'] class OpenGameForm(forms.Form): teams = forms.ModelMultipleChoiceField(queryset=Team.objects.none(), widget=forms.CheckboxSelectMultiple) diff --git a/calendars/migrations/0004_game_is_home_game.py b/calendars/migrations/0004_game_is_home_game.py new file mode 100644 index 0000000..ee67b7b --- /dev/null +++ b/calendars/migrations/0004_game_is_home_game.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.6 on 2025-10-02 10:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('calendars', '0003_game_opened_for_teams'), + ] + + operations = [ + migrations.AddField( + model_name='game', + name='is_home_game', + field=models.BooleanField(default=True), + ), + ] diff --git a/calendars/migrations/__pycache__/0004_game_is_home_game.cpython-313.pyc b/calendars/migrations/__pycache__/0004_game_is_home_game.cpython-313.pyc new file mode 100644 index 0000000..7ba8a69 Binary files /dev/null and b/calendars/migrations/__pycache__/0004_game_is_home_game.cpython-313.pyc differ diff --git a/calendars/models.py b/calendars/models.py index a19db7f..16ebcd4 100644 --- a/calendars/models.py +++ b/calendars/models.py @@ -27,6 +27,7 @@ class Game(Event): meeting_minutes_before_game = models.PositiveIntegerField(default=60) season = models.CharField(max_length=255, blank=True) min_players = models.PositiveIntegerField(default=9) + is_home_game = models.BooleanField(default=True) opened_for_teams = models.ManyToManyField('clubs.Team', related_name='opened_games', blank=True) class GameResult(models.Model): diff --git a/calendars/templates/calendars/event_form.html b/calendars/templates/calendars/event_form.html index bf821aa..9ca22e2 100644 --- a/calendars/templates/calendars/event_form.html +++ b/calendars/templates/calendars/event_form.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load l10n %} {% block content %}
@@ -10,11 +11,30 @@
{% csrf_token %} - {{ form.as_p }} + + {% for field in form %} +
+ + {% if object and field.name == 'start_time' %} +

Current: {{ object.start_time|localize }}

+ {% endif %} + {% if object and field.name == 'end_time' %} +

Current: {{ object.end_time|localize }}

+ {% endif %} + {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +
{{ error }}
+ {% endfor %} +
+ {% endfor %} +
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/calendars/views.py b/calendars/views.py index 340192d..e7225ff 100644 --- a/calendars/views.py +++ b/calendars/views.py @@ -70,10 +70,16 @@ class GameCreateView(LoginRequiredMixin, CreateView): class EventUpdateView(LoginRequiredMixin, CoachCheckMixin, UpdateView): model = Event - form_class = EventForm template_name = 'calendars/event_form.html' success_url = reverse_lazy('dashboard') + def get_form_class(self): + if hasattr(self.object, 'game'): + return GameForm + if hasattr(self.object, 'training'): + return TrainingForm + return EventForm + class EventDeleteView(LoginRequiredMixin, CoachCheckMixin, DeleteView): model = Event template_name = 'calendars/event_confirm_delete.html' diff --git a/dashboard/templates/dashboard/dashboard.html b/dashboard/templates/dashboard/dashboard.html index 614caf1..b464f9d 100644 --- a/dashboard/templates/dashboard/dashboard.html +++ b/dashboard/templates/dashboard/dashboard.html @@ -28,7 +28,12 @@ {% endif %} ">
-
{{ item.event.title }}
+
+ {{ item.event.title }} + {% if item.event.game.is_home_game %} + + {% endif %} +
{{ item.event.start_time|localize }}

Team: {{ item.event.team.name }}

@@ -104,7 +109,12 @@ {% endif %} ">
-
{{ item.event.title }}
+
+ {{ item.event.title }} + {% if item.event.game.is_home_game %} + + {% endif %} +
{{ item.event.start_time|localize }}

Team: {{ item.event.team.name }}

diff --git a/db.sqlite3 b/db.sqlite3 index bdf6883..ada3856 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/templates/base.html b/templates/base.html index 121de5b..8278537 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,6 +4,7 @@ Baseball Organisator +