From 4f232ee7e0ef28e8898f1ec1bf0c1a863180a412 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Mon, 23 Nov 2020 14:28:30 +0100 Subject: [PATCH] Migration step 3: Now compatible with Django 2.2 --- VIPSWeb/settings.py | 1 + common/middleware/whodid.py | 2 +- forecasts/models.py | 9 +++++++++ information/models.py | 4 ++++ vips_messages/models.py | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py index ac1cb4ce..f1eb8948 100755 --- a/VIPSWeb/settings.py +++ b/VIPSWeb/settings.py @@ -106,6 +106,7 @@ TEMPLATES = [ 'context_processors':[ 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.request', + 'django.contrib.messages.context_processors.messages', 'VIPSWeb.context_processors.settings' ] }, diff --git a/common/middleware/whodid.py b/common/middleware/whodid.py index 97b59e2d..8a40f004 100755 --- a/common/middleware/whodid.py +++ b/common/middleware/whodid.py @@ -36,7 +36,7 @@ class WhodidMiddleware(object): def process_request(self, request): if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): - if hasattr(request, 'user') and request.user.is_authenticated(): + if hasattr(request, 'user') and request.user.is_authenticated: user = request.user else: user = None diff --git a/forecasts/models.py b/forecasts/models.py index b4d6c235..7234e0b2 100755 --- a/forecasts/models.py +++ b/forecasts/models.py @@ -501,6 +501,9 @@ class MeasurementUnit(models.Model): opposite = models.BooleanField(default=False) def __unicode__(self): return self.name + def __str__(self): + return self.name + class Meta: ordering = ['name'] @@ -548,6 +551,9 @@ class HighChartsType(models.Model): name = models.CharField(max_length=63) def __unicode__(self): return self.name + + def __str__(self): + return self.name class ModelGraphParameter(models.Model): model_id = models.CharField(max_length=10, validators=[validate_model_id_length]) @@ -557,3 +563,6 @@ class ModelGraphParameter(models.Model): def __unicode__(self): return self.model_id + "/" + self.resultparameter.getNamespaceKey() + + def __str__(self): + return self.model_id + "/" + self.resultparameter.getNamespaceKey() diff --git a/information/models.py b/information/models.py index 5b2871fc..6594c756 100755 --- a/information/models.py +++ b/information/models.py @@ -10,6 +10,10 @@ from django.utils import translation class Information(models.Model): def __unicode__(self): return InformationLocale.get_heading_with_fallback(self.id) + + def __str__(self): + return InformationLocale.get_heading_with_fallback(self.id) + parent_information = models.ForeignKey('self', blank=True, null=True, related_name='children', verbose_name=_("Parent information"),on_delete=models.CASCADE) main_illustration = models.ImageField(upload_to='images/information', blank=True, verbose_name=_("Main illustration") ) ordering = models.IntegerField(default=0, verbose_name=_("Ordering")) diff --git a/vips_messages/models.py b/vips_messages/models.py index 59a5e34c..16803ab6 100755 --- a/vips_messages/models.py +++ b/vips_messages/models.py @@ -192,6 +192,8 @@ class Message: class Advertisement(models.Model): def __unicode__(self): return self.ad_heading + def __str__(self): + return self.ad_heading """ Represents an advertisement to be shown on the frontpage """ ad_heading = models.CharField(max_length=200, verbose_name=_("Headline")) ad_text = models.TextField() -- GitLab