diff --git a/apps/member/tables.py b/apps/member/tables.py index a6de17d2..d0c37a6e 100644 --- a/apps/member/tables.py +++ b/apps/member/tables.py @@ -17,6 +17,7 @@ class ClubTable(tables.Table): fields = ('id', 'name', 'email') row_attrs = { 'class': 'table-row', + 'id': lambda record: "row-" + str(record.pk), 'data-href': lambda record: record.pk } diff --git a/apps/member/urls.py b/apps/member/urls.py index d9dfd181..bc536f60 100644 --- a/apps/member/urls.py +++ b/apps/member/urls.py @@ -12,6 +12,8 @@ urlpatterns = [ path('club//', views.ClubDetailView.as_view(), name="club_detail"), path('club//add_member/', views.ClubAddMemberView.as_view(), name="club_add_member"), path('club/create/', views.ClubCreateView.as_view(), name="club_create"), + path('club//update', views.ClubUpdateView.as_view(), name="club_update"), + path('club//update_pic', views.ClubPictureUpdateView.as_view(), name="club_update_pic"), path('user/', views.UserListView.as_view(), name="user_list"), path('user/', views.UserDetailView.as_view(), name="user_detail"), path('user//update', views.UserUpdateView.as_view(), name="user_update_profile"), diff --git a/apps/member/views.py b/apps/member/views.py index 0ba76d6a..9e88ae02 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -223,10 +223,7 @@ class DeleteAliasView(LoginRequiredMixin, DeleteView): return self.post(request, *args, **kwargs) -class ProfilePictureUpdateView(LoginRequiredMixin, FormMixin, DetailView): - model = User - template_name = 'member/profile_picture_update.html' - context_object_name = 'user_object' +class PictureUpdateView(LoginRequiredMixin, FormMixin, DetailView): form_class = ImageForm def get_context_data(self, *args, **kwargs): @@ -272,6 +269,10 @@ class ProfilePictureUpdateView(LoginRequiredMixin, FormMixin, DetailView): self.object.note.save() return super().form_valid(form) +class ProfilePictureUpdateView(PictureUpdateView): + model = User + template_name = 'member/profile_picture_update.html' + context_object_name = 'user_object' class ManageAuthTokens(LoginRequiredMixin, TemplateView): """ @@ -329,10 +330,11 @@ class ClubCreateView(LoginRequiredMixin, CreateView): """ model = Club form_class = ClubForm - + success_url = reverse_lazy('member:club_list') + def form_valid(self, form): return super().form_valid(form) - + class ClubListView(LoginRequiredMixin, SingleTableView): """ @@ -364,6 +366,23 @@ class ClubDetailView(LoginRequiredMixin, DetailView): context['member_list'] = club_member return context + +class ClubUpdateView(LoginRequiredMixin, UpdateView): + model = Club + context_object_name = "club" + form_class = ClubForm + template_name = "member/club_form.html" + success_url = reverse_lazy("member:club_detail") + + +class ClubPictureUpdateView(PictureUpdateView): + model = Club + template_name = 'member/club_picture_update.html' + context_object_name = 'club' + + def get_success_url(self): + return reverse_lazy('member:club_detail', kwargs={'pk': self.object.id}) + class ClubAddMemberView(LoginRequiredMixin, CreateView): model = Membership diff --git a/templates/member/club_detail.html b/templates/member/club_detail.html index 38f87812..979c0897 100644 --- a/templates/member/club_detail.html +++ b/templates/member/club_detail.html @@ -1,62 +1,9 @@ -{% extends "base.html" %} -{% load static %} -{% load i18n %} -{% load render_table from django_tables2 %} -{% load pretty_money %} -{% block content %} -

Clubs

-

Club {{ object.name }}

-
-
{% trans 'Membership starts on' %}
-
{{ club.membership_start }}
-
{% trans 'Membership ends on' %}
-
{{ club.membership_end }}
-
{% trans 'Membership duration' %}
-
{{ club.membership_duration }}
-
Aliases
-
{{ club.note.aliases_set.all }}
-
{% trans 'balance' %}
-
{{ club.note.balance | pretty_money }}
+{% extends "member/noteowner_detail.html" %} -
+{% block profile_info %} +{% include "member/club_info.html" %} +{% endblock %} - - - -
-
-
-
- -
-
- -
-
- - {% render_table member_list %} -
-
-
-
-
-
- -
-
-
-
- {% render_table history_list %} -
-
-
-
- {% endblock %} +{% block profile_content %} +{% include "member/club_tables.html" %} +{% endblock %} diff --git a/templates/member/club_form.html b/templates/member/club_form.html index 577297bb..99c254e3 100644 --- a/templates/member/club_form.html +++ b/templates/member/club_form.html @@ -3,7 +3,6 @@ {% load i18n %} {% load crispy_forms_tags %} {% block content %} -

{% trans "Clubs list" %}

{% csrf_token %} {{form|crispy}} diff --git a/templates/member/club_info.html b/templates/member/club_info.html new file mode 100644 index 00000000..a88527fc --- /dev/null +++ b/templates/member/club_info.html @@ -0,0 +1,32 @@ +{% load i18n static pretty_money %} +
+
+ + + +
+
+
+
{% trans 'name'|capfirst %}
+
{{ club.name}}
+ +
{% trans 'membership start'|capfirst %}
+
{{ club.membership_start }}
+ +
{% trans 'membership end'|capfirst %}
+
{{ club.membership_end }}
+ +
{% trans 'membership duration'|capfirst %}
+
{{ club.membership_duration }}
+ +
{% trans 'membership fee'|capfirst %}
+
{{ club.membership_fee|pretty_money }}
+ +
{% trans 'aliases'|capfirst %}
+
{{ object.note.alias_set.all|join:", " }}
+ +
{% trans 'email'|capfirst %}
+
{{ club.email}}
+
+
+
diff --git a/templates/member/club_list.html b/templates/member/club_list.html index 16571113..7f0b02a1 100644 --- a/templates/member/club_list.html +++ b/templates/member/club_list.html @@ -2,15 +2,65 @@ {% load render_table from django_tables2 %} {% load i18n %} {% block content %} - -{% render_table table %} - -{% trans "New club" %} +
+
+

+ {% trans "search clubs" %} +

+ +
+ {% trans "Créer un club" %} +
+
+
+
+
+
+
{% trans "club listing "%}
+
+
+ {% render_table table %} +
+
+
+
{% endblock %} {% block extrajavascript %} +{% endblock %} diff --git a/templates/member/picture_update.html b/templates/member/picture_update.html new file mode 100644 index 00000000..f0c43e47 --- /dev/null +++ b/templates/member/picture_update.html @@ -0,0 +1,95 @@ +{% load i18n crispy_forms_tags %} +{% block profile_content %} +
+ + {% csrf_token %} + {{ form |crispy }} + +
+ + +{% endblock %} +{% block extracss %} + +{% endblock %} + +{% block extrajavascript%} + + + +{% endblock %} diff --git a/templates/member/profile_detail.html b/templates/member/profile_detail.html index 31510acf..42d03d8b 100644 --- a/templates/member/profile_detail.html +++ b/templates/member/profile_detail.html @@ -1,97 +1,9 @@ -{% extends "base.html" %} -{% load i18n static pretty_money django_tables2 %} +{% extends "member/noteowner_detail.html" %} -{% block content %} -
-
-
-
- - - -
-
-
-
{% trans 'name'|capfirst %}, {% trans 'first name' %}
-
{{ object.last_name }} {{ object.first_name }}
- -
{% trans 'username'|capfirst %}
-
{{ object.username }}
- -
{% trans 'password'|capfirst %}
-
- - {% trans 'Change password' %} - -
- -
{% trans 'section'|capfirst %}
-
{{ object.profile.section }}
- -
{% trans 'address'|capfirst %}
-
{{ object.profile.address }}
- -
{% trans 'balance'|capfirst %}
-
{{ object.note.balance | pretty_money }}
- -
{% trans 'aliases'|capfirst %}
-
{{ object.note.alias_set.all|join:", " }}
-
- - {% if object.pk == user.pk %} - {% trans 'Manage auth token' %} - {% endif %} -
- -
-
-
- {% block profile_content %} -
-
- -
- {% render_table club_list %} -
-
- -
- -
-
- {% render_table history_list %} -
-
-
-
- {% endblock %} -
-
+{% block profile_info %} +{% include "member/profile_info.html" %} {% endblock %} -{% block extrajavascript %} - +{% block profile_content %} +{% include "member/profile_tables.html" %} {% endblock %} diff --git a/templates/member/profile_info.html b/templates/member/profile_info.html new file mode 100644 index 00000000..30383866 --- /dev/null +++ b/templates/member/profile_info.html @@ -0,0 +1,48 @@ +{% load i18n static pretty_money %} + +
+
+ + + +
+
+
+
{% trans 'name'|capfirst %}, {% trans 'first name' %}
+
{{ object.last_name }} {{ object.first_name }}
+ +
{% trans 'username'|capfirst %}
+
{{ object.username }}
+ +
{% trans 'password'|capfirst %}
+
+ + {% trans 'Change password' %} + +
+ +
{% trans 'section'|capfirst %}
+
{{ object.profile.section }}
+ +
{% trans 'address'|capfirst %}
+
{{ object.profile.address }}
+ +
{% trans 'balance'|capfirst %}
+
{{ object.note.balance | pretty_money }}
+ +
{% trans 'aliases'|capfirst %}
+
{{ object.note.alias_set.all|join:", " }}
+
+ + {% if object.pk == user.pk %} + {% trans 'Manage auth token' %} + {% endif %} +
+ +
diff --git a/templates/member/profile_picture_update.html b/templates/member/profile_picture_update.html index 36e53dcd..db7c5767 100644 --- a/templates/member/profile_picture_update.html +++ b/templates/member/profile_picture_update.html @@ -1,97 +1,10 @@ -{% extends "member/profile_detail.html" %} +{% extends "member/noteowner_detail.html" %} {% load i18n static pretty_money django_tables2 crispy_forms_tags %} -{% block profile_content %} -
-
- {% csrf_token %} - {{ form |crispy }} -
-
- - -{% endblock %} -{% block extracss %} - -{% endblock %} +{% block profile_info %} +{% include "member/profile_info.html" %} +{% endblock%} -{% block extrajavascript%} - - - -{% endblock %} +{% block profile_content%} +{% include "member/picture_update.html" %} +{% endblock%} diff --git a/templates/member/profile_tables.html b/templates/member/profile_tables.html new file mode 100644 index 00000000..9d2c687f --- /dev/null +++ b/templates/member/profile_tables.html @@ -0,0 +1,31 @@ +{% load render_table from django_tables2 %} +{% load i18n %} +
+
+ +
+ {% render_table club_list %} +
+
+ +
+ +
+
+ {% render_table history_list %} +
+
+
+