mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-05-01 10:24:43 +00:00
Improve url confs for better support of Django 2.0+
This commit is contained in:
parent
3d06666bc2
commit
f7f0cda92d
4 changed files with 55 additions and 28 deletions
|
|
@ -55,3 +55,6 @@ TEMPLATES = [
|
|||
]
|
||||
|
||||
NOTIFICATIONS_USE_JSONFIELD = True
|
||||
LOGIN_REDIRECT_URL = 'test/'
|
||||
LOGIN_URL = '/admin/login/'
|
||||
APPEND_SLASH = True
|
||||
|
|
|
|||
|
|
@ -1,21 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
from django import get_version
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.views import login
|
||||
|
||||
import notifications.urls
|
||||
import notifications.tests.views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^login/$', login, name='login'), # needed for Django 1.6 tests
|
||||
url(r'^test_make/', notifications.tests.views.make_notification),
|
||||
url(r'^test/', notifications.tests.views.live_tester),
|
||||
url(r'^', include(notifications.urls, namespace='notifications')),
|
||||
]
|
||||
from notifications.tests.views import live_tester, make_notification
|
||||
from django.contrib import admin
|
||||
|
||||
if StrictVersion(get_version()) >= StrictVersion('2.0'):
|
||||
urlpatterns.append(url(r'^admin/', admin.site.urls))
|
||||
from django.urls import include, path
|
||||
urlpatterns = [
|
||||
path('test_make/', make_notification),
|
||||
path('test/', live_tester),
|
||||
path('login/', login, name='login'), # reverse for django login is not working
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('notifications.urls', namespace='notifications')),
|
||||
]
|
||||
else:
|
||||
urlpatterns.append(url(r'^admin/', include(admin.site.urls)))
|
||||
from django.conf.urls import include, url
|
||||
urlpatterns = [
|
||||
url(r'^login/$', login, name='login'), # reverse for django login is not working
|
||||
url(r'^test_make/', make_notification),
|
||||
url(r'^test/', live_tester),
|
||||
url(r'^', include('notifications.urls', namespace='notifications')),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
from notifications import notify
|
||||
import random
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render
|
||||
from django.utils.decorators import method_decorator
|
||||
from notifications import notify
|
||||
|
||||
|
||||
@login_required
|
||||
def live_tester(request):
|
||||
notify.send(sender=request.user, recipient=request.user, verb='you loaded the page')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
from django.conf.urls import url
|
||||
from django import get_version
|
||||
|
||||
from . import views
|
||||
|
||||
if StrictVersion(get_version()) >= StrictVersion('2.0'):
|
||||
from django.urls import include, path
|
||||
urlpatterns = [
|
||||
path('', views.AllNotificationsList.as_view(), name='all'),
|
||||
path('unread/', views.UnreadNotificationsList.as_view(), name='unread'),
|
||||
path('mark-all-as-read/', views.mark_all_as_read, name='mark_all_as_read'),
|
||||
path('mark-as-read/<slug:slug>/', views.mark_as_read, name='mark_as_read'),
|
||||
path('mark-as-unread/<slug:slug>/', views.mark_as_unread, name='mark_as_unread'),
|
||||
path('delete/<slug:slug>/', views.delete, name='delete'),
|
||||
path('api/unread_count/', views.live_unread_notification_count, name='live_unread_notification_count'),
|
||||
path('api/unread_list/', views.live_unread_notification_list, name='live_unread_notification_list'),
|
||||
]
|
||||
else:
|
||||
from django.contrib import admin
|
||||
from django.conf.urls import include, url
|
||||
urlpatterns = [
|
||||
url(r'^$', views.AllNotificationsList.as_view(), name='all'),
|
||||
url(r'^unread/$', views.UnreadNotificationsList.as_view(), name='unread'),
|
||||
url(r'^mark-all-as-read/$', views.mark_all_as_read, name='mark_all_as_read'),
|
||||
url(r'^mark-as-read/(?P<slug>\d+)/$', views.mark_as_read, name='mark_as_read'),
|
||||
url(r'^mark-as-unread/(?P<slug>\d+)/$', views.mark_as_unread, name='mark_as_unread'),
|
||||
url(r'^delete/(?P<slug>\d+)/$', views.delete, name='delete'),
|
||||
url(r'^api/unread_count/$', views.live_unread_notification_count, name='live_unread_notification_count'),
|
||||
url(r'^api/unread_list/$', views.live_unread_notification_list, name='live_unread_notification_list'),
|
||||
]
|
||||
|
||||
app_name = 'notifications'
|
||||
urlpatterns = [
|
||||
url(r'^$', views.AllNotificationsList.as_view(), name='all'),
|
||||
url(r'^unread/$', views.UnreadNotificationsList.as_view(), name='unread'),
|
||||
url(r'^mark-all-as-read/$', views.mark_all_as_read, name='mark_all_as_read'),
|
||||
url(r'^mark-as-read/(?P<slug>\d+)/$', views.mark_as_read, name='mark_as_read'),
|
||||
url(r'^mark-as-unread/(?P<slug>\d+)/$', views.mark_as_unread, name='mark_as_unread'),
|
||||
url(r'^delete/(?P<slug>\d+)/$', views.delete, name='delete'),
|
||||
url(r'^api/unread_count/$', views.live_unread_notification_count, name='live_unread_notification_count'),
|
||||
url(r'^api/unread_list/$', views.live_unread_notification_list, name='live_unread_notification_list'),
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue