Skip to content

Commit a2131f4

Browse files
committed
Update for Django 3
1 parent 844e8a1 commit a2131f4

35 files changed

Lines changed: 69 additions & 643 deletions

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
recursive-include mqueue/static *
2-
recursive-include mqueue/templates *
32
recursive-include mqueue/migrations *
43
recursive-include mqueue/locale *
54
recursive-include mqueue/hooks *

docs/api/api.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
Graphql Api
22
===========
33

4-
*New in 0.9*
5-
64
It is possible to query for public events, users events and staff events.
75

86
Settings
97
~~~~~~~~
108

11-
Install with ``pip install django-graphql-utils django-filters``
9+
Install with ``pip install graphene-django django-filter``
1210

1311
.. highlight:: python
1412

1513
::
1614

17-
INSTALLED_APPS += ("graphene_django", "graphql_utils", "django_filters",)
15+
INSTALLED_APPS += ("graphene_django", "django_filters",)
1816

1917
GRAPHENE = {
2018
'SCHEMA': 'mqueue.schema.schema'
@@ -31,18 +29,16 @@ Urls:
3129
::
3230

3331
from django.conf import settings
32+
from django.views.decorators.csrf import csrf_exempt
3433
from graphene_django.views import GraphQLView
35-
from graphql_utils.views import TGraphQLView
3634
3735
urlpatterns = [
3836
# ...
39-
url(r'^graphql', TGraphQLView.as_view()),
37+
path('graphql', GraphQLView.as_view()),
4038
]
4139
4240
if settings.DEBUG:
43-
urlpatterns += [url(r'^graphiql', GraphQLView.as_view(graphiql=True)), ]
44-
45-
Note: the ``/graphql`` endpoint is protected by a Django csrf token
41+
urlpatterns += [path('graphiql', csrf_exempt(GraphQLView.as_view(graphiql=True)))]
4642

4743
Event scope
4844
~~~~~~~~~~~
@@ -62,6 +58,8 @@ Possible scope values are: ``public``, ``users``, ``staff``, ``superuser`` (defa
6258
Queries
6359
~~~~~~~
6460

61+
Go to ``http://localhost:8000/graphiql/`` to test the queries
62+
6563
Available queries are:
6664

6765
``publicEvents``, ``usersEvents``, ``staffEvents``, ``allEvents`` (for the superuser)
@@ -77,7 +75,7 @@ Example: public events:
7775
edges {
7876
node {
7977
name
80-
event_class
78+
eventClass
8179
}
8280
}
8381
}

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Add to INSTALLED_APPS:
1414

1515
::
1616

17-
"django_extensions",
1817
"mqueue",
1918

2019
Run the migrations.

docs/settings/graphical_settings.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Event classes
55
~~~~~~~~~~~~~
66

77
You can define your custom set of event classes and the corresponding
8-
css classes to display in the admin. The default values are (check ``mqueue/static/mqueue.css``):
8+
css classes to display in the admin. The default values are (check ``mqueue/static/mqueue/mqueue.css``):
99

1010
.. highlight:: python
1111

docs/usage/hooks.rst

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,12 @@
11
Hooks
22
=====
33

4-
*New in 0.7.1* (inspired by `Logrus <https://github.com/sirupsen/logrus>`_)
4+
Optional hooks can be used to perform extra actions on events (inspired by `Logrus <https://github.com/sirupsen/logrus>`_).
5+
Available hooks:
56

6-
Optional hooks can be used to perform extra actions on events. Available hooks:
7-
8-
- **Postgresql**: record the events in a postgresql database (go)
9-
- **Influxdb**: record the events in an influxdb database (go)
107
- **Redis**: record the events in Redis (python)
118
- **Centrifugo**: push events as messages in the Centrifugo websockets server (python)
129

13-
Postgresql
14-
----------
15-
16-
In ``settings.py``
17-
18-
.. highlight:: python
19-
20-
::
21-
22-
MQUEUE_HOOKS = {
23-
"postgresql": {
24-
"path": "mqueue.hooks.postgresql",
25-
"addr": "localhost",
26-
"user": "user",
27-
"password": "pwd",
28-
"database": "mydomain_events",
29-
"table": "events"
30-
}
31-
}
32-
33-
Create the database in postgresql and migrate it with a management command:
34-
35-
::
36-
37-
python3 manage.py mqueue_migrate_pg
38-
39-
Influxdb
40-
--------
41-
42-
::
43-
44-
"influxdb": {
45-
"path": "mqueue.hooks.influxdb",
46-
"addr": "http://localhost:8086",
47-
"user": "admin",
48-
"password": "admin",
49-
"database": "events"
50-
}
51-
52-
Create the database in Influxdb
53-
5410
Redis
5511
-----
5612

mqueue/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '0.9.5'
1+
__version__ = '0.10.0'
22
default_app_config = 'mqueue.apps.MqueueConfig'

mqueue/admin.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22

33
from django.utils.translation import ugettext_lazy as _
44
from django.contrib import admin
5-
from mqueue.models import MEvent
6-
from mqueue.utils import format_event_class
5+
from django.utils.html import format_html
6+
from .models import MEvent
7+
from .utils import format_event_class
78

89

910
def link_to_object(obj):
10-
return '<a href="' + obj.url + '" target="_blank">' + obj.url + '</a>'
11+
return format_html('<a href="' + obj.url + '" target="_blank">' + obj.url + '</a>')
1112

1213

1314
def link_to_object_admin(obj):
14-
return '<a href="' + obj.admin_url + '" target="_blank">' + obj.admin_url + '</a>'
15+
return format_html('<a href="' + obj.admin_url + '" target="_blank">' + obj.admin_url + '</a>')
16+
17+
18+
def event(obj):
19+
return format_html(format_event_class(obj))
1520

1621

1722
@admin.register(MEvent)
1823
class MEventAdmin(admin.ModelAdmin):
1924
date_hierarchy = 'date_posted'
2025
readonly_fields = ['date_posted', 'request']
21-
list_display = [format_event_class, 'name', 'date_posted',
22-
'bucket', 'user', link_to_object, link_to_object_admin]
26+
list_display = [event, 'name', 'date_posted',
27+
'bucket', 'user', link_to_object, link_to_object_admin, 'scope']
2328
list_filter = (
2429
'event_class',
2530
('content_type', admin.RelatedOnlyFieldListFilter),
@@ -39,6 +44,11 @@ class MEventAdmin(admin.ModelAdmin):
3944
'content_type',
4045
)
4146

47+
class Media:
48+
css = {
49+
'all': ('mqueue/mqueue.css',)
50+
}
51+
4252
def get_readonly_fields(self, request, obj=None):
4353
super(MEventAdmin, self).get_readonly_fields(request, obj)
4454
return ('notes', 'request')

mqueue/apps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class MqueueConfig(AppConfig):
1010
def ready(self):
1111
# models registration from settings
1212
from django.conf import settings
13-
from mqueue.tracking import mqueue_tracker
13+
from .tracking import mqueue_tracker
1414
registered_models = getattr(settings, 'MQUEUE_AUTOREGISTER', [])
1515
for modtup in registered_models:
1616
modpath = modtup[0]
@@ -28,6 +28,6 @@ def ready(self):
2828
raise(e)
2929

3030
# watchers
31-
from mqueue.watchers import init_watchers
32-
from mqueue.conf import WATCH
31+
from .watchers import init_watchers
32+
from .conf import WATCH
3333
init_watchers(WATCH)

mqueue/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class LogsDBHandler(Handler, object):
88

99
def emit(self, record):
10-
from mqueue.models import MEvent
10+
from .models import MEvent
1111
msg = record.getMessage()
1212
name = msg[:120]
1313
if record.exc_info:

mqueue/hooks/centrifugo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.conf import settings
2-
from mqueue.conf import DOMAIN
2+
from ...conf import DOMAIN
33
try:
44
from instant.conf import SITE_SLUG
55
from instant.producers import publish

0 commit comments

Comments
 (0)