Commit 88269fef authored by Zachary Seguin's avatar Zachary Seguin

Merge branch 'fix-24' into 'master'

Add fix for archive search; properly translate the search page

Closes #24

See merge request !13
parents 6bd261bc 9bac63d8
Pipeline #141 passed with stages
in 6 minutes and 4 seconds
......@@ -49,5 +49,7 @@ common_js = Bundle(
'vendor/picker.date.js',
'vendor/picker.time.js',
'foundation.min.js',
'alerts_canada.en.js',
'alerts_canada.fr.js',
'alerts_canada.js',
output='alerts_canada/js/alerts_canada.js')
......@@ -117,3 +117,7 @@ def datetime(date):
@app.template_filter()
def short_datetime(date):
return format_datetime(date, 'medium')
@app.template_filter()
def picker_date(date):
return format_datetime(date, 'yyyy-MM-dd')
\ No newline at end of file
/*
The MIT License (MIT)
Copyright (c) 2018 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
if (window.lang == 'en') {
$.extend($.fn.pickadate.defaults, {
format: 'dddd, mmmm d, yyyy',
});
}
\ No newline at end of file
/*
The MIT License (MIT)
Copyright (c) 2018 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
if (window.lang == 'fr') {
$.extend($.fn.pickadate.defaults, {
monthsFull: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
monthsShort: ['janv', 'févr', 'mars', 'avril', 'mai', 'juin', 'juil', 'août', 'sept', 'oct', 'nov', 'déc'],
weekdaysShort: ['dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam'],
weekdaysFull: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
today: 'Aujourd\'hui',
clear: 'Effacer',
close: 'Annuler',
labelMonthNext: 'Le mois prochain',
labelMonthPrev: 'Le mois dernier',
labelMonthSelect: 'Choisir un mois',
labelYearSelect: 'Choisir une année',
format: 'dddd le d mmmm yyyy',
});
}
\ No newline at end of file
/*
The MIT License (MIT)
Copyright (c) 2015 Zachary Seguin
Copyright (c) 2015-2018 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -28,15 +28,18 @@ var maxDate = new Date();
maxDate.setDate(maxDate.getDate() + 1);
$('.datepicker').pickadate({
format: 'dddd, mmmm d, yyyy',
formatSubmit: 'yyyy-mm-dd',
min: new Date(2015, 4, 1),
max: maxDate
max: maxDate,
hiddenName: true,
selectMonths: true,
selectYears: true,
});
$('.timepicker').pickatime({
format: 'h:iA',
formatSubmit: 'HH:i',
min: false,
max: false
max: false,
hiddenName: true,
});
......@@ -9652,7 +9652,76 @@ Picker.extend( 'pickatime', TimePicker )
/*
The MIT License (MIT)
Copyright (c) 2015 Zachary Seguin
Copyright (c) 2018 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
if (window.lang == 'en') {
$.extend($.fn.pickadate.defaults, {
format: 'dddd, mmmm d, yyyy',
});
}
/*
The MIT License (MIT)
Copyright (c) 2018 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
if (window.lang == 'fr') {
$.extend($.fn.pickadate.defaults, {
monthsFull: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
monthsShort: ['janv', 'févr', 'mars', 'avril', 'mai', 'juin', 'juil', 'août', 'sept', 'oct', 'nov', 'déc'],
weekdaysShort: ['dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam'],
weekdaysFull: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
today: 'Aujourd\'hui',
clear: 'Effacer',
close: 'Annuler',
labelMonthNext: 'Le mois prochain',
labelMonthPrev: 'Le mois dernier',
labelMonthSelect: 'Choisir un mois',
labelYearSelect: 'Choisir une année',
format: 'dddd le d mmmm yyyy',
});
}
/*
The MIT License (MIT)
Copyright (c) 2015-2018 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -9679,15 +9748,18 @@ var maxDate = new Date();
maxDate.setDate(maxDate.getDate() + 1);
$('.datepicker').pickadate({
format: 'dddd, mmmm d, yyyy',
formatSubmit: 'yyyy-mm-dd',
min: new Date(2015, 4, 1),
max: maxDate
max: maxDate,
hiddenName: true,
selectMonths: true,
selectYears: true,
});
$('.timepicker').pickatime({
format: 'h:iA',
formatSubmit: 'HH:i',
min: false,
max: false
max: false,
hiddenName: true,
});
......@@ -123,14 +123,14 @@ def do_settings():
def alerts_archive():
from flask import request
if ( request.args.get('from-date_submit', None)
and request.args.get('from-time_submit', None)
and request.args.get('to-date_submit', None)
and request.args.get('to-time_submit', None)):
if ( request.args.get('from-date', None)
and request.args.get('from-time', None)
and request.args.get('to-date', None)
and request.args.get('to-time', None)):
# Get alerts for the time period
try:
from_date = helpers.get_timezone().localize(dateutil.parser.parse(request.args['from-date_submit'] + ' ' + request.args['from-time_submit'])).astimezone(pytz.utc)
to_date = helpers.get_timezone().localize(dateutil.parser.parse(request.args['to-date_submit'] + ' ' + request.args['to-time_submit'])).astimezone(pytz.utc)
from_date = helpers.get_timezone().localize(dateutil.parser.parse(request.args['from-date'] + ' ' + request.args['from-time'])).astimezone(pytz.utc)
to_date = helpers.get_timezone().localize(dateutil.parser.parse(request.args['to-date'] + ' ' + request.args['to-time'])).astimezone(pytz.utc)
alerts = Alert.query.filter((Alert.sent >= from_date) & (Alert.sent <= to_date)).join(Info).order_by(Alert.sent.desc(), Alert.superseded, Alert.processed.desc())
......
......@@ -8,10 +8,10 @@
<div class="row collapse postfix-radius">
<div class="medium-8 columns">
<input type="text" name="from-date" class="datepicker" value="{{ now | date }}">
<input type="text" name="from-date" class="datepicker" data-value="{{ now | picker_date }}">
</div>
<div class="medium-4 columns">
<input type="text" name="from-time" class="timepicker postfix" value="12:00AM">
<input type="text" name="from-time" class="timepicker postfix" data-value="00:00">
</div>
</div>
</div>
......@@ -20,10 +20,10 @@
<div class="row collapse postfix-radius">
<div class="medium-8 columns">
<input type="text" name="to-date" class="datepicker" value="{{ (now + timedelta(days=1)) | date }}">
<input type="text" name="to-date" class="datepicker" data-value="{{ (now + timedelta(days=1)) | picker_date }}">
</div>
<div class="medium-4 columns">
<input type="text" name="to-time" class="timepicker postfix" value="12:00AM">
<input type="text" name="to-time" class="timepicker postfix" data-value="00:00">
</div>
</div>
</div>
......
......@@ -109,6 +109,9 @@
</div>
</footer>
<script>
window.lang = "{{ g.lang }}";
</script>
{% assets "common_js" %}
<script src="{{ ASSET_URL }}"></script>
{% endassets %}
......
......@@ -72,7 +72,7 @@ msgstr "Vos paramètres ont été sauvegardés."
#: pyalertscanada/web/routing_web.py:140
msgid "Alerts archive results"
msgstr "Les résultats de recherche du l'historique des alerts"
msgstr "Les résultats du recherche de l'historique des alertes"
#: pyalertscanada/web/routing_web.py:142
msgid "Please provide a valid date."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment