diff --git a/club/forms.py b/club/forms.py
index 76d13e2c..c358e401 100644
--- a/club/forms.py
+++ b/club/forms.py
@@ -34,13 +34,20 @@ from counter.models import Counter
class ClubEditForm(forms.ModelForm):
+ error_css_class = "error"
+ required_css_class = "required"
+
class Meta:
model = Club
fields = ["address", "logo", "short_description"]
+ widgets = {"short_description": forms.Textarea()}
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.fields["short_description"].widget = forms.Textarea()
+
+class ClubAdminEditForm(ClubEditForm):
+ admin_fields = ["name", "parent", "is_active"]
+
+ class Meta(ClubEditForm.Meta):
+ fields = ["name", "parent", "is_active", *ClubEditForm.Meta.fields]
class MailingForm(forms.Form):
diff --git a/club/templates/club/edit_club.jinja b/club/templates/club/edit_club.jinja
new file mode 100644
index 00000000..2964fb64
--- /dev/null
+++ b/club/templates/club/edit_club.jinja
@@ -0,0 +1,54 @@
+{% extends "core/base.jinja" %}
+
+{% block title %}
+ {% trans name=object %}Edit {{ name }}{% endtrans %}
+{% endblock %}
+
+{% block content %}
+
{% trans name=object %}Edit {{ name }}{% endtrans %}
+
+
+{% endblock content %}
diff --git a/club/urls.py b/club/urls.py
index 5dcd492a..664d93a6 100644
--- a/club/urls.py
+++ b/club/urls.py
@@ -26,7 +26,6 @@ from django.urls import path
from club.views import (
ClubCreateView,
- ClubEditPropView,
ClubEditView,
ClubListView,
ClubMailingView,
@@ -70,7 +69,6 @@ urlpatterns = [
path(
"/sellings/csv/", ClubSellingCSVView.as_view(), name="sellings_csv"
),
- path("/prop/", ClubEditPropView.as_view(), name="club_prop"),
path("/tools/", ClubToolsView.as_view(), name="tools"),
path("/mailing/", ClubMailingView.as_view(), name="mailing"),
path(
diff --git a/club/views.py b/club/views.py
index e03df328..0c32cfad 100644
--- a/club/views.py
+++ b/club/views.py
@@ -56,12 +56,7 @@ from com.views import (
PosterEditBaseView,
PosterListBaseView,
)
-from core.auth.mixins import (
- CanCreateMixin,
- CanEditMixin,
- CanEditPropMixin,
- CanViewMixin,
-)
+from core.auth.mixins import CanCreateMixin, CanEditMixin, CanViewMixin
from core.models import PageRev
from core.views import DetailFormView, PageEditViewBase
from core.views.mixins import TabedViewMixin
@@ -113,21 +108,23 @@ class ClubTabsMixin(TabedViewMixin):
}
)
if self.request.user.can_edit(self.object):
- tab_list.append(
- {
- "url": reverse("club:tools", kwargs={"club_id": self.object.id}),
- "slug": "tools",
- "name": _("Tools"),
- }
- )
- tab_list.append(
- {
- "url": reverse(
- "club:club_edit", kwargs={"club_id": self.object.id}
- ),
- "slug": "edit",
- "name": _("Edit"),
- }
+ tab_list.extend(
+ [
+ {
+ "url": reverse(
+ "club:tools", kwargs={"club_id": self.object.id}
+ ),
+ "slug": "tools",
+ "name": _("Tools"),
+ },
+ {
+ "url": reverse(
+ "club:club_edit", kwargs={"club_id": self.object.id}
+ ),
+ "slug": "edit",
+ "name": _("Edit"),
+ },
+ ]
)
if self.object.page and self.request.user.can_edit(self.object.page):
tab_list.append(
@@ -165,16 +162,6 @@ class ClubTabsMixin(TabedViewMixin):
},
]
)
- if self.request.user.is_owner(self.object):
- tab_list.append(
- {
- "url": reverse(
- "club:club_prop", kwargs={"club_id": self.object.id}
- ),
- "slug": "props",
- "name": _("Props"),
- }
- )
return tab_list
@@ -461,23 +448,23 @@ class ClubSellingCSVView(ClubSellingView):
class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView):
- """Edit a Club's main informations (for the club's members)."""
+ """Edit a Club.
+
+ Regular club board members will be able to edit the main infos
+ (like the logo and the description).
+ Admins will also be able to edit the club properties
+ (like the name and the parent club).
+ """
model = Club
pk_url_kwarg = "club_id"
- form_class = ClubEditForm
- template_name = "core/edit.jinja"
+ template_name = "club/edit_club.jinja"
current_tab = "edit"
-
-class ClubEditPropView(ClubTabsMixin, CanEditPropMixin, UpdateView):
- """Edit the properties of a Club object (for the Sith admins)."""
-
- model = Club
- pk_url_kwarg = "club_id"
- fields = ["name", "parent", "is_active"]
- template_name = "core/edit.jinja"
- current_tab = "props"
+ def get_form_class(self):
+ if self.object.is_owned_by(self.request.user):
+ return ClubAdminEditForm
+ return ClubEditForm
class ClubCreateView(PermissionRequiredMixin, CreateView):
diff --git a/galaxy/management/commands/generate_galaxy_test_data.py b/galaxy/management/commands/generate_galaxy_test_data.py
index ada43a36..2f800db0 100644
--- a/galaxy/management/commands/generate_galaxy_test_data.py
+++ b/galaxy/management/commands/generate_galaxy_test_data.py
@@ -130,8 +130,7 @@ class Command(BaseCommand):
self.clubs = Club.objects.bulk_create(
[
Club(
- unix_name=f"galaxy-club-{i}",
- name=f"club-{i}",
+ name=f"galaxy-club-{i}",
board_group=Group.objects.create(name=f"board {i}"),
members_group=Group.objects.create(name=f"members {i}"),
)