fix rud for inactive news
This commit is contained in:
parent
5f4852d11e
commit
f026cfceba
|
|
@ -7,6 +7,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.postgres.fields import HStoreField
|
from django.contrib.postgres.fields import HStoreField
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Case, When
|
from django.db.models import Case, When
|
||||||
|
from django.urls.exceptions import NoReverseMatch
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
@ -295,7 +296,10 @@ class News(GalleryMixin, BaseAttributes, TranslatedFieldsMixin, HasTagsMixin,
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def web_url(self):
|
def web_url(self):
|
||||||
|
try:
|
||||||
return reverse('web:news:rud', kwargs={'slug': next(iter(self.slugs.values()))})
|
return reverse('web:news:rud', kwargs={'slug': next(iter(self.slugs.values()))})
|
||||||
|
except NoReverseMatch as e:
|
||||||
|
return None # no active links
|
||||||
|
|
||||||
def should_read(self, user):
|
def should_read(self, user):
|
||||||
return self.__class__.objects.should_read(self, user)[:3]
|
return self.__class__.objects.should_read(self, user)[:3]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user