Skip to content

Commit

Permalink
Merge pull request #233 from SEL-Columbia/staging
Browse files Browse the repository at this point in the history
0.2.8 Release
  • Loading branch information
vr2262 committed Jan 14, 2016
2 parents a39ca61 + 21d1aa4 commit 7bc5df4
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Several solutions exist to handle offline mobile data collection. While this typ

**Dokomo strives to simplify the process by integrating the elements of a data collection effort into a unified system, from creation of mobile-ready surveys to quick analysis and visualization of the collected data.**

The latest install script is here: https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.7/installer.sh
The latest install script is here: https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.8/installer.sh

## Features

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nginx:
- /etc/letsencrypt:/etc/letsencrypt
- /tmp:/tmp
webapp:
image: "selcolumbia/dokomoforms:0.2.7"
image: "selcolumbia/dokomoforms:0.2.8"
command: bash -c "./docker-wait-for-postgres.sh db && head -c 24 /dev/urandom > cookie_secret && python webapp.py"
links:
- "db:db"
Expand Down
10 changes: 7 additions & 3 deletions dokomoforms/handlers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ def user_survey_language(self, survey):
"""Return the logged-in User's selected language
for the given survey, or None if they do not have one."""
user = self.current_user_model
if (user
and survey.id in user.preferences
and 'display_language' in user.preferences[survey.id]):
if user is None:
return None
try:
return user.preferences[survey.id]['display_language']
except KeyError:
# preference has not been set
pass
return None

def set_default_headers(self):
Expand All @@ -107,6 +110,7 @@ def set_default_headers(self):
" cdn.leafletjs.com code.highcharts.com"
" momentjs.com cdn.datatables.net https://login.persona.org; "
"child-src login.persona.org; "
"frame-src login.persona.org; "
"style-src 'self' 'unsafe-inline'"
" fonts.googleapis.com cdn.leafletjs.com *.cloudfront.net;"
"font-src 'self' fonts.googleapis.com fonts.gstatic.com;"
Expand Down
15 changes: 15 additions & 0 deletions dokomoforms/static/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Dokomo Forms",
"short_name": "Dokomo Forms",
"start_url": "/enumerate/",
"scope": "/enumerate/",
"display": "standalone",
"icons": [
{
"src": "/static/dist/admin/img/favicon.png",
"sizes": "196x196",
"type": "image/png"
}
],
"lang": "en-US"
}
2 changes: 1 addition & 1 deletion dokomoforms/static/src/admin/js/account-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var AccountOverview = (function() {
zoom: 14,
attributionControl: false
});
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(map);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(map);
var markers = [];
_.each(submissions, function(submission) {
console.log(submission);
Expand Down
1 change: 1 addition & 0 deletions dokomoforms/static/src/common/js/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Nothing to see here
1 change: 1 addition & 0 deletions dokomoforms/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<link href="/static/dist/admin/css/admin.css" rel="stylesheet" type="text/css">

<link rel="icon" href="/static/dist/admin/img/favicon.png">
<link rel="manifest" href="/static/manifest.json">

<title>{{ options.organization }} Surveys -- Powered by DokomoData</title>
</head>
Expand Down
15 changes: 15 additions & 0 deletions dokomoforms/templates/view_enumerate.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@

<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,100' rel='stylesheet' type='text/css'>
<link rel="icon" href="/static/dist/survey/img/favicon.png">
<link rel="manifest" href="/static/manifest.json">
<script>
// From https://github.com/GoogleChrome/samples/blob/cbc8098c3ebda4dda0ff894673d3847eae31648f/app-install-banner/basic-banner/index.html
window.addEventListener('load', function() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/static/src/common/js/service-worker.js', { scope: '/static/src/common/js/' })
.then(function(r) {
console.log('registered service worker');
})
.catch(function(error) {
console.error(error);
});
};
});
</script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion dokomoforms/templates/view_visualize.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h4>Welcome {{ current_user }}</h4>
<script src="/static/lib.js"></script>
<script src="https://login.persona.org/include.js"></script>
<script src="/static/persona.js"></script>
<script src="http://d3js.org/d3.v3.js"></script>
<script src="https://d3js.org/d3.v3.js"></script>
<script src="/static/visualizations.js"></script>
{% if time_data %}
<script>
Expand Down
6 changes: 3 additions & 3 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
# Dokomo Forms installer for version 0.2.7
# Dokomo Forms installer for version 0.2.8
set -e

