mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-30 00:23:54 +00:00 
			
		
		
		
	Improve club templates
This commit is contained in:
		
							
								
								
									
										57
									
								
								club/templates/club/club_base.jinja
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								club/templates/club/club_base.jinja
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | {% extends "core/base.jinja" %} | ||||||
|  |  | ||||||
|  | {% block content %} | ||||||
|  | <div class="tool-bar"> | ||||||
|  |     <div>{{ club.name }}</div> | ||||||
|  |     <div class="tools"> | ||||||
|  |         <a href="{{ url('club:club_view', club_id=club.id) }}" | ||||||
|  |             {%- if tab == "infos" -%} | ||||||
|  |                 class="selected_tab" | ||||||
|  |             {%- endif -%} | ||||||
|  |         >{% trans %}Infos{% endtrans %}</a> | ||||||
|  |  | ||||||
|  |         {% if can_view(club, user) %} | ||||||
|  |         <a href="{{ url('club:club_members', club_id=club.pk) }}" | ||||||
|  |             {%- if tab == "members" -%} | ||||||
|  |                 class="selected_tab" | ||||||
|  |             {%- endif -%} | ||||||
|  |         >{% trans %}Members{% endtrans %}</a> | ||||||
|  |         {% endif %} | ||||||
|  |  | ||||||
|  |         {% if can_view(club, user) %} | ||||||
|  |         <a href="{{ url('club:tools', club_id=club.id) }}" | ||||||
|  |             {%- if tab == "tools" -%} | ||||||
|  |                 class="selected_tab" | ||||||
|  |             {%- endif -%} | ||||||
|  |         >{% trans %}Tools{% endtrans %}</a> | ||||||
|  |         {% endif %} | ||||||
|  |  | ||||||
|  |         {% if can_edit(club, request.user) %} | ||||||
|  |         <a href="{{ url('club:club_edit', club_id=club.id) }}" | ||||||
|  |             {%- if tab == "edit" -%} | ||||||
|  |                 class="selected_tab" | ||||||
|  |             {%- endif -%} | ||||||
|  |         >{% trans %}Edit{% endtrans %}</a> | ||||||
|  |         {% endif %} | ||||||
|  |  | ||||||
|  |         {% if can_edit_prop(club, request.user) %} | ||||||
|  |         <a href="{{ url('club:club_prop', club_id=club.id) }}" | ||||||
|  |             {%- if tab == "props" -%} | ||||||
|  |                 class="selected_tab" | ||||||
|  |             {%- endif -%} | ||||||
|  |         >{% trans %}Props{% endtrans %}</a> | ||||||
|  |         {% endif %} | ||||||
|  |  | ||||||
|  |     </div> | ||||||
|  |     <hr> | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <div> | ||||||
|  |     {% block club %} | ||||||
|  |     {% endblock %} | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | {% endblock %} | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -1,35 +1,8 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "club/club_base.jinja" %} | ||||||
| {% from 'core/macros.jinja' import user_profile_link %} | {% from 'core/macros.jinja' import user_profile_link %} | ||||||
|  |  | ||||||
| {% block content %} | {% block club %} | ||||||
|     <h3>{% trans %}Club{% endtrans %}</h3> |     <h3>{% trans %}Club{% endtrans %}</h3> | ||||||
|     <p><a href="{{ url('club:club_list') }}">{% trans %}Back to list{% endtrans %}</a></p> |  | ||||||
|     {% if can_edit(club, user) %} |  | ||||||
|     <p><a href="{{ url('club:club_edit', club_id=club.pk) }}">{% trans %}Edit{% endtrans %}</a></p> |  | ||||||
|     {% endif %} |  | ||||||
|     {% if can_edit_prop(club, user) %} |  | ||||||
|     <p><a href="{{ url('club:club_prop', club_id=club.pk) }}">{% trans %}Prop{% endtrans %}</a> |  | ||||||
|     </p> |  | ||||||
|     {% endif %} |  | ||||||
|     {% if can_view(club, user) %} |  | ||||||
|     <p><a href="{{ url('club:club_members', club_id=club.pk) }}">{% trans %}Members{% endtrans %}</a></p> |  | ||||||
|     {% endif %} |  | ||||||
|     <h3>{{ club.name }}</h3> |  | ||||||
|     <p>{{ club.address }}</p> |  | ||||||
|     <table> |  | ||||||
|         <thead> |  | ||||||
|             <td>{% trans %}User{% endtrans %}</td> |  | ||||||
|             <td>{% trans %}Role{% endtrans %}</td> |  | ||||||
|         </thead> |  | ||||||
|         <tbody> |  | ||||||
|         {% for m in club.members.filter(end_date=None).order_by('-role').all() %} |  | ||||||
|             <tr> |  | ||||||
|                 <td>{{ user_profile_link(m.user) }}</td> |  | ||||||
|                 <td>{{ settings.SITH_CLUB_ROLES[m.role] }}</td> |  | ||||||
|             </tr> |  | ||||||
|         {% endfor %} |  | ||||||
|         </tbody> |  | ||||||
|     </table> |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "club/club_base.jinja" %} | ||||||
|  |  | ||||||
| {% block content %} | {% block club %} | ||||||
|     <h2>{% trans %}Edit club{% endtrans %}</h2> |     <h2>{% trans %}Edit club{% endtrans %}</h2> | ||||||
|     <form action="{{ url('club:club_edit', club_id=club.id) }}" method="post"> |     <form action="{{ url('club:club_edit', club_id=club.id) }}" method="post"> | ||||||
|         {% csrf_token %} |         {% csrf_token %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "club/club_base.jinja" %} | ||||||
|  |  | ||||||
| {% block content %} | {% block club %} | ||||||
|     <h2>{% trans %}Edit club properties{% endtrans %}</h2> |     <h2>{% trans %}Edit club properties{% endtrans %}</h2> | ||||||
|     <form action="" method="post"> |     <form action="" method="post"> | ||||||
|         {% csrf_token %} |         {% csrf_token %} | ||||||
|   | |||||||
| @@ -1,18 +1,20 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "club/club_base.jinja" %} | ||||||
| {% from 'core/macros.jinja' import user_profile_link %} | {% from 'core/macros.jinja' import user_profile_link %} | ||||||
|  |  | ||||||
| {% block content %} | {% block club %} | ||||||
|     <h2>{% trans %}Club members{% endtrans %}</h2> |     <h2>{% trans %}Club members{% endtrans %}</h2> | ||||||
|     <table> |     <table> | ||||||
|         <thead> |         <thead> | ||||||
|             <td>{% trans %}User{% endtrans %}</td> |             <td>{% trans %}User{% endtrans %}</td> | ||||||
|             <td>{% trans %}Role{% endtrans %}</td> |             <td>{% trans %}Role{% endtrans %}</td> | ||||||
|  |             <td>{% trans %}Description{% endtrans %}</td> | ||||||
|         </thead> |         </thead> | ||||||
|         <tbody> |         <tbody> | ||||||
|         {% for m in club.members.filter(end_date=None).order_by('-role').all() %} |         {% for m in club.members.filter(end_date=None).order_by('-role').all() %} | ||||||
|             <tr> |             <tr> | ||||||
|                 <td>{{ user_profile_link(m.user) }}</td> |                 <td>{{ user_profile_link(m.user) }}</td> | ||||||
|                 <td>{{ settings.SITH_CLUB_ROLES[m.role] }}</td> |                 <td>{{ settings.SITH_CLUB_ROLES[m.role] }}</td> | ||||||
|  |                 <td>{{ m.description }}</td> | ||||||
|             </tr> |             </tr> | ||||||
|         {% endfor %} |         {% endfor %} | ||||||
|         </tbody> |         </tbody> | ||||||
|   | |||||||
| @@ -1,8 +1,7 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "club/club_base.jinja" %} | ||||||
|  |  | ||||||
| {% block content %} | {% block club %} | ||||||
| <h3>{% trans %}Club tools{% endtrans %}</h3> | <h3>{% trans %}Club tools{% endtrans %}</h3> | ||||||
| <p><a href="{{ url('club:club_view', club_id=object.id) }}">Back to club</a></p> |  | ||||||
| <div> | <div> | ||||||
|     {% if object.counters.filter(type="OFFICE")|count > 0 %} |     {% if object.counters.filter(type="OFFICE")|count > 0 %} | ||||||
|     <h4>{% trans %}Counters:{% endtrans %}</h4> |     <h4>{% trans %}Counters:{% endtrans %}</h4> | ||||||
|   | |||||||
| @@ -25,6 +25,11 @@ class ClubView(DetailView): | |||||||
|     pk_url_kwarg = "club_id" |     pk_url_kwarg = "club_id" | ||||||
|     template_name = 'club/club_detail.jinja' |     template_name = 'club/club_detail.jinja' | ||||||
|  |  | ||||||
|  |     def get_context_data(self, **kwargs): | ||||||
|  |         kwargs = super(ClubView, self).get_context_data(**kwargs) | ||||||
|  |         kwargs['tab'] = "infos" | ||||||
|  |         return kwargs | ||||||
|  |  | ||||||
| class ClubToolsView(CanEditMixin, DetailView): | class ClubToolsView(CanEditMixin, DetailView): | ||||||
|     """ |     """ | ||||||
|     Tools page of a Club |     Tools page of a Club | ||||||
| @@ -33,6 +38,11 @@ class ClubToolsView(CanEditMixin, DetailView): | |||||||
|     pk_url_kwarg = "club_id" |     pk_url_kwarg = "club_id" | ||||||
|     template_name = 'club/club_tools.jinja' |     template_name = 'club/club_tools.jinja' | ||||||
|  |  | ||||||
|  |     def get_context_data(self, **kwargs): | ||||||
|  |         kwargs = super(ClubToolsView, self).get_context_data(**kwargs) | ||||||
|  |         kwargs['tab'] = "tools" | ||||||
|  |         return kwargs | ||||||
|  |  | ||||||
| class ClubMemberForm(forms.ModelForm): | class ClubMemberForm(forms.ModelForm): | ||||||
|     """ |     """ | ||||||
|     Form handling the members of a club |     Form handling the members of a club | ||||||
| @@ -41,7 +51,7 @@ class ClubMemberForm(forms.ModelForm): | |||||||
|     required_css_class = 'required' |     required_css_class = 'required' | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = Membership |         model = Membership | ||||||
|         fields = ['user', 'role'] |         fields = ['user', 'role', 'description'] | ||||||
|  |  | ||||||
|     def clean(self): |     def clean(self): | ||||||
|         """ |         """ | ||||||
| @@ -87,6 +97,11 @@ class ClubMembersView(CanViewMixin, UpdateView): | |||||||
|         form._user = self.request.user |         form._user = self.request.user | ||||||
|         return form |         return form | ||||||
|  |  | ||||||
|  |     def get_context_data(self, **kwargs): | ||||||
|  |         kwargs = super(ClubMembersView, self).get_context_data(**kwargs) | ||||||
|  |         kwargs['tab'] = "members" | ||||||
|  |         return kwargs | ||||||
|  |  | ||||||
| class ClubEditView(CanEditMixin, UpdateView): | class ClubEditView(CanEditMixin, UpdateView): | ||||||
|     """ |     """ | ||||||
|     Edit a Club's main informations (for the club's members) |     Edit a Club's main informations (for the club's members) | ||||||
| @@ -96,6 +111,11 @@ class ClubEditView(CanEditMixin, UpdateView): | |||||||
|     fields = ['address'] |     fields = ['address'] | ||||||
|     template_name = 'club/club_edit.jinja' |     template_name = 'club/club_edit.jinja' | ||||||
|  |  | ||||||
|  |     def get_context_data(self, **kwargs): | ||||||
|  |         kwargs = super(ClubEditView, self).get_context_data(**kwargs) | ||||||
|  |         kwargs['tab'] = "edit" | ||||||
|  |         return kwargs | ||||||
|  |  | ||||||
| class ClubEditPropView(CanEditPropMixin, UpdateView): | class ClubEditPropView(CanEditPropMixin, UpdateView): | ||||||
|     """ |     """ | ||||||
|     Edit the properties of a Club object (for the Sith admins) |     Edit the properties of a Club object (for the Sith admins) | ||||||
| @@ -105,6 +125,10 @@ class ClubEditPropView(CanEditPropMixin, UpdateView): | |||||||
|     fields = ['name', 'unix_name', 'parent'] |     fields = ['name', 'unix_name', 'parent'] | ||||||
|     template_name = 'club/club_edit_prop.jinja' |     template_name = 'club/club_edit_prop.jinja' | ||||||
|  |  | ||||||
|  |     def get_context_data(self, **kwargs): | ||||||
|  |         kwargs = super(ClubEditPropView, self).get_context_data(**kwargs) | ||||||
|  |         kwargs['tab'] = "props" | ||||||
|  |         return kwargs | ||||||
|  |  | ||||||
| class ClubCreateView(CanEditPropMixin, CreateView): | class ClubCreateView(CanEditPropMixin, CreateView): | ||||||
|     """ |     """ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user