Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
My SU
Backend
API
Commits
e0c4e316
Commit
e0c4e316
authored
1 year ago
by
s2536528
Browse files
Options
Downloads
Patches
Plain Diff
Added method get_object in class viewsets/event.py
parent
883ba89f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/calendar/viewsets/event.py
+7
-0
7 additions, 0 deletions
apps/calendar/viewsets/event.py
with
7 additions
and
0 deletions
apps/calendar/viewsets/event.py
+
7
−
0
View file @
e0c4e316
from
django.shortcuts
import
get_object_or_404
from
django.utils
import
timezone
from
guardian.shortcuts
import
get_objects_for_user
from
guardian.shortcuts
import
Q
...
...
@@ -59,6 +60,12 @@ class EventViewSet(viewsets.ModelViewSet):
def
get_serializer_class
(
self
):
return
EventSerializer
def
get_object
(
self
):
obj
=
get_object_or_404
(
self
.
get_queryset
(),
pk
=
self
.
kwargs
[
"
id
"
])
# maybe instead of id, name ?
print
(
"
method for retrieving the object was used ! [TEST]
"
)
self
.
check_object_permissions
(
self
.
request
,
obj
)
return
obj
def
get_queryset
(
self
):
associations
=
get_objects_for_user
(
self
.
request
.
user
,
'
board
'
,
klass
=
Association
)
queryset
=
Event
.
objects
.
filter
(
...
...
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