diff --git a/kos/templates/kos/change_profile.html b/kos/templates/kos/change_profile.html
index 6378691..c25474f 100644
--- a/kos/templates/kos/change_profile.html
+++ b/kos/templates/kos/change_profile.html
@@ -17,4 +17,15 @@
Zmena údajov tímu
{% else %}
Platbu za súťaž zatiaľ neevidujeme.
{% endif %}
+
+
{% endblock %}
\ No newline at end of file
diff --git a/kos/views.py b/kos/views.py
index 0e781d8..4e981e7 100644
--- a/kos/views.py
+++ b/kos/views.py
@@ -420,25 +420,31 @@ def get_context_data(self, **kwargs):
context['paid'] = (
team.paid if hasattr(team, 'paid') else False
)
- context['disabled'] = team.game.year.registration_deadline < now()
+ context['disabled'] = not team.editable
return context
def post(self, request, *args, **kwargs):
team = self.get_team()
if team is None:
return redirect('kos:game')
- if team.game.year.registration_deadline < now():
+ if not team.editable:
messages.error(
request, 'Tieto údaje nie je možné meniť po skončení registrácie')
return redirect('kos:change-profile')
+ # TODO: Check that the team did not change their is_online
+ # status after the registration deadline. Currently this
+ # is only disabled on frontend but can be bypassed.
return super().post(request, *args, **kwargs)
def get_form(self, form_class=None):
form = super().get_form(form_class)
team = self.get_team()
- if team.game.year.registration_deadline < now():
+ if not team.editable:
for field in form.fields.values():
field.widget.attrs['disabled'] = True
+ # Po konci registracie uz nechceme timu dovolit menit ci je online
+ if team.game.year.registration_deadline < now():
+ form.fields['is_online'].widget.attrs['disabled'] = True
return form
def form_valid(self, form):