From c7e3d50038dbca6a1eec8c1c44c2ace234ff44da Mon Sep 17 00:00:00 2001 From: tkupek Date: Sat, 5 Mar 2016 13:31:42 +0100 Subject: [PATCH] renamed statistic token, made it readonly --- db.sqlite3 | Bin 137216 -> 137216 bytes tkupek_elearning/elearning/admin.py | 7 ++++- .../migrations/0024_auto_20160305_1222.py | 25 ++++++++++++++++++ tkupek_elearning/elearning/models.py | 2 +- .../elearning/templates/elearning.html | 2 +- tkupek_elearning/elearning/views.py | 4 +-- 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 tkupek_elearning/elearning/migrations/0024_auto_20160305_1222.py diff --git a/db.sqlite3 b/db.sqlite3 index 7c942b4797d9a837edf1e0a6062b714f08b4a8b8..c2c53834cfc130732713e70c3143192ba0c001ad 100644 GIT binary patch delta 1001 zcma)4Uu=_A6u;-5cJ0@0rJXZFXQbc~wz+=2-~WEK)HOs5GNxwPiv*f4?MEpaEw-Jv3&)5o4y2n6Q3{eQ*ZB7g554L4(F*At62~>XUE8yTp6H@q&^BG; z!6j(#<~{9jX@^TQ-dArPig(MYw3ZSLQ#B0Jee3ffcWQZCL{4)xlSM-{bwhQpaP=q4 zJGvE?mNZe;G{y|??($GD)WdTGaErh#?&St-c}Id6F&hWo5C$5thTZ;kF9cyAQ+I0B zN-2A4wr^tji4AM;J-8WAptkI9b|wb=T@7ms$)1%lV`H10-9uhRvd zq#2rfe$Y?0J(v6U4P&yJw`QGcUS^Wc6sF}RnGb$QFeSmXxWo&hq?shDikUK4`+6_z zmU;tlpWr(GV}fqbB{~N8x&7M^dMzuEEhfAO;Qo1OyIXv}Z>Jcb|1oE#B}G(BS=Z#3 zcXjwuhyMhdsKyVM?U`ad&Ocu%*~Ld68)-EqN<3^uAI~)J?SZjw+1Tt2rmLEvv^Vy^ zc4&S05UC)nj>A|ewAm+khu|F^;x{<@EFKj8Z_z)y2;r#zU2fq_GkO^g^h|T{C`T{H RNV{W1Si8e!daVY@pIYwiyC-m#!tMG-ZwWAXo_h9zlSuUuVb^&kS7+pYNP+?7TWL% z%2>g6Ea4=6q^opQcLjXwHN!*tc)?V)F@5E3x7#WyQCabZ#jxKWV)x&ASm*RHn-~oQqjJD2N)bhp z*c{g{r%za=U{sX7Aw^acMPHxx7#GjM9#W%e;kh7M1&9-f!*5!|VLo98=*9I{bm50! z-$!Aaz&5k*1h%~EWiNJ}(7fw$cjsYjmk{7LJ3tmj4C7CV@?Ezrg-+ zH#kT{>$+pC*Bn}hzVXZm=6kpDYA%}`P>XD@^xdQQrBq4{sbM+n?+J)Ax0pEAE=AEcuWhh=8dlg`jZ$4d%yF!x(}PoA$((F mJEs>X!D2V`an=9CJ_}v7)zxxx9#&b>W?>{fb;(pRQu}{@m9?w@ diff --git a/tkupek_elearning/elearning/admin.py b/tkupek_elearning/elearning/admin.py index ea46478..fe36c51 100644 --- a/tkupek_elearning/elearning/admin.py +++ b/tkupek_elearning/elearning/admin.py @@ -27,6 +27,11 @@ class UserAdmin(admin.ModelAdmin): return self.readonly_fields + ('token', 'last_seen') +class SettingAdmin(admin.ModelAdmin): + def get_readonly_fields(self, request, obj=None): + + return self.readonly_fields + ('statistic_token',) + admin.site.register(Question, QuestionAdmin) -admin.site.register(Setting), +admin.site.register(Setting, SettingAdmin), admin.site.register(User, UserAdmin) diff --git a/tkupek_elearning/elearning/migrations/0024_auto_20160305_1222.py b/tkupek_elearning/elearning/migrations/0024_auto_20160305_1222.py new file mode 100644 index 0000000..66d625d --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0024_auto_20160305_1222.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-03-05 12:22 +from __future__ import unicode_literals + +from django.db import migrations, models +import tkupek_elearning.elearning.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('elearning', '0023_auto_20160305_1158'), + ] + + operations = [ + migrations.RemoveField( + model_name='setting', + name='token', + ), + migrations.AddField( + model_name='setting', + name='statistic_token', + field=models.CharField(default=tkupek_elearning.elearning.models.gen_token, max_length=40, null=True, unique=True), + ), + ] diff --git a/tkupek_elearning/elearning/models.py b/tkupek_elearning/elearning/models.py index 6a3469f..4e4f6f3 100644 --- a/tkupek_elearning/elearning/models.py +++ b/tkupek_elearning/elearning/models.py @@ -22,7 +22,7 @@ class Setting(models.Model): text_next = models.CharField(max_length=100, null=True) logo = models.CharField(max_length=256, null=False) active = models.BooleanField(unique=True, default=False) - token = models.CharField(max_length=40, null=True, default=gen_token) + statistic_token = models.CharField(max_length=40, null=True, default=gen_token, unique=True) def __unicode__(self): return self.title diff --git a/tkupek_elearning/elearning/templates/elearning.html b/tkupek_elearning/elearning/templates/elearning.html index 67b8913..7ca0743 100644 --- a/tkupek_elearning/elearning/templates/elearning.html +++ b/tkupek_elearning/elearning/templates/elearning.html @@ -24,7 +24,7 @@

{{ settings.title }}

-

{{ settings.message_welcome_user }}

+

{{ settings.message_welcome_user|safe }}

diff --git a/tkupek_elearning/elearning/views.py b/tkupek_elearning/elearning/views.py index a9757f4..f1ad9b9 100644 --- a/tkupek_elearning/elearning/views.py +++ b/tkupek_elearning/elearning/views.py @@ -8,7 +8,7 @@ import json from tkupek_elearning.elearning.models import Setting, Question, Option, UserAnswer, User, UserAnswerOptions -import pdb +#import pdb def get_progress(user): @@ -144,7 +144,7 @@ def statistic(request): return render_to_response('setting_null.html') try: - auth = Setting.objects.get(active=1, token=token) + auth = Setting.objects.get(active=1, statistic_token=token) except ObjectDoesNotExist: auth = None