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
6eabfdd6
Commit
6eabfdd6
authored
7 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
added sepcial show timeslot export
parent
f1c2a398
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
program/utils.py
+10
-0
10 additions, 0 deletions
program/utils.py
program/views.py
+19
-1
19 additions, 1 deletion
program/views.py
pv/urls.py
+3
-2
3 additions, 2 deletions
pv/urls.py
with
32 additions
and
3 deletions
program/utils.py
+
10
−
0
View file @
6eabfdd6
...
...
@@ -40,6 +40,16 @@ def get_automation_id_choices():
return
shows
def
get_cached_shows
():
cache_dir
=
getattr
(
settings
,
'
AUTOMATION_CACHE_DIR
'
,
'
cache
'
)
cached_shows
=
join
(
cache_dir
,
'
shows.json
'
)
shows
=
{}
with
open
(
cached_shows
)
as
shows_json
:
shows
=
json
.
loads
(
shows_json
.
read
())
return
shows
def
tofirstdayinisoweek
(
year
,
week
):
# http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python
ret
=
datetime
.
strptime
(
'
%04d-%02d-1
'
%
(
year
,
week
),
'
%Y-%W-%w
'
)
...
...
This diff is collapsed.
Click to expand it.
program/views.py
+
19
−
1
View file @
6eabfdd6
...
...
@@ -10,7 +10,7 @@ from django.views.generic.list import ListView
from
models
import
BroadcastFormat
,
MusicFocus
,
Note
,
Show
,
ShowInformation
,
ShowTopic
,
TimeSlot
,
Host
from
program.utils
import
tofirstdayinisoweek
from
program.utils
import
tofirstdayinisoweek
,
get_cached_shows
class
HostListView
(
ListView
):
...
...
@@ -211,3 +211,21 @@ def json_day_schedule(request, year=None, month=None, day=None):
return
HttpResponse
(
json
.
dumps
(
schedule
,
ensure_ascii
=
False
,
encoding
=
'
utf8
'
).
encode
(
'
utf8
'
),
content_type
=
"
application/json; charset=utf-8
"
)
def
json_timeslots_specials
(
request
):
specials
=
{}
shows
=
get_cached_shows
()[
'
shows
'
]
for
show
in
shows
:
show
[
'
pv_id
'
]
=
-
1
if
show
[
'
type
'
]
==
'
s
'
:
specials
[
show
[
'
id
'
]]
=
show
for
ts
in
TimeSlot
.
objects
.
filter
(
end__gt
=
datetime
.
now
).
filter
(
programslot__automation_id__in
=
specials
.
iterkeys
()):
automation_id
=
ts
.
programslot
.
automation_id
specials
[
automation_id
][
'
pv_id
'
]
=
int
(
ts
.
programslot
.
show
.
id
)
specials
[
automation_id
][
'
pv_name
'
]
=
ts
.
programslot
.
show
.
name
specials
[
automation_id
][
'
pv_start
'
]
=
ts
.
start
.
strftime
(
'
%Y-%m-%d_%H:%M:%S
'
)
specials
[
automation_id
][
'
pv_end
'
]
=
ts
.
end
.
strftime
(
'
%Y-%m-%d_%H:%M:%S
'
)
return
HttpResponse
(
json
.
dumps
(
specials
,
ensure_ascii
=
False
,
encoding
=
'
utf8
'
).
encode
(
'
utf8
'
),
content_type
=
"
application/json; charset=utf-8
"
)
This diff is collapsed.
Click to expand it.
pv/urls.py
+
3
−
2
View file @
6eabfdd6
...
...
@@ -2,7 +2,7 @@ from django.conf import settings
from
django.conf.urls
import
patterns
,
url
,
include
from
django.contrib
import
admin
from
program.views
import
json_day_schedule
from
program.views
import
json_day_schedule
,
json_timeslots_specials
admin
.
autodiscover
()
...
...
@@ -11,7 +11,8 @@ urlpatterns = patterns('',
url
(
r
'
^program/
'
,
include
(
'
program.urls
'
)),
url
(
r
'
^nop
'
,
include
(
'
nop.urls
'
)),
url
(
r
'
^tinymce/
'
,
include
(
'
tinymce.urls
'
)),
url
(
r
'
^export/day_schedule/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$
'
,
json_day_schedule
)
url
(
r
'
^export/day_schedule/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$
'
,
json_day_schedule
),
url
(
r
'
^export/timeslots_specials/$
'
,
json_timeslots_specials
)
)
if
settings
.
DEBUG
:
...
...
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