Browse Source

Cislo | funkce get

Cislo.get(rocnik, cislo)

vraci cislo posle cisla rocniku a cisla cisla
remotes/origin/korekturovatko_emaily
Bc. Petr Pecha 9 years ago
parent
commit
a90b395494
  1. 11
      seminar/models.py

11
seminar/models.py

@ -11,6 +11,7 @@ from django.utils.encoding import force_unicode
from django.utils.text import slugify from django.utils.text import slugify
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from imagekit.models import ImageSpecField, ProcessedImageField from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFit, Transpose from imagekit.processors import ResizeToFit, Transpose
@ -28,6 +29,7 @@ from reversion import revisions as reversion
from seminar.utils import roman from seminar.utils import roman
class SeminarModelBase(models.Model): class SeminarModelBase(models.Model):
class Meta: class Meta:
@ -382,6 +384,15 @@ class Cislo(SeminarModelBase):
return None return None
return cs[i] 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) @reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible @python_2_unicode_compatible

Loading…
Cancel
Save