Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
e1474c7a
Commit
e1474c7a
authored
Aug 14, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add is_root property to user
parent
79256399
Pipeline
#115
failed with stage
in 2 minutes and 50 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
10 deletions
+11
-10
club/templates/club/club_list.jinja
club/templates/club/club_list.jinja
+1
-1
core/models.py
core/models.py
+2
-1
core/templates/core/user_base.jinja
core/templates/core/user_base.jinja
+1
-1
core/templates/core/user_tools.jinja
core/templates/core/user_tools.jinja
+4
-4
core/views/user.py
core/views/user.py
+2
-2
subscription/models.py
subscription/models.py
+1
-1
No files found.
club/templates/club/club_list.jinja
View file @
e1474c7a
...
...
@@ -17,7 +17,7 @@
{%
-
endmacro
%}
{%
block
content
%}
{%
if
user.is_
superuser
or
user.is_in_group
(
settings.SITH_GROUPS
[
'root'
][
'name'
])
%}
{%
if
user.is_
root
%}
<p><a
href=
"
{{
url
(
'club:club_new'
)
}}
"
>
{%
trans
%}
New club
{%
endtrans
%}
</a></p>
{%
endif
%}
{%
if
club_list
%}
...
...
core/models.py
View file @
e1474c7a
...
...
@@ -223,6 +223,7 @@ class User(AbstractBaseUser):
return
True
return
self
.
groups
.
filter
(
name
=
group_name
).
exists
()
@
property
def
is_root
(
self
):
return
self
.
is_superuser
or
self
.
groups
.
filter
(
name
=
settings
.
SITH_GROUPS
[
'root'
][
'name'
]).
exists
()
...
...
@@ -348,7 +349,7 @@ class User(AbstractBaseUser):
return
False
def
can_be_edited_by
(
self
,
user
):
return
user
.
is_in_group
(
settings
.
SITH_MAIN_BOARD_GROUP
)
or
user
.
is_
in_group
(
settings
.
SITH_GROUPS
[
'root'
][
'name'
])
return
user
.
is_in_group
(
settings
.
SITH_MAIN_BOARD_GROUP
)
or
user
.
is_
root
class
AnonymousUser
(
AuthAnonymousUser
):
...
...
core/templates/core/user_base.jinja
View file @
e1474c7a
...
...
@@ -13,7 +13,7 @@
{%
endif
%}
{%
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
[
'root'
][
'name'
])
)
%}
or
request.user.is_
root
)
%}
<a
href=
"
{{
url
(
'core:user_account'
,
user_id
=
profile.id
)
}}
"
>
{%
trans
%}
Account
{%
endtrans
%}
</a>
{%
endif
%}
</div>
...
...
core/templates/core/user_tools.jinja
View file @
e1474c7a
...
...
@@ -10,10 +10,10 @@
<hr>
<h4>
{%
trans
%}
Sith management
{%
endtrans
%}
</h4>
<ul>
{%
if
user.is_
in_group
(
settings.SITH_GROUPS
[
'root'
][
'name'
])
%}
{%
if
user.is_
root
%}
<li><a
href=
"
{{
url
(
'core:group_list'
)
}}
"
>
{%
trans
%}
Groups
{%
endtrans
%}
</a></li>
{%
endif
%}
{%
if
user.is_in_group
(
settings.SITH_MAIN_BOARD_GROUP
)
or
user.is_
in_group
(
settings.SITH_GROUPS
[
'root'
][
'name'
])
%}
{%
if
user.is_in_group
(
settings.SITH_MAIN_BOARD_GROUP
)
or
user.is_
root
%}
<li><a
href=
"
{{
url
(
'subscription:subscription'
)
}}
"
>
{%
trans
%}
Subscriptions
{%
endtrans
%}
</a></li>
{%
endif
%}
</ul>
...
...
@@ -21,7 +21,7 @@
<hr>
<h4>
{%
trans
%}
Counters
{%
endtrans
%}
</h4>
<ul>
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'counter-admin'
][
'name'
])
or
user.is_
in_group
(
settings.SITH_GROUPS
[
'root'
][
'name'
])
%}
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'counter-admin'
][
'name'
])
or
user.is_
root
%}
<h5>
{%
trans
%}
General management
{%
endtrans
%}
</h5>
<li><a
href=
"
{{
url
(
'counter:admin_list'
)
}}
"
>
{%
trans
%}
General counters management
{%
endtrans
%}
</a></li>
<li><a
href=
"
{{
url
(
'counter:product_list'
)
}}
"
>
{%
trans
%}
Products management
{%
endtrans
%}
</a></li>
...
...
@@ -38,7 +38,7 @@
<hr>
<h4>
{%
trans
%}
Accounting
{%
endtrans
%}
</h4>
<ul>
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'accounting-admin'
][
'name'
])
or
user.is_
in_group
(
settings.SITH_GROUPS
[
'root'
][
'name'
])
%}
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'accounting-admin'
][
'name'
])
or
user.is_
root
%}
<li><a
href=
"
{{
url
(
'accounting:bank_list'
)
}}
"
>
{%
trans
%}
General accounting
{%
endtrans
%}
</a></li>
{%
endif
%}
{%
for
m
in
user.membership.
filter
(
end_date
=
None
)
.
filter
(
role__gte
=
7
)
.
all
()
%}
...
...
core/views/user.py
View file @
e1474c7a
...
...
@@ -46,7 +46,7 @@ def password_root_change(request, user_id):
"""
Allows a root user to change someone's password
"""
if
not
request
.
user
.
is_
superuser
and
not
request
.
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'root'
][
'name'
])
:
if
not
request
.
user
.
is_
root
:
raise
PermissionDenied
user
=
User
.
objects
.
filter
(
id
=
user_id
).
first
()
if
not
user
:
...
...
@@ -196,7 +196,7 @@ class UserAccountView(DetailView):
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'
])
):
or
request
.
user
.
is_
root
):
return
res
raise
PermissionDenied
...
...
subscription/models.py
View file @
e1474c7a
...
...
@@ -115,7 +115,7 @@ class Subscription(models.Model):
def
can_be_edited_by
(
self
,
user
):
return
user
.
is_in_group
(
settings
.
SITH_MAIN_BOARD_GROUP
)
or
user
.
is_
in_group
(
settings
.
SITH_GROUPS
[
'root'
][
'name'
])
return
user
.
is_in_group
(
settings
.
SITH_MAIN_BOARD_GROUP
)
or
user
.
is_
root
def
is_valid_now
(
self
):
return
self
.
subscription_start
<=
date
.
today
()
and
date
.
today
()
<=
self
.
subscription_end
...
...
Write
Preview
Markdown
is supported
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