Cislo | funkce get

Cislo.get(rocnik, cislo)

vraci cislo posle cisla rocniku a cisla cisla
This commit is contained in:
Bc. Petr Pecha 2016-06-05 21:17:28 +02:00
parent c531fd4f78
commit a90b395494

View file

@ -11,6 +11,7 @@ from django.utils.encoding import force_unicode
from django.utils.text import slugify
from django.core.urlresolvers import reverse
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFit, Transpose
@ -28,6 +29,7 @@ from reversion import revisions as reversion
from seminar.utils import roman
class SeminarModelBase(models.Model):
class Meta:
@ -382,6 +384,15 @@ class Cislo(SeminarModelBase):
return None
return cs[i]
@classmethod
def get(cls, rocnik, cislo):
try:
r = Rocnik.objects.get(rocnik=rocnik)
c = r.cisla.get(cislo=cislo)
except ObjectDoesNotExist:
return None
return c
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible