renamed statistic token, made it readonly

This commit is contained in:
tkupek 2016-03-05 13:31:42 +01:00
parent 9b0708fdff
commit c7e3d50038
6 changed files with 35 additions and 5 deletions

Binary file not shown.

View file

@ -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)

View file

@ -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),
),
]

View file

@ -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

View file

@ -24,7 +24,7 @@
<img src="{{ settings.logo }}" class="mainLogo">
<h1>{{ settings.title }}</h1>
<p>{{ settings.message_welcome_user }}</p>
<p>{{ settings.message_welcome_user|safe }}</p>
<div class="progress">
<div id="progressbar" class="progress-bar progress-bar-striped" role="progressbar" style="width: {{ progress }}%">
</div>

View file

@ -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