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
e89b4c50
You need to sign in or sign up before continuing.
Commit
e89b4c50
authored
11 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
added JSON export for automation.
parent
6e8c1713
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
program/models.py
+4
-2
4 additions, 2 deletions
program/models.py
program/utils.py
+9
-0
9 additions, 0 deletions
program/utils.py
program/views.py
+21
-0
21 additions, 0 deletions
program/views.py
urls.py
+3
-0
3 additions, 0 deletions
urls.py
with
37 additions
and
2 deletions
program/models.py
+
4
−
2
View file @
e89b4c50
...
...
@@ -9,6 +9,8 @@ from datetime import date, datetime, time, timedelta
from
dateutil.relativedelta
import
relativedelta
from
dateutil.rrule
import
rrule
from
utils
import
get_automation_id_choices
class
BroadcastFormat
(
models
.
Model
):
format
=
models
.
CharField
(
_
(
"
Format
"
),
max_length
=
32
)
slug
=
models
.
SlugField
(
_
(
"
Slug
"
),
max_length
=
32
,
unique
=
True
)
...
...
@@ -227,7 +229,7 @@ class Show(models.Model):
email
=
models
.
EmailField
(
_
(
"
E-Mail
"
),
blank
=
True
,
null
=
True
)
website
=
models
.
URLField
(
_
(
"
Website
"
),
blank
=
True
,
null
=
True
)
cba_series_id
=
models
.
IntegerField
(
_
(
"
CBA series ID
"
),
blank
=
True
,
null
=
True
)
automation_id
=
models
.
IntegerField
(
_
(
"
Automation ID
"
),
blank
=
True
,
null
=
True
)
automation_id
=
models
.
IntegerField
(
_
(
"
Automation ID
"
),
blank
=
True
,
null
=
True
,
choices
=
get_automation_id_choices
()
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
last_updated
=
models
.
DateTimeField
(
auto_now
=
True
,
editable
=
False
)
...
...
@@ -294,7 +296,7 @@ class ProgramSlot(models.Model):
tend
=
models
.
TimeField
(
_
(
"
End time
"
))
until
=
models
.
DateField
(
_
(
"
Last date
"
))
is_repetition
=
models
.
BooleanField
(
_
(
"
Is repetition
"
),
default
=
False
)
automation_id
=
models
.
IntegerField
(
_
(
"
Automation ID
"
),
blank
=
True
,
null
=
True
)
automation_id
=
models
.
IntegerField
(
_
(
"
Automation ID
"
),
blank
=
True
,
null
=
True
,
choices
=
get_automation_id_choices
()
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
last_updated
=
models
.
DateTimeField
(
auto_now
=
True
,
editable
=
False
)
...
...
This diff is collapsed.
Click to expand it.
program/utils.py
0 → 100644
+
9
−
0
View file @
e89b4c50
from
django.conf
import
settings
import
json
import
urllib
def
get_automation_id_choices
():
shows_list
=
json
.
load
(
urllib
.
urlopen
(
settings
.
AUTOMATION_BASE_URL
))[
'
shows
'
]
shows
=
[(
s
[
'
id
'
],
s
[
'
title
'
])
for
s
in
shows_list
]
return
shows
\ No newline at end of file
This diff is collapsed.
Click to expand it.
program/views.py
+
21
−
0
View file @
e89b4c50
from
django.views.generic
import
list_detail
,
simple
from
django.shortcuts
import
get_object_or_404
from
django.db.models
import
Q
from
django.http
import
HttpResponse
from
models
import
BroadcastFormat
,
MusicFocus
,
Note
,
Show
,
ShowInformation
,
ShowTopic
,
TimeSlot
from
datetime
import
date
,
datetime
,
time
,
timedelta
import
json
def
show_list
(
request
):
queryset
=
Show
.
objects
.
filter
(
programslots__until__gt
=
date
.
today
()).
exclude
(
id
=
1
).
distinct
()
...
...
@@ -127,3 +130,21 @@ def styles(request):
extra_context
[
'
showinformation
'
]
=
ShowInformation
.
objects
.
all
()
extra_context
[
'
showtopic
'
]
=
ShowTopic
.
objects
.
all
()
return
simple
.
direct_to_template
(
request
,
template
=
'
program/styles.css
'
,
mimetype
=
'
text/css
'
,
extra_context
=
extra_context
)
def
json_day_schedule
(
request
,
year
=
None
,
month
=
None
,
day
=
None
):
if
year
is
None
and
month
is
None
and
day
is
None
:
today
=
datetime
.
combine
(
date
.
today
(),
time
(
6
,
0
))
else
:
today
=
datetime
.
strptime
(
'
%s__%s__%s__06__00
'
%
(
year
,
month
,
day
),
'
%Y__%m__%d__%H__%M
'
)
timeslots
=
TimeSlot
.
objects
.
get_day_timeslots
(
today
)
schedule
=
[]
for
ts
in
timeslots
:
if
ts
.
programslot
.
automation_id
:
schedule
.
append
((
ts
.
start
.
strftime
(
'
%H:%M:%S
'
),
ts
.
programslot
.
automation_id
))
elif
ts
.
programslot
.
show
.
automation_id
:
schedule
.
append
((
ts
.
start
.
strftime
(
'
%H:%M:%S
'
),
ts
.
programslot
.
show
.
automation_id
))
else
:
schedule
.
append
((
ts
.
start
.
strftime
(
'
%H:%M:%S
'
),
-
1
))
return
HttpResponse
(
json
.
dumps
(
schedule
),
content_type
=
"
application/json
"
)
This diff is collapsed.
Click to expand it.
urls.py
+
3
−
0
View file @
e89b4c50
...
...
@@ -4,12 +4,15 @@ from django.contrib import admin
admin
.
autodiscover
()
from
program.views
import
json_day_schedule
urlpatterns
=
patterns
(
''
,
(
r
'
^admin/
'
,
include
(
admin
.
site
.
urls
)),
(
r
'
^program/
'
,
include
(
'
program.urls
'
)),
(
r
'
^nop
'
,
include
(
'
nop.urls
'
)),
(
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
),
)
if
settings
.
DEBUG
:
urlpatterns
+=
patterns
(
''
,
(
r
'
^site_media/(?P<path>.*)$
'
,
'
django.views.static.serve
'
,
{
'
document_root
'
:
settings
.
MEDIA_ROOT
})
...
...
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