diff --git a/db.sqlite3 b/db.sqlite3 index 0a4db40..d96cfdf 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/tkupek_elearning/elearning/admin.py b/tkupek_elearning/elearning/admin.py index fe36c51..e31ad76 100644 --- a/tkupek_elearning/elearning/admin.py +++ b/tkupek_elearning/elearning/admin.py @@ -24,7 +24,7 @@ class UserAdmin(admin.ModelAdmin): def get_readonly_fields(self, request, obj=None): - return self.readonly_fields + ('token', 'last_seen') + return self.readonly_fields + ('token', 'last_seen', 'completed') class SettingAdmin(admin.ModelAdmin): diff --git a/tkupek_elearning/elearning/migrations/0029_auto_20160305_1409.py b/tkupek_elearning/elearning/migrations/0029_auto_20160305_1409.py new file mode 100644 index 0000000..83fae14 --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0029_auto_20160305_1409.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-03-05 14:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('elearning', '0028_auto_20160305_1338'), + ] + + operations = [ + migrations.RenameField( + model_name='user', + old_name='completed_message_shown', + new_name='completed', + ), + ] diff --git a/tkupek_elearning/elearning/models.py b/tkupek_elearning/elearning/models.py index 45855a0..fe455a2 100644 --- a/tkupek_elearning/elearning/models.py +++ b/tkupek_elearning/elearning/models.py @@ -66,7 +66,7 @@ class User(models.Model): token = models.CharField(max_length=40, null=True, default=gen_token, unique=True) name = models.CharField(max_length=100, null=False) last_seen = models.DateTimeField(null=True, blank=True) - completed_message_shown = models.BooleanField(null=False, default=False) + completed = models.BooleanField(null=False, default=False) def __unicode__(self): return self.name diff --git a/tkupek_elearning/elearning/static/js/elearning.js b/tkupek_elearning/elearning/static/js/elearning.js index 346dabe..58eeaa3 100644 --- a/tkupek_elearning/elearning/static/js/elearning.js +++ b/tkupek_elearning/elearning/static/js/elearning.js @@ -22,10 +22,12 @@ var QueryString = function () { }(); window.onload = init(); -//window.onbeforeunload = function() { - //var message = document.getElementById("popup-leave-message").innerHTML; - //return message; - //} +window.onbeforeunload = function() { + if(document.getElementById("progressbar").style.width != "100%") { + var message = document.getElementById("popup-leave-message").innerHTML; + return message; + } + } function init() { enable_disable_question(); diff --git a/tkupek_elearning/elearning/views.py b/tkupek_elearning/elearning/views.py index 4e381ad..5c11710 100644 --- a/tkupek_elearning/elearning/views.py +++ b/tkupek_elearning/elearning/views.py @@ -111,9 +111,9 @@ def get_answer(request): progress = get_progress(user) show_completed = False - if progress is 100 and user.completed_message_shown is False: + if progress is 100 and user.completed is False: show_completed = True - user.completed_message_shown = True + user.completed = True user.save() holder = {'options_id': options_id, 'progress': str(progress), 'show_completed': show_completed} diff --git a/tkupek_elearning/settings.py b/tkupek_elearning/settings.py index 5b3dca0..bb86b4a 100644 --- a/tkupek_elearning/settings.py +++ b/tkupek_elearning/settings.py @@ -23,7 +23,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = '_*hrxgzo(8hkrp5f8n4j9vo15acsy0b88yiy$6d5ezwi&pns(j' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False ALLOWED_HOSTS = ["127.0.0.1", "localhost"]