mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 04:49:25 +00:00
Add basic account view for user and refactor user tool bar
This commit is contained in:
@ -9,6 +9,7 @@ from django.http import HttpResponseRedirect
|
||||
from django.utils import timezone
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
|
||||
import re
|
||||
|
||||
@ -345,4 +346,28 @@ class CounterDeleteView(CanEditMixin, DeleteView):
|
||||
template_name = 'core/delete_confirm.jinja'
|
||||
success_url = reverse_lazy('counter:admin_list')
|
||||
|
||||
# User accounting infos
|
||||
|
||||
class UserAccountView(DetailView):
|
||||
"""
|
||||
Display a user's account
|
||||
"""
|
||||
model = Customer
|
||||
pk_url_kwarg = "user_id"
|
||||
template_name = "counter/user_account.jinja"
|
||||
|
||||
def dispatch(self, request, *arg, **kwargs):
|
||||
res = super(UserAccountView, self).dispatch(request, *arg, **kwargs)
|
||||
if (self.object.user == request.user
|
||||
or request.user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name'])
|
||||
or request.user.is_in_group(settings.SITH_GROUPS['root']['name'])):
|
||||
return res
|
||||
raise PermissionDenied
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(UserAccountView, self).get_context_data(**kwargs)
|
||||
kwargs['profile'] = self.object.user
|
||||
# TODO: add list of month where account has activity
|
||||
return kwargs
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user