Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
energy
bmon
Commits
daea6179
Commit
daea6179
authored
Oct 29, 2016
by
Alan Mitchell
Browse files
Databsae Migrations for Periodic Scripts.
parent
bf5305db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
5 deletions
+57
-5
bmsapp/migrations/0010_periodicscript.py
bmsapp/migrations/0010_periodicscript.py
+27
-0
bmsapp/migrations/0011_auto_20161028_1951.py
bmsapp/migrations/0011_auto_20161028_1951.py
+25
-0
bmsapp/view_util.py
bmsapp/view_util.py
+5
-5
No files found.
bmsapp/migrations/0010_periodicscript.py
0 → 100644
View file @
daea6179
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bmsapp'
,
'0009_auto_20160322_1730'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'PeriodicScript'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'script_file_name'
,
models
.
CharField
(
max_length
=
50
,
verbose_name
=
b
'File name of script'
)),
(
'period'
,
models
.
IntegerField
(
default
=
3600
,
verbose_name
=
b
'How often should script run'
,
choices
=
[(
300
,
b
'5 min'
),
(
600
,
b
'10 min'
),
(
900
,
b
'15 min'
),
(
1800
,
b
'30 min'
),
(
3600
,
b
'1 hr'
),
(
7200
,
b
'2 hr'
),
(
14400
,
b
'4 hr'
),
(
21600
,
b
'6 hr'
),
(
43200
,
b
'12 hr'
),
(
86400
,
b
'24 hr'
)])),
(
'script_parameters'
,
models
.
TextField
(
verbose_name
=
b
'Script Parameters in YAML form'
,
blank
=
True
)),
(
'script_results'
,
models
.
TextField
(
verbose_name
=
b
'Script results in YAML form'
,
blank
=
True
)),
],
options
=
{
},
bases
=
(
models
.
Model
,),
),
]
bmsapp/migrations/0011_auto_20161028_1951.py
0 → 100644
View file @
daea6179
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-10-29 03:51
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bmsapp'
,
'0010_periodicscript'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'alertcondition'
,
name
=
'recipients'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
to
=
'bmsapp.AlertRecipient'
,
verbose_name
=
b
'Who should be notified?'
),
),
migrations
.
AlterField
(
model_name
=
'building'
,
name
=
'sensors'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
through
=
'bmsapp.BldgToSensor'
,
to
=
'bmsapp.Sensor'
),
),
]
bmsapp/view_util.py
View file @
daea6179
...
...
@@ -2,7 +2,7 @@
Helper functions for the views in this BMS application.
'''
import
importlib
from
django.template
import
Context
,
loader
from
django.template
import
loader
import
models
,
reports
.
basechart
...
...
@@ -48,7 +48,7 @@ def group_list_html():
ID of the first group, which is selected.
"""
# always have the All Buildings option, which has the special id of 0.
groups
=
[
(
0
,
'All Facilities'
)
]
groups
=
[
(
0
,
'All Facilities'
,
''
)
]
# add the rest of the groups.
for
gp
in
models
.
BuildingGroup
.
objects
.
all
():
...
...
@@ -58,7 +58,7 @@ def group_list_html():
selected_gp
=
groups
[
0
][
0
]
t
=
loader
.
get_template
(
'bmsapp/select_list.html'
)
return
t
.
render
(
Context
(
{
'item_list'
:
groups
,
'id_to_select'
:
selected_gp
}
)
),
selected_gp
return
t
.
render
(
{
'item_list'
:
groups
,
'id_to_select'
:
selected_gp
}
),
selected_gp
def
bldg_list_html
(
bldg_group_id
,
selected_bldg_id
=
None
):
...
...
@@ -84,7 +84,7 @@ def bldg_list_html(bldg_group_id, selected_bldg_id=None):
selected_bldg_id
=
bldgs
[
0
][
0
]
t
=
loader
.
get_template
(
'bmsapp/select_list.html'
)
return
t
.
render
(
Context
(
{
'item_list'
:
bldgs
,
'id_to_select'
:
selected_bldg_id
}
)
),
selected_bldg_id
return
t
.
render
(
{
'item_list'
:
bldgs
,
'id_to_select'
:
selected_bldg_id
}
),
selected_bldg_id
def
chart_list_html
(
group_id
,
bldg_id
):
...
...
@@ -133,7 +133,7 @@ def chart_list_html(group_id, bldg_id):
item_list
.
append
(
(
cht
.
id
,
cht
.
title
,
attrs
)
)
t
=
loader
.
get_template
(
'bmsapp/select_list.html'
)
return
t
.
render
(
Context
(
{
'item_list'
:
item_list
,
'id_to_select'
:
id_to_select
}
)
),
id_to_select
return
t
.
render
(
{
'item_list'
:
item_list
,
'id_to_select'
:
id_to_select
}
),
id_to_select
def
sensor_list_html
(
bldg_id
):
"""Returns the option list HTML for a Select control that allows
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment