From ad720ba704c6988bfb3d5cc1af0ecd6f9dda188d Mon Sep 17 00:00:00 2001 From: roelio Date: Mon, 27 Oct 2014 10:23:49 +0100 Subject: [PATCH 1/4] Django 1.6 compatibility --- persistent_messages/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistent_messages/urls.py b/persistent_messages/urls.py index 02ebc94..ac83158 100644 --- a/persistent_messages/urls.py +++ b/persistent_messages/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns('', url(r'^detail/(?P\d+)/$', 'persistent_messages.views.message_detail', name='message_detail'), From d33b592f09f749e3392aa5658368e67e5c49be54 Mon Sep 17 00:00:00 2001 From: tony Date: Wed, 12 Nov 2014 10:16:16 +0100 Subject: [PATCH 2/4] Replace User with get_user_model --- persistent_messages/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/persistent_messages/models.py b/persistent_messages/models.py index cf75b65..c976c02 100644 --- a/persistent_messages/models.py +++ b/persistent_messages/models.py @@ -1,7 +1,7 @@ import persistent_messages from persistent_messages.constants import PERSISTENT_MESSAGE_LEVELS from django.db import models -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.utils.encoding import force_unicode from django.contrib import messages from django.contrib.messages import utils @@ -11,8 +11,8 @@ LEVEL_TAGS = utils.get_level_tags() class Message(models.Model): - user = models.ForeignKey(User, blank=True, null=True) - from_user = models.ForeignKey(User, blank=True, null=True, related_name="from_user") + user = models.ForeignKey(get_user_model(), blank=True, null=True) + from_user = models.ForeignKey(get_user_model(), blank=True, null=True, related_name="from_user") subject = models.CharField(max_length=255, blank=True, default='') message = models.TextField() LEVEL_CHOICES = ( From c714c21dc83fb6d98e062bda35132d8daacff8d1 Mon Sep 17 00:00:00 2001 From: Roel Obdam Date: Tue, 25 Nov 2014 15:13:49 +0100 Subject: [PATCH 3/4] Removed get_user_model from module level --- persistent_messages/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/persistent_messages/models.py b/persistent_messages/models.py index c976c02..83643e0 100644 --- a/persistent_messages/models.py +++ b/persistent_messages/models.py @@ -1,6 +1,7 @@ import persistent_messages from persistent_messages.constants import PERSISTENT_MESSAGE_LEVELS from django.db import models +from django.conf import settings from django.contrib.auth import get_user_model from django.utils.encoding import force_unicode from django.contrib import messages @@ -11,8 +12,8 @@ LEVEL_TAGS = utils.get_level_tags() class Message(models.Model): - user = models.ForeignKey(get_user_model(), blank=True, null=True) - from_user = models.ForeignKey(get_user_model(), blank=True, null=True, related_name="from_user") + user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True) + from_user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name="from_user") subject = models.CharField(max_length=255, blank=True, default='') message = models.TextField() LEVEL_CHOICES = ( @@ -83,4 +84,4 @@ def _get_tags(self): return u' '.join([label_tag, read_tag]) return read_tag tags = property(_get_tags) - \ No newline at end of file + From 857f7f1aeaecf890ffa8473cd66c5ed3c98292dd Mon Sep 17 00:00:00 2001 From: Roel Obdam Date: Sun, 3 Jan 2016 18:56:32 +0100 Subject: [PATCH 4/4] Add migrations --- .../migrations/0001_initial.py | 32 +++++++++++++++++++ persistent_messages/migrations/__init__.py | 0 2 files changed, 32 insertions(+) create mode 100644 persistent_messages/migrations/0001_initial.py create mode 100644 persistent_messages/migrations/__init__.py diff --git a/persistent_messages/migrations/0001_initial.py b/persistent_messages/migrations/0001_initial.py new file mode 100644 index 0000000..90ae73e --- /dev/null +++ b/persistent_messages/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Message', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('subject', models.CharField(default=b'', max_length=255, blank=True)), + ('message', models.TextField()), + ('level', models.IntegerField(choices=[(10, b'DEBUG'), (20, b'INFO'), (25, b'SUCCESS'), (30, b'WARNING'), (40, b'ERROR'), (110, b'PERSISTENT DEBUG'), (120, b'PERSISTENT INFO'), (125, b'PERSISTENT SUCCESS'), (130, b'PERSISTENT WARNING'), (140, b'PERSISTENT ERROR')])), + ('extra_tags', models.CharField(max_length=128)), + ('created', models.DateTimeField(auto_now_add=True)), + ('modified', models.DateTimeField(auto_now=True)), + ('read', models.BooleanField(default=False)), + ('expires', models.DateTimeField(null=True, blank=True)), + ('close_timeout', models.IntegerField(null=True, blank=True)), + ('from_user', models.ForeignKey(related_name='from_user', blank=True, to=settings.AUTH_USER_MODEL, null=True)), + ('user', models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True)), + ], + ), + ] diff --git a/persistent_messages/migrations/__init__.py b/persistent_messages/migrations/__init__.py new file mode 100644 index 0000000..e69de29