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
0c720c07
Verified
Commit
0c720c07
authored
11 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
refactor: remove NestedObjectFinderMixin since it’s no longer used
parent
b5f9c113
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7799
passed
11 months ago
Stage: build
Stage: test
Stage: deploy
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/utils.py
+0
-20
0 additions, 20 deletions
program/utils.py
program/views.py
+3
-24
3 additions, 24 deletions
program/views.py
with
3 additions
and
44 deletions
program/utils.py
+
0
−
20
View file @
0c720c07
...
@@ -24,7 +24,6 @@ from datetime import date, datetime, time
...
@@ -24,7 +24,6 @@ from datetime import date, datetime, time
from
typing
import
Dict
,
Optional
,
Tuple
,
Union
from
typing
import
Dict
,
Optional
,
Tuple
,
Union
import
requests
import
requests
from
rest_framework
import
exceptions
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -126,22 +125,3 @@ def delete_links(instance: Union["Host", "Note", "Show"]) -> Union["Host", "Note
...
@@ -126,22 +125,3 @@ def delete_links(instance: Union["Host", "Note", "Show"]) -> Union["Host", "Note
link
.
delete
(
keep_parents
=
True
)
link
.
delete
(
keep_parents
=
True
)
return
instance
return
instance
class
NestedObjectFinderMixin
:
ROUTE_FILTER_LOOKUPS
=
{}
def
_get_route_filters
(
self
)
->
Dict
[
str
,
int
]:
filter_kwargs
=
{}
for
key
,
value
in
self
.
kwargs
.
items
():
if
key
in
self
.
ROUTE_FILTER_LOOKUPS
:
try
:
filter_kwargs
[
self
.
ROUTE_FILTER_LOOKUPS
[
key
]]
=
int
(
value
)
except
ValueError
:
raise
exceptions
.
ValidationError
(
detail
=
f
"
{
key
}
must map to an integer value.
"
,
code
=
"
invalid-pk
"
)
return
filter_kwargs
def
get_queryset
(
self
):
return
super
().
get_queryset
().
filter
(
**
self
.
_get_route_filters
())
This diff is collapsed.
Click to expand it.
program/views.py
+
3
−
24
View file @
0c720c07
...
@@ -80,7 +80,7 @@ from program.serializers import (
...
@@ -80,7 +80,7 @@ from program.serializers import (
UserSerializer
,
UserSerializer
,
)
)
from
program.services
import
get_timerange_timeslots
,
resolve_conflicts
from
program.services
import
get_timerange_timeslots
,
resolve_conflicts
from
program.utils
import
NestedObjectFinderMixin
,
get_values
,
parse_date
from
program.utils
import
get_values
,
parse_date
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -514,14 +514,7 @@ class APIRRuleViewSet(viewsets.ModelViewSet):
...
@@ -514,14 +514,7 @@ class APIRRuleViewSet(viewsets.ModelViewSet):
destroy
=
extend_schema
(
summary
=
"
Delete an existing schedule.
"
),
destroy
=
extend_schema
(
summary
=
"
Delete an existing schedule.
"
),
list
=
extend_schema
(
summary
=
"
List all schedules.
"
),
list
=
extend_schema
(
summary
=
"
List all schedules.
"
),
)
)
class
APIScheduleViewSet
(
class
APIScheduleViewSet
(
viewsets
.
ModelViewSet
):
NestedObjectFinderMixin
,
viewsets
.
ModelViewSet
,
):
ROUTE_FILTER_LOOKUPS
=
{
"
show_pk
"
:
"
show
"
,
}
filterset_class
=
filters
.
ScheduleFilterSet
filterset_class
=
filters
.
ScheduleFilterSet
pagination_class
=
LimitOffsetPagination
pagination_class
=
LimitOffsetPagination
queryset
=
Schedule
.
objects
.
all
()
queryset
=
Schedule
.
objects
.
all
()
...
@@ -648,18 +641,12 @@ class APIScheduleViewSet(
...
@@ -648,18 +641,12 @@ class APIScheduleViewSet(
),
),
)
)
class
APITimeSlotViewSet
(
class
APITimeSlotViewSet
(
NestedObjectFinderMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
DestroyModelMixin
,
mixins
.
DestroyModelMixin
,
mixins
.
ListModelMixin
,
mixins
.
ListModelMixin
,
viewsets
.
GenericViewSet
,
viewsets
.
GenericViewSet
,
):
):
ROUTE_FILTER_LOOKUPS
=
{
"
show_pk
"
:
"
schedule__show
"
,
"
schedule_pk
"
:
"
schedule
"
,
}
filterset_class
=
filters
.
TimeSlotFilterSet
filterset_class
=
filters
.
TimeSlotFilterSet
pagination_class
=
LimitOffsetPagination
pagination_class
=
LimitOffsetPagination
queryset
=
TimeSlot
.
objects
.
all
().
order_by
(
"
-start
"
)
queryset
=
TimeSlot
.
objects
.
all
().
order_by
(
"
-start
"
)
...
@@ -696,15 +683,7 @@ class APITimeSlotViewSet(
...
@@ -696,15 +683,7 @@ class APITimeSlotViewSet(
destroy
=
extend_schema
(
summary
=
"
Delete an existing note.
"
),
destroy
=
extend_schema
(
summary
=
"
Delete an existing note.
"
),
list
=
extend_schema
(
summary
=
"
List all notes.
"
),
list
=
extend_schema
(
summary
=
"
List all notes.
"
),
)
)
class
APINoteViewSet
(
class
APINoteViewSet
(
viewsets
.
ModelViewSet
):
NestedObjectFinderMixin
,
viewsets
.
ModelViewSet
,
):
ROUTE_FILTER_LOOKUPS
=
{
"
show_pk
"
:
"
timeslot__show
"
,
"
timeslot_pk
"
:
"
timeslot
"
,
}
filterset_class
=
filters
.
NoteFilterSet
filterset_class
=
filters
.
NoteFilterSet
pagination_class
=
LimitOffsetPagination
pagination_class
=
LimitOffsetPagination
serializer_class
=
NoteSerializer
serializer_class
=
NoteSerializer
...
...
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