# Do you have docker installed?
Expand Down Expand Up @@ -105,8 +105,8 @@ $SUDO openssl dhparam -out /etc/letsencrypt/live/$LETSENCRYPT_DIR/dhparam.pem 20
printf "========================================\n"
printf " Downloading configuration files \n"
printf "========================================\n"
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.7/docker-compose.yml > docker-compose.yml
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.7/nginx.conf > nginx.conf
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.8/docker-compose.yml > docker-compose.yml
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.8/nginx.conf > nginx.conf

# Edit the configuration files
printf "========================================\n"
Expand Down
14 changes: 7 additions & 7 deletions tests/python/branch-heaven-fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,25 @@
models.construct_bucket(
bucket_type='multiple_choice',
bucket=node.choices[1],
),
],
),
],

nodes=[
models.construct_survey_node(
node=models.construct_node(
title={'English': 'mc text sub 1'},
type_constraint='text',
),
),
),
models.construct_survey_node(
node=models.construct_node(
title={'English': 'mc text sub 2'},
type_constraint='text',
),
),
]
)
]
),
]
)
]
))

survey.nodes.append(models.construct_survey_node(
Expand Down
14 changes: 12 additions & 2 deletions tests/python/test_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,15 @@ def test_url_slug_collision(self):
.get_attribute('class')
)
)
self.click(self.drv.find_element_by_class_name('save-survey-url'))
try:
self.click(self.drv.find_element_by_class_name('save-survey-url'))
except (WebDriverException, ValueError):
# Catch ValueError due to
# https://github.com/SeleniumHQ/selenium/issues/1470
#
# Certain browsers complain when you try to click something that's
# not clickable.
pass

self.get('/enumerate/slug')
self.assertEqual(
Expand Down Expand Up @@ -1430,6 +1438,7 @@ def test_logout(self):
# clicking logout should refresh the page
self.wait_for_element('menu', By.CLASS_NAME)
self.click(self.drv.find_element_by_class_name('menu'))
self.sleep()
self.click(
self.drv
.find_element_by_class_name('menu_logout')
Expand Down Expand Up @@ -4073,7 +4082,8 @@ def test_add_new_facility(self):
self.sleep()
self.wait_for_element(
'.btn-add-facility',
by=By.CSS_SELECTOR
by=By.CSS_SELECTOR,
timeout=10,
)
# click add button
self.click(
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ deps=
restructuredtext-lint

[flake8]
ignore=E402,E731
exclude=docs,node_modules
20 changes: 10 additions & 10 deletions webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ def __init__(self, session=None, options=options):

sur = SurveyResource

settings = {
'template_path': os.path.join(_pwd, 'dokomoforms', 'templates'),
'static_path': os.path.join(_pwd, 'dokomoforms', 'static'),
'default_handler_class': handlers.NotFound,
'xsrf_cookies': True,
'cookie_secret': get_cookie_secret(),
'login_url': '/',
'debug': options.debug,
}

urls = [
# Administrative
url(r'/', handlers.Index, name='index'),
Expand Down Expand Up @@ -252,16 +262,6 @@ def __init__(self, session=None, options=options):
),
]

settings = {
'template_path': os.path.join(_pwd, 'dokomoforms/templates'),
'static_path': os.path.join(_pwd, 'dokomoforms/static'),
'default_handler_class': handlers.NotFound,
'xsrf_cookies': True,
'cookie_secret': get_cookie_secret(),
'login_url': '/',
'debug': options.debug,
}

# HTTPS
if options.https:
settings['xsrf_cookie_kwargs'] = {'secure': True}
Expand Down

0 comments on commit 7bc5df4

Please sign in to comment.