mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-26 17:51:24 +00:00
Do some user profile templating
This commit is contained in:
parent
55ea2ac763
commit
0db7180d43
@ -162,9 +162,19 @@ tbody>tr:hover {
|
||||
}
|
||||
.tool-bar {
|
||||
overflow: auto;
|
||||
padding: 4px;
|
||||
}
|
||||
.tools {
|
||||
float: right;
|
||||
padding: 6px;
|
||||
overflow: hidden;
|
||||
border: 1px solid grey;
|
||||
}
|
||||
.tools a {
|
||||
padding: 10px;
|
||||
}
|
||||
.selected_tab {
|
||||
background: lightgrey;
|
||||
}
|
||||
#basket {
|
||||
width: 40%;
|
||||
|
@ -4,22 +4,53 @@
|
||||
<div class="tool-bar">
|
||||
<div>{{ profile.get_display_name() }}</div>
|
||||
<div class="tools">
|
||||
<a href="{{ url('core:user_profile', user_id=profile.id) }}">{% trans %}Infos{% endtrans %}</a>
|
||||
<a href="{{ url('core:user_stats', user_id=profile.id) }}">{% trans %}Stats{% endtrans %}</a>
|
||||
|
||||
<a href="{{ url('core:user_profile', user_id=profile.id) }}"
|
||||
{%- if tab == "infos" -%}
|
||||
class="selected_tab"
|
||||
{%- endif -%}
|
||||
>{% trans %}Infos{% endtrans %}</a>
|
||||
|
||||
<a href="{{ url('core:user_tools') }}"
|
||||
{%- if tab == "tools" -%}
|
||||
class="selected_tab"
|
||||
{%- endif -%}
|
||||
>{% trans %}Tools{% endtrans %}</a>
|
||||
|
||||
<a href="{{ url('core:user_stats', user_id=profile.id) }}"
|
||||
{%- if tab == "stats" -%}
|
||||
class="selected_tab"
|
||||
{%- endif -%}
|
||||
>{% trans %}Stats{% endtrans %}</a>
|
||||
|
||||
{% if can_edit(profile, request.user) or user.id == profile.id %}
|
||||
<a href="{{ url('core:user_edit', user_id=profile.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
<a href="{{ url('core:user_edit', user_id=profile.id) }}"
|
||||
{%- if tab == "edit" -%}
|
||||
class="selected_tab"
|
||||
{%- endif -%}
|
||||
>{% trans %}Edit{% endtrans %}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if can_edit_prop(profile, request.user) %}
|
||||
<a href="{{ url('core:user_groups', user_id=profile.id) }}">{% trans %}Groups{% endtrans %}</a>
|
||||
<a href="{{ url('core:user_groups', user_id=profile.id) }}"
|
||||
{%- if tab == "groups" -%}
|
||||
class="selected_tab"
|
||||
{%- endif -%}
|
||||
>{% trans %}Groups{% endtrans %}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if profile.customer and (profile == request.user
|
||||
or request.user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name'])
|
||||
or request.user.is_root) %}
|
||||
<a href="{{ url('core:user_account', user_id=profile.id) }}">{% trans %}Account{% endtrans %} ({{ profile.customer.amount }}€)</a>
|
||||
<a href="{{ url('core:user_account', user_id=profile.id) }}"
|
||||
{%- if tab == "account" -%}
|
||||
class="selected_tab"
|
||||
{%- endif -%}
|
||||
>{% trans %}Account{% endtrans %} ({{ profile.customer.amount }}€)</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div>
|
||||
{% block infos %}
|
||||
|
@ -1,10 +1,10 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
{% extends "core/user_base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans user_name=user.get_display_name() %}{{ user_name }}'s tools{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block infos %}
|
||||
<h3>{% trans %}User Tools{% endtrans %}</h3>
|
||||
|
||||
<hr>
|
||||
|
@ -124,6 +124,11 @@ class UserView(CanViewMixin, DetailView):
|
||||
context_object_name = "profile"
|
||||
template_name = "core/user_detail.jinja"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(UserView, self).get_context_data(**kwargs)
|
||||
kwargs['tab'] = "infos"
|
||||
return kwargs
|
||||
|
||||
class UserStatsView(CanViewMixin, DetailView):
|
||||
"""
|
||||
Display a user's stats
|
||||
@ -143,6 +148,7 @@ class UserStatsView(CanViewMixin, DetailView):
|
||||
kwargs['total_foyer_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=foyer)], timedelta())
|
||||
kwargs['total_mde_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=mde)], timedelta())
|
||||
kwargs['total_gommette_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=gommette)], timedelta())
|
||||
kwargs['tab'] = "stats"
|
||||
return kwargs
|
||||
|
||||
class UserMiniView(CanViewMixin, DetailView):
|
||||
@ -221,6 +227,7 @@ class UserUpdateProfileView(CanEditMixin, UpdateView):
|
||||
kwargs = super(UserUpdateProfileView, self).get_context_data(**kwargs)
|
||||
kwargs['profile'] = self.form.instance
|
||||
kwargs['form'] = self.form
|
||||
kwargs['tab'] = "edit"
|
||||
return kwargs
|
||||
|
||||
class UserUpdateGroupView(CanEditPropMixin, UpdateView):
|
||||
@ -234,6 +241,11 @@ class UserUpdateGroupView(CanEditPropMixin, UpdateView):
|
||||
widgets={'groups':CheckboxSelectMultiple})
|
||||
context_object_name = "profile"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(UserUpdateGroupView, self).get_context_data(**kwargs)
|
||||
kwargs['tab'] = "groups"
|
||||
return kwargs
|
||||
|
||||
class UserToolsView(TemplateView):
|
||||
"""
|
||||
Displays the logged user's tools
|
||||
@ -244,6 +256,8 @@ class UserToolsView(TemplateView):
|
||||
from launderette.models import Launderette
|
||||
kwargs = super(UserToolsView, self).get_context_data(**kwargs)
|
||||
kwargs['launderettes'] = Launderette.objects.all()
|
||||
kwargs['profile'] = self.request.user
|
||||
kwargs['tab'] = "tools"
|
||||
return kwargs
|
||||
|
||||
class UserAccountView(DetailView):
|
||||
@ -270,6 +284,7 @@ class UserAccountView(DetailView):
|
||||
except:
|
||||
pass
|
||||
# TODO: add list of month where account has activity
|
||||
kwargs['tab'] = "account"
|
||||
return kwargs
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user