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
b1c06ac9
Commit
b1c06ac9
authored
14 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
added filtering to the show list view.
parent
1ea3eeb4
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
+23
-3
23 additions, 3 deletions
program/views.py
with
23 additions
and
3 deletions
program/views.py
+
23
−
3
View file @
b1c06ac9
from
django.views.generic.list
import
ListView
from
django.shortcuts
import
get_object_or_404
from
models
import
BroadcastFormat
,
MusicFocus
,
Note
,
Show
,
ShowInformation
,
ShowTopic
...
...
@@ -6,7 +7,6 @@ from datetime import datetime, timedelta
class
ShowListView
(
ListView
):
context_object_name
=
'
show_list
'
model
=
Show
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ShowListView
,
self
).
get_context_data
(
**
kwargs
)
...
...
@@ -17,7 +17,27 @@ class ShowListView(ListView):
context
[
'
showtopic_list
'
]
=
ShowTopic
.
objects
.
all
()
return
context
def
get_queryset
(
self
):
if
'
broadcastformat
'
in
self
.
request
.
GET
:
broadcastformat
=
get_object_or_404
(
BroadcastFormat
,
slug
=
self
.
request
.
GET
[
'
broadcastformat
'
])
return
Show
.
objects
.
filter
(
broadcastformat
=
broadcastformat
)
elif
'
musicfocus
'
in
self
.
request
.
GET
:
musicfocus
=
get_object_or_404
(
MusicFocus
,
slug
=
self
.
request
.
GET
[
'
musicfocus
'
])
return
Show
.
objects
.
filter
(
musicfocus
=
musicfocus
)
elif
'
showinformation
'
in
self
.
request
.
GET
:
showinformation
=
get_object_or_404
(
ShowInformation
,
slug
=
self
.
request
.
GET
[
'
showinformation
'
])
return
Show
.
objects
.
filter
(
showinformation
=
showinformation
)
elif
'
showtopic
'
in
self
.
request
.
GET
:
showtopic
=
get_object_or_404
(
ShowTopic
,
slug
=
self
.
request
.
GET
[
'
showtopic
'
])
return
Show
.
objects
.
filter
(
showtopic
=
showtopic
)
else
:
return
Show
.
objects
.
all
()
class
RecommendationsView
(
ListView
):
context_object_name
=
'
recommendations
'
template_name
=
'
program/recommendations.html
'
...
...
@@ -26,4 +46,4 @@ class RecommendationsView(ListView):
now
=
datetime
.
now
()
in_one_week
=
now
+
timedelta
(
weeks
=
1
)
return
Note
.
objects
.
filter
(
status
=
1
,
timeslot__start__range
=
(
now
,
in_one_week
))[:
10
]
\ No newline at end of file
return
Note
.
objects
.
filter
(
status
=
1
,
timeslot__start__range
=
(
now
,
in_one_week
))[:
10
]
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