Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
AURA
steering
Commits
db913d06
Verified
Commit
db913d06
authored
1 year ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
refactor: remove code for nested routes
parent
51abe312
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/views.py
+1
-23
1 addition, 23 deletions
program/views.py
with
1 addition
and
23 deletions
program/views.py
+
1
−
23
View file @
db913d06
...
...
@@ -28,13 +28,12 @@ from django_filters.rest_framework import DjangoFilterBackend
from
drf_spectacular.utils
import
OpenApiResponse
,
extend_schema
,
extend_schema_view
from
rest_framework
import
filters
as
drf_filters
from
rest_framework
import
mixins
,
permissions
,
status
,
viewsets
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework.response
import
Response
from
django.contrib.auth.models
import
User
from
django.db
import
IntegrityError
from
django.http
import
Http404
,
HttpResponse
,
JsonResponse
from
django.http
import
HttpResponse
,
JsonResponse
from
django.shortcuts
import
get_object_or_404
from
django.utils
import
timezone
from
django.utils.translation
import
gettext
as
_
...
...
@@ -730,27 +729,6 @@ class APINoteViewSet(
else
:
return
Note
.
objects
.
filter
(
timeslot__schedule__show__owners
=
user
)
def
_get_timeslot
(
self
):
# TODO: Once we remove nested routes, timeslot ownership
# should be checked in a permission class.
timeslot_pk
=
self
.
request
.
data
.
get
(
"
timeslot_id
"
,
None
)
if
timeslot_pk
is
None
:
timeslot_pk
=
get_values
(
self
.
kwargs
,
"
timeslot_pk
"
)
if
timeslot_pk
is
None
:
raise
ValidationError
({
"
timeslot_id
"
:
[
_
(
"
This field is required.
"
)]},
code
=
"
required
"
)
qs
=
TimeSlot
.
objects
.
all
()
if
not
self
.
request
.
user
.
is_superuser
:
qs
=
qs
.
filter
(
schedule__show__owners
=
self
.
request
.
user
)
try
:
return
qs
.
get
(
pk
=
timeslot_pk
)
except
TimeSlot
.
DoesNotExist
:
raise
Http404
()
def
perform_create
(
self
,
serializer
):
# TODO: Once we remove nested routes, this should be removed
# and timeslot should be required in the serializer again.
serializer
.
save
(
timeslot
=
self
.
_get_timeslot
())
class
ActiveFilterMixin
:
filter_class
=
filters
.
ActiveFilterSet
...
...
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