mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-03-17 05:40:25 +00:00
Merge pull request #286 from TheOneAboveAllTitan/issues/28
[swapper] Removed hardlinks for Notification model #285
This commit is contained in:
commit
b42e9713cb
5 changed files with 26 additions and 8 deletions
12
README.rst
12
README.rst
|
|
@ -408,7 +408,9 @@ In case you need to customize the notification model in order to add field or
|
|||
customised features that depend on your application, you can inherit and extend
|
||||
the ``AbstractNotification`` model, example:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python
|
||||
|
||||
#In your_app/models.py
|
||||
|
||||
from django.db import models
|
||||
from notifications.base.models import AbstractNotification
|
||||
|
|
@ -422,6 +424,14 @@ the ``AbstractNotification`` model, example:
|
|||
class Meta(AbstractNotification.Meta):
|
||||
abstract = False
|
||||
|
||||
You will require to define ``NOTIFICATIONS_NOTIFICATION_MODEL`` setting in `setting.py` as follows:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# In your_project/settings.py
|
||||
|
||||
NOTIFICATIONS_NOTIFICATION_MODEL = 'your_app.Notification'
|
||||
|
||||
Notes
|
||||
=====
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
''' Django notifications admin file '''
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.contrib import admin
|
||||
from .models import Notification
|
||||
from swapper import load_model
|
||||
|
||||
Notification = load_model('notifications', 'Notification')
|
||||
|
||||
|
||||
class NotificationAdmin(admin.ModelAdmin):
|
||||
|
|
|
|||
|
|
@ -211,7 +211,6 @@ class AbstractNotification(models.Model):
|
|||
class Meta:
|
||||
abstract = True
|
||||
ordering = ('-timestamp',)
|
||||
app_label = 'notifications'
|
||||
# speed up notifications count query
|
||||
index_together = ('recipient', 'unread')
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Replace this with more appropriate tests for your application.
|
|||
import json
|
||||
|
||||
import pytz
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
|
@ -17,9 +18,12 @@ from django.test import RequestFactory, TestCase
|
|||
from django.test.utils import CaptureQueriesContext
|
||||
from django.utils import timezone
|
||||
from django.utils.timezone import localtime, utc
|
||||
from notifications.models import Notification, notify_handler
|
||||
from notifications.models import notify_handler
|
||||
from notifications.signals import notify
|
||||
from notifications.utils import id2slug
|
||||
from swapper import load_model
|
||||
|
||||
Notification = load_model('notifications', 'Notification')
|
||||
|
||||
try:
|
||||
# Django >= 1.7
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
''' Django Notifications example views '''
|
||||
from distutils.version import StrictVersion # pylint: disable=no-name-in-module,import-error
|
||||
from distutils.version import \
|
||||
StrictVersion # pylint: disable=no-name-in-module,import-error
|
||||
|
||||
from django import get_version
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.forms import model_to_dict
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.generic import ListView
|
||||
from notifications import settings
|
||||
from notifications.models import Notification
|
||||
from notifications.utils import id2slug, slug2id
|
||||
from notifications.settings import get_config
|
||||
from django.views.decorators.cache import never_cache
|
||||
from notifications.utils import id2slug, slug2id
|
||||
from swapper import load_model
|
||||
|
||||
Notification = load_model('notifications', 'Notification')
|
||||
|
||||
if StrictVersion(get_version()) >= StrictVersion('1.7.0'):
|
||||
from django.http import JsonResponse # noqa
|
||||
|
|
|
|||
Loading…
Reference in a new issue