Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
d279198e
Commit
d279198e
authored
Jun 01, 2016
by
Enrico Zini
Browse files
vperms -> visit_perms, and deprecated vperms
parent
fc4ac972
Changes
5
Hide whitespace changes
Inline
Side-by-side
backend/mixins.py
View file @
d279198e
...
@@ -84,23 +84,24 @@ class VisitPersonMixin(VisitorMixin):
...
@@ -84,23 +84,24 @@ class VisitPersonMixin(VisitorMixin):
else
:
else
:
return
bmodels
.
Person
.
lookup_or_404
(
key
)
return
bmodels
.
Person
.
lookup_or_404
(
key
)
def
get_vperms
(
self
):
def
get_v
isit_
perms
(
self
):
return
self
.
person
.
permissions_of
(
self
.
visitor
)
return
self
.
person
.
permissions_of
(
self
.
visitor
)
def
load_objects
(
self
):
def
load_objects
(
self
):
super
(
VisitPersonMixin
,
self
).
load_objects
()
super
(
VisitPersonMixin
,
self
).
load_objects
()
self
.
person
=
self
.
get_person
()
self
.
person
=
self
.
get_person
()
self
.
vperms
=
self
.
get_vperms
()
self
.
v
isit_
perms
=
self
.
get_v
isit_
perms
()
def
check_permissions
(
self
):
def
check_permissions
(
self
):
super
(
VisitPersonMixin
,
self
).
check_permissions
()
super
(
VisitPersonMixin
,
self
).
check_permissions
()
if
self
.
require_vperms
and
self
.
require_vperms
not
in
self
.
vperms
.
perms
:
if
self
.
require_vperms
and
self
.
require_vperms
not
in
self
.
v
isit_
perms
.
perms
:
raise
PermissionDenied
raise
PermissionDenied
def
get_context_data
(
self
,
**
kw
):
def
get_context_data
(
self
,
**
kw
):
ctx
=
super
(
VisitPersonMixin
,
self
).
get_context_data
(
**
kw
)
ctx
=
super
(
VisitPersonMixin
,
self
).
get_context_data
(
**
kw
)
ctx
[
"person"
]
=
self
.
person
ctx
[
"person"
]
=
self
.
person
ctx
[
"vperms"
]
=
self
.
vperms
ctx
[
"vperms"
]
=
self
.
visit_perms
ctx
[
"visit_perms"
]
=
self
.
visit_perms
return
ctx
return
ctx
...
@@ -116,12 +117,15 @@ class VisitProcessMixin(VisitPersonMixin):
...
@@ -116,12 +117,15 @@ class VisitProcessMixin(VisitPersonMixin):
def
get_person
(
self
):
def
get_person
(
self
):
return
self
.
process
.
person
return
self
.
process
.
person
def
get_vperms
(
self
):
def
get_process
(
self
):
return
bmodels
.
Process
.
lookup_or_404
(
self
.
kwargs
[
"key"
])
def
get_visit_perms
(
self
):
return
self
.
process
.
permissions_of
(
self
.
visitor
)
return
self
.
process
.
permissions_of
(
self
.
visitor
)
def
pre_dispatch
(
self
):
def
load_objects
(
self
):
self
.
process
=
bmodels
.
Process
.
lookup_or_404
(
self
.
kwargs
[
"key"
]
)
self
.
process
=
self
.
get_process
(
)
super
(
VisitProcessMixin
,
self
).
pre_dispatch
()
super
(
VisitProcessMixin
,
self
).
load_objects
()
def
get_context_data
(
self
,
**
kw
):
def
get_context_data
(
self
,
**
kw
):
ctx
=
super
(
VisitProcessMixin
,
self
).
get_context_data
(
**
kw
)
ctx
=
super
(
VisitProcessMixin
,
self
).
get_context_data
(
**
kw
)
...
...
process/mixins.py
View file @
d279198e
...
@@ -11,13 +11,13 @@ from . import models as pmodels
...
@@ -11,13 +11,13 @@ from . import models as pmodels
class
VisitProcessMixin
(
VisitPersonMixin
):
class
VisitProcessMixin
(
VisitPersonMixin
):
"""
"""
Visit a person process. Adds self.person, self.process and
self.vperms with
Visit a person process. Adds self.person, self.process and
the permissions the visitor has over the person
self.visit_perms with
the permissions the visitor has over the person
"""
"""
def
get_person
(
self
):
def
get_person
(
self
):
return
self
.
process
.
person
return
self
.
process
.
person
def
get_vperms
(
self
):
def
get_v
isit_
perms
(
self
):
return
self
.
process
.
permissions_of
(
self
.
visitor
)
return
self
.
process
.
permissions_of
(
self
.
visitor
)
def
get_process
(
self
):
def
get_process
(
self
):
...
...
process/views.py
View file @
d279198e
...
@@ -147,7 +147,7 @@ class RequirementMixin(VisitProcessMixin):
...
@@ -147,7 +147,7 @@ class RequirementMixin(VisitProcessMixin):
process
=
get_object_or_404
(
pmodels
.
Process
,
pk
=
self
.
kwargs
[
"pk"
])
process
=
get_object_or_404
(
pmodels
.
Process
,
pk
=
self
.
kwargs
[
"pk"
])
return
get_object_or_404
(
pmodels
.
Requirement
,
process
=
process
,
type
=
self
.
get_requirement_type
())
return
get_object_or_404
(
pmodels
.
Requirement
,
process
=
process
,
type
=
self
.
get_requirement_type
())
def
get_vperms
(
self
):
def
get_v
isit_
perms
(
self
):
return
self
.
requirement
.
permissions_of
(
self
.
visitor
)
return
self
.
requirement
.
permissions_of
(
self
.
visitor
)
def
get_process
(
self
):
def
get_process
(
self
):
...
...
public/views.py
View file @
d279198e
...
@@ -141,7 +141,7 @@ class Process(VisitProcessTemplateView):
...
@@ -141,7 +141,7 @@ class Process(VisitProcessTemplateView):
# Process form ASAP, so we compute the rest with updated values
# Process form ASAP, so we compute the rest with updated values
am
=
self
.
visitor
.
am_or_none
if
self
.
visitor
else
None
am
=
self
.
visitor
.
am_or_none
if
self
.
visitor
else
None
if
am
and
(
self
.
process
.
manager
==
am
or
am
.
is_admin
)
and
(
if
am
and
(
self
.
process
.
manager
==
am
or
am
.
is_admin
)
and
(
"edit_bio"
in
self
.
vperms
.
perms
or
"edit_ldap"
in
self
.
vperms
.
perms
):
"edit_bio"
in
self
.
v
isit_
perms
.
perms
or
"edit_ldap"
in
self
.
v
isit_
perms
.
perms
):
StatusUpdateForm
=
make_statusupdateform
(
am
)
StatusUpdateForm
=
make_statusupdateform
(
am
)
form
=
StatusUpdateForm
(
initial
=
dict
(
progress
=
self
.
process
.
progress
))
form
=
StatusUpdateForm
(
initial
=
dict
(
progress
=
self
.
process
.
progress
))
else
:
else
:
...
@@ -510,7 +510,7 @@ class Person(VisitPersonTemplateView):
...
@@ -510,7 +510,7 @@ class Person(VisitPersonTemplateView):
am_processes
=
[]
am_processes
=
[]
audit_log
=
[]
audit_log
=
[]
if
"view_person_audit_log"
in
self
.
vperms
.
perms
:
if
"view_person_audit_log"
in
self
.
v
isit_
perms
.
perms
:
is_admin
=
self
.
visitor
.
is_admin
is_admin
=
self
.
visitor
.
is_admin
for
e
in
self
.
person
.
audit_log
.
order_by
(
"-logdate"
):
for
e
in
self
.
person
.
audit_log
.
order_by
(
"-logdate"
):
if
is_admin
:
if
is_admin
:
...
...
restricted/views.py
View file @
d279198e
...
@@ -181,7 +181,7 @@ class Person(VisitPersonTemplateView):
...
@@ -181,7 +181,7 @@ class Person(VisitPersonTemplateView):
template_name
=
"restricted/person.html"
template_name
=
"restricted/person.html"
def
get_person_form
(
self
):
def
get_person_form
(
self
):
perms
=
self
.
vperms
.
perms
perms
=
self
.
v
isit_
perms
.
perms
# Check permissions
# Check permissions
if
"edit_bio"
not
in
perms
and
"edit_ldap"
not
in
perms
:
if
"edit_bio"
not
in
perms
and
"edit_ldap"
not
in
perms
:
...
@@ -245,7 +245,7 @@ class NewProcess(VisitPersonTemplateView):
...
@@ -245,7 +245,7 @@ class NewProcess(VisitPersonTemplateView):
from
django.db.models
import
Min
,
Max
from
django.db.models
import
Min
,
Max
ctx
=
super
(
NewProcess
,
self
).
get_context_data
(
**
kw
)
ctx
=
super
(
NewProcess
,
self
).
get_context_data
(
**
kw
)
applying_for
=
self
.
kwargs
[
"applying_for"
]
applying_for
=
self
.
kwargs
[
"applying_for"
]
if
applying_for
not
in
self
.
vperms
.
advocate_targets
:
if
applying_for
not
in
self
.
v
isit_
perms
.
advocate_targets
:
raise
PermissionDenied
raise
PermissionDenied
# Checks and warnings
# Checks and warnings
...
@@ -276,7 +276,7 @@ class NewProcess(VisitPersonTemplateView):
...
@@ -276,7 +276,7 @@ class NewProcess(VisitPersonTemplateView):
def
post
(
self
,
request
,
applying_for
,
key
,
*
args
,
**
kw
):
def
post
(
self
,
request
,
applying_for
,
key
,
*
args
,
**
kw
):
applying_for
=
self
.
kwargs
[
"applying_for"
]
applying_for
=
self
.
kwargs
[
"applying_for"
]
if
applying_for
not
in
self
.
vperms
.
advocate_targets
:
if
applying_for
not
in
self
.
v
isit_
perms
.
advocate_targets
:
raise
PermissionDenied
raise
PermissionDenied
advtext
=
request
.
POST
[
"text"
].
strip
()
advtext
=
request
.
POST
[
"text"
].
strip
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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