Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
0b0fb203
Verified
Commit
0b0fb203
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix person_required with support for anonymous users (3. try)
Addition to MR
#110
parent
d1b725b0
No related branches found
No related tags found
No related merge requests found
Pipeline
#580
failed
5 years ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/decorators.py
+6
-3
6 additions, 3 deletions
aleksis/core/decorators.py
with
6 additions
and
3 deletions
aleksis/core/decorators.py
+
6
−
3
View file @
0b0fb203
from
typing
import
Callable
from
django.contrib.auth.decorators
import
login_required
,
user_passes_test
from
aleksis.core.util.core_helpers
import
has_person
from
django.contrib.auth.models
import
User
def
admin_required
(
function
:
Callable
=
None
)
->
Callable
:
...
...
@@ -10,8 +9,12 @@ def admin_required(function: Callable = None) -> Callable:
return
actual_decorator
(
function
)
def
has_person_by_user
(
user
:
User
)
->
bool
:
return
getattr
(
user
,
"
person
"
,
None
)
is
not
None
def
person_required
(
function
:
Callable
=
None
)
->
Callable
:
"""
Requires a logged-in user which is linked to a person.
"""
actual_decorator
=
user_passes_test
(
has_person
)
actual_decorator
=
user_passes_test
(
has_person
_by_user
)
return
actual_decorator
(
login_required
(
function
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment