mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +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 {
|
.tool-bar {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
padding: 4px;
|
||||||
}
|
}
|
||||||
.tools {
|
.tools {
|
||||||
float: right;
|
float: right;
|
||||||
|
padding: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid grey;
|
||||||
|
}
|
||||||
|
.tools a {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.selected_tab {
|
||||||
|
background: lightgrey;
|
||||||
}
|
}
|
||||||
#basket {
|
#basket {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
|
@ -4,22 +4,53 @@
|
|||||||
<div class="tool-bar">
|
<div class="tool-bar">
|
||||||
<div>{{ profile.get_display_name() }}</div>
|
<div>{{ profile.get_display_name() }}</div>
|
||||||
<div class="tools">
|
<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 %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
{% if can_edit_prop(profile, request.user) %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
{% if profile.customer and (profile == request.user
|
{% if profile.customer and (profile == request.user
|
||||||
or request.user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name'])
|
or request.user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name'])
|
||||||
or request.user.is_root) %}
|
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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% block infos %}
|
{% block infos %}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/user_base.jinja" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% trans user_name=user.get_display_name() %}{{ user_name }}'s tools{% endtrans %}
|
{% trans user_name=user.get_display_name() %}{{ user_name }}'s tools{% endtrans %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block infos %}
|
||||||
<h3>{% trans %}User Tools{% endtrans %}</h3>
|
<h3>{% trans %}User Tools{% endtrans %}</h3>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -124,6 +124,11 @@ class UserView(CanViewMixin, DetailView):
|
|||||||
context_object_name = "profile"
|
context_object_name = "profile"
|
||||||
template_name = "core/user_detail.jinja"
|
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):
|
class UserStatsView(CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Display a user's stats
|
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_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_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['total_gommette_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=gommette)], timedelta())
|
||||||
|
kwargs['tab'] = "stats"
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class UserMiniView(CanViewMixin, DetailView):
|
class UserMiniView(CanViewMixin, DetailView):
|
||||||
@ -221,6 +227,7 @@ class UserUpdateProfileView(CanEditMixin, UpdateView):
|
|||||||
kwargs = super(UserUpdateProfileView, self).get_context_data(**kwargs)
|
kwargs = super(UserUpdateProfileView, self).get_context_data(**kwargs)
|
||||||
kwargs['profile'] = self.form.instance
|
kwargs['profile'] = self.form.instance
|
||||||
kwargs['form'] = self.form
|
kwargs['form'] = self.form
|
||||||
|
kwargs['tab'] = "edit"
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class UserUpdateGroupView(CanEditPropMixin, UpdateView):
|
class UserUpdateGroupView(CanEditPropMixin, UpdateView):
|
||||||
@ -234,6 +241,11 @@ class UserUpdateGroupView(CanEditPropMixin, UpdateView):
|
|||||||
widgets={'groups':CheckboxSelectMultiple})
|
widgets={'groups':CheckboxSelectMultiple})
|
||||||
context_object_name = "profile"
|
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):
|
class UserToolsView(TemplateView):
|
||||||
"""
|
"""
|
||||||
Displays the logged user's tools
|
Displays the logged user's tools
|
||||||
@ -244,6 +256,8 @@ class UserToolsView(TemplateView):
|
|||||||
from launderette.models import Launderette
|
from launderette.models import Launderette
|
||||||
kwargs = super(UserToolsView, self).get_context_data(**kwargs)
|
kwargs = super(UserToolsView, self).get_context_data(**kwargs)
|
||||||
kwargs['launderettes'] = Launderette.objects.all()
|
kwargs['launderettes'] = Launderette.objects.all()
|
||||||
|
kwargs['profile'] = self.request.user
|
||||||
|
kwargs['tab'] = "tools"
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class UserAccountView(DetailView):
|
class UserAccountView(DetailView):
|
||||||
@ -270,6 +284,7 @@ class UserAccountView(DetailView):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# TODO: add list of month where account has activity
|
# TODO: add list of month where account has activity
|
||||||
|
kwargs['tab'] = "account"
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user