Add basic account view for user and refactor user tool bar

This commit is contained in:
Skia
2016-07-17 12:38:02 +02:00
parent c099cc489b
commit e92a73dfb1
11 changed files with 165 additions and 16 deletions

View File

@ -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