fix rud for inactive news

This commit is contained in:
Kuroshini 2020-01-20 14:52:22 +03:00
parent 5f4852d11e
commit f026cfceba

View File

@ -7,6 +7,7 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import HStoreField
from django.db import models
from django.db.models import Case, When
from django.urls.exceptions import NoReverseMatch
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from rest_framework.reverse import reverse
@ -295,7 +296,10 @@ class News(GalleryMixin, BaseAttributes, TranslatedFieldsMixin, HasTagsMixin,
@property
def web_url(self):
return reverse('web:news:rud', kwargs={'slug': next(iter(self.slugs.values()))})
try:
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):
return self.__class__.objects.should_read(self, user)[:3]