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
4ab3f2cb
Commit
4ab3f2cb
authored
6 years ago
by
Frank Poetzsch-Heffter
Browse files
Options
Downloads
Patches
Plain Diff
limiting access
#13
parent
9fce3b5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!86
Merge school-apps
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
schoolapps/aub/views.py
+24
-1
24 additions, 1 deletion
schoolapps/aub/views.py
with
24 additions
and
1 deletion
schoolapps/aub/views.py
+
24
−
1
View file @
4ab3f2cb
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.contrib.auth.decorators
import
user_passes_test
from
django.contrib.auth
import
REDIRECT_FIELD_NAME
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.urls
import
reverse
from
django.utils
import
timezone
...
...
@@ -26,16 +28,37 @@ def index(request):
return
render
(
request
,
'
aub/index.html
'
,
context
)
def
check_own_aub_verification
(
user
):
return
Aub
.
objects
.
all
().
filter
(
created_by
=
user
)
def
check_own_aub
(
function
=
None
,
redirect_field_name
=
REDIRECT_FIELD_NAME
,
login_url
=
None
):
"""
Decorator for views that checks that the user only gets his own aub, redirecting
to the dashboard if necessary.
"""
actual_decorator
=
user_passes_test
(
check_own_aub_verification
,
login_url
=
login_url
,
redirect_field_name
=
redirect_field_name
)
if
function
:
return
actual_decorator
(
function
)
return
actual_decorator
def
not_your_own
():
return
"
hallo
"
@login_required
@permission_required
(
'
aub.apply_for_aub
'
)
@check_own_aub
(
login_url
=
'
/index.html?reason=not_your_own
'
)
def
details
(
request
,
aub_id
):
# aub = Aub.objects.all().filter(id=aub_id)
aub
=
get_object_or_404
(
Aub
,
id
=
aub_id
)
context
=
{
'
aub
'
:
aub
}
return
render
(
request
,
'
aub/details.html
'
,
context
)
@login_required
@permission_required
(
'
aub.apply_for_aub
'
)
def
apply_for
(
request
):
...
...
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