diff --git a/app.py b/app.py index 0bc96d2..cc2fba4 100644 --- a/app.py +++ b/app.py @@ -7,7 +7,7 @@ from flask_login import current_user - +from requests.exceptions import HTTPError from database import db, init_db from models import get_base_info, get_segment, get_downloads, get_full_filename, User, Role from custom import ExtendedLoginForm @@ -87,8 +87,7 @@ def retrieve_transcript(file_id, position): file_id, position = _parse_args(file_id, position) try: obj = get_base_info(file_id) - if current_user.seconds_available < obj.segment_length: - from requests.exceptions import HTTPError + if current_user.seconds_available < obj.segment_length: raise HTTPError('You do not have enough credit available to download this segment') segment = get_segment(obj, file_id, position, update=True) current_user.seconds_available -= obj.segment_length @@ -155,7 +154,7 @@ def solution(file_id, position): re.sub(r'[\.,-]', '', segment.transcript.lower()) student_solution, google_solution = differ.diff_prettyHtml(differ.diff_main(student_solution, segment.transcript)) - return render_template('solution.html', obj=obj, file_id=file_id, segment=segment, + return render_template('solution.html', obj=obj, file_id=file_id, segment=segment, position=position, filename=full_filename, student_solution=student_solution, google_solution=google_solution, confidence='{:.2f}'.format(segment.confidence)) diff --git a/docker-compose.yaml b/docker-compose.yaml index 38206de..995c0ed 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3' services: flask: - image: huwf/dictogloss:0.3 + build: ./ ports: - 127.0.0.1:5000:5000 # - 127.0.0.1:5001:443 @@ -13,12 +13,17 @@ services: VIRTUAL_PORT: 5000 # VIRTUAL_PROTO: https LETSENCRYPT_HOST: dictogloss.huwfryer.co.uk - LETSENCRYPT_EMAIL: huwfryer@gmail.com + LETSENCRYPT_EMAIL: ${DEFAULT_EMAIL} + + DEFAULT_EMAIL: ${DEFAULT_EMAIL} + DEFAULT_PASSWORD: ${DEFAULT_PASSWORD} + volumes: - ./letsencrypt:/etc/letsencrypt - ./config.py:/usr/src/config.py - mp3:/usr/src/static/mp3 - + - ./database.db:/usr/src/database.db + - ./API_KEY.json:/usr/src/API_KEY.json # SEE: https://github.com/buchdag/letsencrypt-nginx-proxy-companion-compose/blob/master/2-containers/compose-v3/labels/docker-compose.yaml # For examples on how to set up the letsencrypt service nginx_proxy: @@ -52,7 +57,7 @@ services: restart: always volumes: - + db: mp3: conf: vhost: diff --git a/static/scripts/scripts.js b/static/scripts/scripts.js index 7dcd2e5..cf8ceca 100644 --- a/static/scripts/scripts.js +++ b/static/scripts/scripts.js @@ -36,7 +36,7 @@ $(document).ready(function () { // TODO: Don't know why this isn't working with jQuery, but this is simple enough for vanilla JS document.getElementById('retrieve').parentNode.parentNode.innerHTML = data; // Keep the "seconds available" up to date... - document.getElementById('seconds_available').innerHTML = parseInt($('audio')[0].duration); + $('#seconds_available').text(Math.floor(parseInt($('#seconds_available').text()) - $('audio')[0].duration)); $('.spinner-border').hide(); }); @@ -51,4 +51,9 @@ $(document).ready(function () { $('#playerSpeed').text(rate * 100); }); -}); \ No newline at end of file + // Only works on the POST solution view + $('#exercise').height($('#solution').height()); + +}); + + diff --git a/templates/base.html b/templates/base.html index dc9d93f..b891108 100644 --- a/templates/base.html +++ b/templates/base.html @@ -19,7 +19,9 @@
+ Seconds available: {{current_user.seconds_available}} +
{% endif %} @@ -65,4 +67,4 @@