Example #1
0
    def test_same_user_channel_redis_queue_view(self):
        s = SameUserChannelRedisQueueView()

        backup = DynamicChannelRedisQueueView.dispatch

        try:
            DynamicChannelRedisQueueView.dispatch = lambda *args, **kw: True

            # Anonymous access enabled by default
            self.user.is_anonymous = lambda self=None: True
            self.assertEquals(s.dispatch(self.request), True)

            # Logged-in access for users, who have same username as channel name
            self.user.is_anonymous = lambda self=None: False
            self.assertEquals(s.dispatch(self.request).status_code, 403)

            s.redis_channel = self.user.username
            self.assertEquals(s.dispatch(self.request), True)

        finally:
            DynamicChannelRedisQueueView.dispatch = backup
Example #2
0
    def test_same_user_channel_redis_queue_view(self):
        s = SameUserChannelRedisQueueView()

        backup = DynamicChannelRedisQueueView.dispatch

        try:
            DynamicChannelRedisQueueView.dispatch = lambda *args, **kw: True

            # Anonymous access enabled by default
            self.user.is_anonymous = lambda self=None: True
            self.assertEquals(s.dispatch(self.request), True)

            # Logged-in access for users, who have same username as channel name
            self.user.is_anonymous = lambda self=None: False
            self.assertEquals(s.dispatch(self.request).status_code, 403)

            s.redis_channel = self.user.username
            self.assertEquals(s.dispatch(self.request), True)

        finally:
            DynamicChannelRedisQueueView.dispatch = backup
Example #3
0
from django.conf.urls import patterns, url
from monitio.views import SameUserChannelRedisQueueView

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

    # Mark read
    url(r'^mark_read/(?P<message_id>\d+)/$', 'message_mark_read',
        name='message_mark_read'),
    url(r'^mark_read/all/$', 'message_mark_all_read',
        name='message_mark_all_read'),

    # Delete
    url(r'^delete/message/(?P<message_id>\d+)/$', 'message_delete',
        name='message_delete'),
    url(r'^delete/all/$', 'message_delete_all', name='message_delete_all'),

    # django-sse
    url(r'^sse/(?P<channel>\w+)?$',
        SameUserChannelRedisQueueView.as_view(), name="persistent-messages-sse"),


)
Example #4
0
from django.conf.urls.defaults import *
from monitio.views import SameUserChannelRedisQueueView

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

    # Mark read
    url(r'^mark_read/(?P<message_id>\d+)/$',
        'message_mark_read',
        name='message_mark_read'),
    url(r'^mark_read/all/$',
        'message_mark_all_read',
        name='message_mark_all_read'),

    # Delete
    url(r'^delete/message/(?P<message_id>\d+)/$',
        'message_delete',
        name='message_delete'),
    url(r'^delete/all/$', 'message_delete_all', name='message_delete_all'),

    # django-sse
    url(r'^sse/(?P<channel>\w+)?$',
        SameUserChannelRedisQueueView.as_view(),
        name="persistent-messages-sse"),
)