Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 1.6 compatibility #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions persistent_messages/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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)),
],
),
]
Empty file.
9 changes: 5 additions & 4 deletions persistent_messages/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = (
Expand Down Expand Up @@ -83,4 +84,4 @@ def _get_tags(self):
return u' '.join([label_tag, read_tag])
return read_tag
tags = property(_get_tags)


2 changes: 1 addition & 1 deletion persistent_messages/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import patterns, url

urlpatterns = patterns('',
url(r'^detail/(?P<message_id>\d+)/$', 'persistent_messages.views.message_detail', name='message_detail'),
Expand Down