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
0479a170
Commit
0479a170
authored
14 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
added current/next/after show view & day/today schedule view.
parent
df277467
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TODO
+0
-2
0 additions, 2 deletions
TODO
program/urls.py
+6
-3
6 additions, 3 deletions
program/urls.py
program/views.py
+59
-7
59 additions, 7 deletions
program/views.py
with
65 additions
and
12 deletions
TODO
+
0
−
2
View file @
0479a170
* current/next/after next show view
* day schedule view
* week schedule view
* integrate calendar into day schedule view
* integrate tinyMCE into admin site
...
...
This diff is collapsed.
Click to expand it.
program/urls.py
+
6
−
3
View file @
0479a170
...
...
@@ -3,14 +3,17 @@ from django.views.generic.detail import DetailView
from
django.views.generic.list
import
ListView
from
models
import
Host
,
Show
,
TimeSlot
from
views
import
RecommendationsView
,
ShowListView
from
views
import
CurrentShowView
,
DayScheduleView
,
RecommendationsView
,
ShowListView
,
TodayScheduleView
urlpatterns
=
patterns
(
''
,
(
'
^hosts/$
'
,
ListView
.
as_view
(
model
=
Host
,
context_object_name
=
'
host_list
'
)),
(
'
^$
'
,
TodayScheduleView
.
as_view
()),
(
'
^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$
'
,
DayScheduleView
.
as_view
()),
(
'
^current/$
'
,
CurrentShowView
.
as_view
()),
(
'
^hosts/$
'
,
ListView
.
as_view
(
model
=
Host
,
context_object_name
=
'
hosts
'
)),
url
(
'
^host/(?P<pk>\d+)/$
'
,
DetailView
.
as_view
(
model
=
Host
),
name
=
'
host-detail
'
),
(
'
^recommendations/$
'
,
RecommendationsView
.
as_view
()),
(
'
^recommendations_box/$
'
,
RecommendationsView
.
as_view
(
template_name
=
'
program/recommendations_box.html
'
)),
(
'
^shows/$
'
,
ShowListView
.
as_view
()),
url
(
'
^show/(?P<slug>[\w-]+)/$
'
,
DetailView
.
as_view
(
model
=
Show
),
name
=
'
show-detail
'
),
url
(
'
^
timeslot/
(?P<pk>\d+)/$
'
,
DetailView
.
as_view
(
model
=
TimeSlot
),
name
=
'
timeslot-detail
'
),
url
(
'
^(?P<pk>\d+)/$
'
,
DetailView
.
as_view
(
model
=
TimeSlot
),
name
=
'
timeslot-detail
'
),
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
program/views.py
+
59
−
7
View file @
0479a170
from
django.views.generic.list
import
ListView
from
django.views.generic.base
import
TemplateView
from
django.views.generic.dates
import
DayArchiveView
,
TodayArchiveView
from
django.shortcuts
import
get_object_or_404
from
models
import
BroadcastFormat
,
MusicFocus
,
Note
,
Show
,
ShowInformation
,
ShowTopic
from
models
import
BroadcastFormat
,
MusicFocus
,
Note
,
Show
,
ShowInformation
,
ShowTopic
,
TimeSlot
from
datetime
import
datetime
,
timedelta
from
datetime
import
date
,
datetime
,
time
,
timedelta
class
ShowListView
(
ListView
):
context_object_name
=
'
show
_list
'
context_object_name
=
'
show
s
'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ShowListView
,
self
).
get_context_data
(
**
kwargs
)
context
[
'
broadcastformat
_list
'
]
=
BroadcastFormat
.
objects
.
all
()
context
[
'
musicfoc
us_list
'
]
=
MusicFocus
.
objects
.
all
()
context
[
'
showinformation
_list
'
]
=
ShowInformation
.
objects
.
all
()
context
[
'
showtopic
_list
'
]
=
ShowTopic
.
objects
.
all
()
context
[
'
broadcastformat
s
'
]
=
BroadcastFormat
.
objects
.
all
()
context
[
'
musicfoc
i
'
]
=
MusicFocus
.
objects
.
all
()
context
[
'
showinformation
s
'
]
=
ShowInformation
.
objects
.
all
()
context
[
'
showtopic
s
'
]
=
ShowTopic
.
objects
.
all
()
return
context
...
...
@@ -47,3 +49,53 @@ class RecommendationsView(ListView):
in_one_week
=
now
+
timedelta
(
weeks
=
1
)
return
Note
.
objects
.
filter
(
status
=
1
,
timeslot__start__range
=
(
now
,
in_one_week
))[:
10
]
class
TodayScheduleView
(
TodayArchiveView
):
model
=
TimeSlot
allow_future
=
True
date_field
=
'
start
'
context_object_name
=
'
timeslots
'
template_name
=
'
program/today_schedule.html
'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
TodayScheduleView
,
self
).
get_context_data
(
**
kwargs
)
now
=
datetime
.
now
()
midnight
=
datetime
.
combine
(
date
.
today
(),
time
(
23
,
59
))
context
[
'
broadcastformats
'
]
=
BroadcastFormat
.
objects
.
all
()
context
[
'
recommendations
'
]
=
Note
.
objects
.
filter
(
status
=
1
,
timeslot__start__range
=
(
now
,
midnight
))
return
context
class
DayScheduleView
(
DayArchiveView
):
model
=
TimeSlot
allow_future
=
True
date_field
=
'
start
'
month_format
=
'
%m
'
context_object_name
=
'
timeslots
'
template_name
=
'
program/day_schedule.html
'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
DayScheduleView
,
self
).
get_context_data
(
**
kwargs
)
year
,
month
,
day
=
map
(
int
,
[
self
.
get_year
(),
self
.
get_month
(),
self
.
get_day
()])
this_day
=
datetime
(
year
,
month
,
day
,
0
,
0
)
midnight
=
datetime
(
year
,
month
,
day
,
23
,
59
)
context
[
'
broadcastformats
'
]
=
BroadcastFormat
.
objects
.
all
()
context
[
'
recommendations
'
]
=
Note
.
objects
.
filter
(
status
=
1
,
timeslot__start__range
=
(
this_day
,
midnight
))
return
context
class
CurrentShowView
(
TemplateView
):
template_name
=
'
program/current.html
'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
CurrentShowView
,
self
).
get_context_data
(
**
kwargs
)
context
[
'
current
'
]
=
TimeSlot
.
objects
.
get_or_create_current
()
context
[
'
next
'
]
=
TimeSlot
.
objects
.
get_or_create_current
().
get_next_by_start
()
context
[
'
after_next
'
]
=
TimeSlot
.
objects
.
get_or_create_current
().
get_next_by_start
().
get_next_by_start
()
return
context
\ No newline at end of file
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