X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3204e4303148302d278036eebcfc8cb105cc97d7..df341bdd09208d2b0f84060454cc0000df19deba:/src/catalogue/models/image.py?ds=sidebyside diff --git a/src/catalogue/models/image.py b/src/catalogue/models/image.py old mode 100755 new mode 100644 index 8cadcec2..becc308b --- a/src/catalogue/models/image.py +++ b/src/catalogue/models/image.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -7,6 +5,7 @@ from django.conf import settings from django.contrib.sites.models import Site from django.db import models from django.template.loader import render_to_string +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from catalogue.helpers import cached_in_field from catalogue.models import Project @@ -21,7 +20,7 @@ class Image(dvcs_models.Document): title = models.CharField(_('title'), max_length=255, blank=True) slug = models.SlugField(_('slug'), unique=True) public = models.BooleanField(_('public'), default=True, db_index=True) - project = models.ForeignKey(Project, null=True, blank=True) + project = models.ForeignKey(Project, models.SET_NULL, null=True, blank=True) # cache _new_publishable = models.NullBooleanField(editable=False) @@ -41,9 +40,8 @@ class Image(dvcs_models.Document): def __str__(self): return self.title - @models.permalink def get_absolute_url(self): - return ("catalogue_image", [self.slug]) + return reverse("catalogue_image", args=[self.slug]) def correct_about(self): return ["http://%s%s" % ( @@ -101,7 +99,7 @@ class Image(dvcs_models.Document): return None def accessible(self, request): - return self.public or request.user.is_authenticated() + return self.public or request.user.is_authenticated def is_new_publishable(self): change = self.publishable()