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 diff --git a/persistent_messages/models.py b/persistent_messages/models.py index cf75b65..83643e0 100644 --- a/persistent_messages/models.py +++ b/persistent_messages/models.py @@ -1,7 +1,8 @@ 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.conf import settings +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 +12,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(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 + 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'),