Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
31ecb50c
Commit
31ecb50c
authored
Aug 05, 2016
by
Skia
🤘
Browse files
Move user account view into core
parent
aa17c44b
Pipeline
#88
passed with stage
in 2 minutes and 11 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
co
unte
r/templates/co
unte
r/user_account.jinja
→
cor
e
/templates/cor
e
/user_account.jinja
View file @
31ecb50c
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
{%
endblock
%}
{%
endblock
%}
{%
block
infos
%}
{%
block
infos
%}
{%
if
customer
%}
<h3>
{%
trans
%}
User account
{%
endtrans
%}
</h3>
<h3>
{%
trans
%}
User account
{%
endtrans
%}
</h3>
<p>
{%
trans
%}
Amount:
{%
endtrans
%}{{
customer.amount
}}
€
</p>
<p>
{%
trans
%}
Amount:
{%
endtrans
%}{{
customer.amount
}}
€
</p>
{%
if
customer.refillings.exists
()
%}
{%
if
customer.refillings.exists
()
%}
...
@@ -80,6 +81,9 @@
...
@@ -80,6 +81,9 @@
</tbody>
</tbody>
</table>
</table>
{%
endif
%}
{%
endif
%}
{%
else
%}
<p>
{%
trans
%}
User has no account
{%
endtrans
%}
</p>
{%
endif
%}
{%
endblock
%}
{%
endblock
%}
...
...
core/urls.py
View file @
31ecb50c
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
url
,
include
from
core.views
import
*
from
core.views
import
*
from
counter.views
import
UserAccountView
urlpatterns
=
[
urlpatterns
=
[
url
(
r
'^$'
,
index
,
name
=
'index'
),
url
(
r
'^$'
,
index
,
name
=
'index'
),
...
...
core/views/user.py
View file @
31ecb50c
...
@@ -7,6 +7,7 @@ from django.views.generic.edit import UpdateView
...
@@ -7,6 +7,7 @@ from django.views.generic.edit import UpdateView
from
django.views.generic
import
ListView
,
DetailView
,
TemplateView
from
django.views.generic
import
ListView
,
DetailView
,
TemplateView
from
django.forms.models
import
modelform_factory
from
django.forms.models
import
modelform_factory
from
django.forms
import
CheckboxSelectMultiple
from
django.forms
import
CheckboxSelectMultiple
from
django.conf
import
settings
import
logging
import
logging
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
...
@@ -132,3 +133,31 @@ class UserToolsView(TemplateView):
...
@@ -132,3 +133,31 @@ class UserToolsView(TemplateView):
Displays the logged user's tools
Displays the logged user's tools
"""
"""
template_name
=
"core/user_tools.jinja"
template_name
=
"core/user_tools.jinja"
class
UserAccountView
(
DetailView
):
"""
Display a user's account
"""
model
=
User
pk_url_kwarg
=
"user_id"
template_name
=
"core/user_account.jinja"
def
dispatch
(
self
,
request
,
*
arg
,
**
kwargs
):
# Manually validates the rights
res
=
super
(
UserAccountView
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
if
(
self
.
object
==
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
try
:
kwargs
[
'customer'
]
=
self
.
object
.
customer
except
:
pass
# TODO: add list of month where account has activity
return
kwargs
counter/views.py
View file @
31ecb50c
...
@@ -409,28 +409,3 @@ class ProductEditView(CanEditPropMixin, UpdateView):
...
@@ -409,28 +409,3 @@ class ProductEditView(CanEditPropMixin, UpdateView):
template_name
=
'core/edit.jinja'
template_name
=
'core/edit.jinja'
# TODO: add management of the 'counters' ForeignKey
# TODO: add management of the 'counters' ForeignKey
# 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
):
# Manually validates the rights
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment