Konverze bodu na decimal(8,1)
This commit is contained in:
parent
ef9c7aa497
commit
81cbf39df7
3 changed files with 38 additions and 6 deletions
30
seminar/migrations/0022_decimal_body.py
Normal file
30
seminar/migrations/0022_decimal_body.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import importlib
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
migration_0022 = importlib.import_module('seminar.migrations.0002_add_body_views')
|
||||||
|
print dir(migration_0022)
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0021_cislo_verejna_vysledkovka'),
|
||||||
|
]
|
||||||
|
operations = [
|
||||||
|
migrations.RunSQL(migration_0022.DROP_VIEWS),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='problem',
|
||||||
|
name='body',
|
||||||
|
field=models.DecimalField(null=True, verbose_name='maximum bod\u016f', max_digits=8, decimal_places=1, blank=True),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='reseni',
|
||||||
|
name='body',
|
||||||
|
field=models.DecimalField(null=True, verbose_name='body', max_digits=8, decimal_places=1, blank=True),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
migrations.RunSQL(migration_0022.CREATE_VIEWS),
|
||||||
|
]
|
|
@ -364,7 +364,7 @@ class Problem(SeminarModelBase):
|
||||||
cislo_reseni = models.ForeignKey(Cislo, verbose_name=u'číslo řešení', blank=True, null=True, related_name=u'resene_problemy',
|
cislo_reseni = models.ForeignKey(Cislo, verbose_name=u'číslo řešení', blank=True, null=True, related_name=u'resene_problemy',
|
||||||
help_text=u'Číslo s řešením úlohy, jen pro úlohy')
|
help_text=u'Číslo s řešením úlohy, jen pro úlohy')
|
||||||
|
|
||||||
body = models.IntegerField(u'maximum bodů', blank=True, null=True)
|
body = models.DecimalField(max_digits=8, decimal_places=1, verbose_name=u'maximum bodů', blank=True, null=True)
|
||||||
|
|
||||||
timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
|
timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ class Reseni(SeminarModelBase):
|
||||||
|
|
||||||
resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel', related_name='reseni')
|
resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel', related_name='reseni')
|
||||||
|
|
||||||
body = models.IntegerField(u'body', blank=True, null=True)
|
body = models.DecimalField(max_digits=8, decimal_places=1, verbose_name=u'body', blank=True, null=True)
|
||||||
|
|
||||||
cislo_body = models.ForeignKey(Cislo, verbose_name=u'číslo pro body', related_name='bodovana_reseni', blank=True, null=True)
|
cislo_body = models.ForeignKey(Cislo, verbose_name=u'číslo pro body', related_name='bodovana_reseni', blank=True, null=True)
|
||||||
|
|
||||||
|
@ -562,7 +562,8 @@ class VysledkyBase(SeminarModelBase):
|
||||||
|
|
||||||
resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel', db_column='resitel_id', on_delete=models.DO_NOTHING)
|
resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel', db_column='resitel_id', on_delete=models.DO_NOTHING)
|
||||||
|
|
||||||
body = models.IntegerField(u'body za číslo', db_column='body')
|
body = models.DecimalField(max_digits=8, decimal_places=1, db_column='body',
|
||||||
|
verbose_name=u'body za číslo')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode(u"%s: %sb (%s)" % (self.resitel.plne_jmeno(), self.body, str(self.cislo)))
|
return force_unicode(u"%s: %sb (%s)" % (self.resitel.plne_jmeno(), self.body, str(self.cislo)))
|
||||||
|
@ -589,7 +590,8 @@ class VysledkyKCislu(VysledkyBase):
|
||||||
abstract = False
|
abstract = False
|
||||||
managed = False
|
managed = False
|
||||||
|
|
||||||
body_celkem = models.IntegerField(u'body celkem do čísla', db_column='body_celkem')
|
body_celkem = models.DecimalField(max_digits=8, decimal_places=1, db_column='body_celkem',
|
||||||
|
verbose_name=u'body celkem do čísla')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# NOTE: DB HOG (ale nepouzivany)
|
# NOTE: DB HOG (ale nepouzivany)
|
||||||
|
|
|
@ -29,7 +29,7 @@ class SeminarBasicTests(TestCase):
|
||||||
def test_render_cislo_e2e(self):
|
def test_render_cislo_e2e(self):
|
||||||
cs = Cislo.objects.all()
|
cs = Cislo.objects.all()
|
||||||
for c in cs[:4]:
|
for c in cs[:4]:
|
||||||
url = reverse('seminar_cislo', args=(c.id,))
|
url = c.verejne_url()
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.content) >= 100
|
assert len(r.content) >= 100
|
||||||
|
@ -38,7 +38,7 @@ class SeminarBasicTests(TestCase):
|
||||||
def test_render_problem_e2e(self):
|
def test_render_problem_e2e(self):
|
||||||
ps = Problem.objects.all()
|
ps = Problem.objects.all()
|
||||||
for p in ps[:4]:
|
for p in ps[:4]:
|
||||||
url = reverse('seminar_problem', args=(p.id,))
|
url = p.verejne_url()
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.content) >= 100
|
assert len(r.content) >= 100
|
||||||
|
|
Loading…
Reference in a new issue