X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f20a16da40cce193bc69547ea607436ce0a54370..2ff7d6d98d7ba61ce305fb2906bddaa37f320eb1:/apps/catalogue/models/tag.py diff --git a/apps/catalogue/models/tag.py b/apps/catalogue/models/tag.py index f7c5356a7..b0c75fbb4 100644 --- a/apps/catalogue/models/tag.py +++ b/apps/catalogue/models/tag.py @@ -3,9 +3,10 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.contrib.auth.models import User +from django.core.exceptions import ValidationError from django.db import models from django.db.models import permalink -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext, ugettext_lazy as _ from newtagging.models import TagBase @@ -71,6 +72,11 @@ class Tag(TagBase): def get_absolute_url(self): return ('catalogue.views.tagged_object_list', [self.url_chunk]) + def clean(self): + if self.category == 'book' and (self.gazeta_link or self.wiki_link): + raise ValidationError(ugettext( + u"Book tags can't have attached links. Set them directly on the book instead of it's tag.")) + @classmethod @permalink def create_url(cls, category, slug):