SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 2676662c authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Refactor urlpatterns

parent 2202e782
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,6 @@ class StoredMessageFilterBackend(filters.BaseFilterBackend):
elif period == 'week':
days = 1
limit = timezone.now() - datetime.timedelta(days=days)
print(limit)
queryset = queryset.filter(datetimestamp__gt=limit)
_from = request.query_params.get('from', None)
......@@ -57,6 +56,7 @@ class StoredMessageFilterBackend(filters.BaseFilterBackend):
recipients = request.query_params.get('recipients', None)
if recipients is not None:
queryfilter = queryfilter | Q(data__recipients__icontains=recipients)
# For full-text searches through body-plain / body-html, we use a
# raw SQL query since Django ORM does not support hyphenated lookups,
# and since Mailgun uses hyphenated keys in its JSON responses.
......
......@@ -2,7 +2,7 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.urls import path
from django.urls import include, path
from apimail.api import views as apiviews
from . import views
......@@ -14,26 +14,29 @@ urlpatterns = [
# API
path( # /mail/api/events
'api/events',
apiviews.EventListAPIView.as_view(),
name='api_event_list'
),
path( # /mail/api/event/<uuid>
'api/event/<uuid:uuid>',
apiviews.EventRetrieveAPIView.as_view(),
name='api_event_retrieve'
),
path( # /mail/api/stored_messages
'api/stored_messages',
apiviews.StoredMessageListAPIView.as_view(),
name='api_stored_message_list'
),
path( # /mail/api/stored_message/<uuid>
'api/stored_message/<uuid:uuid>',
apiviews.StoredMessageRetrieveAPIView.as_view(),
name='api_stored_message_retrieve'
),
path('api/', include([
path( # /mail/api/events
'events',
apiviews.EventListAPIView.as_view(),
name='api_event_list'
),
path( # /mail/api/event/<uuid>
'event/<uuid:uuid>',
apiviews.EventRetrieveAPIView.as_view(),
name='api_event_retrieve'
),
path( # /mail/api/stored_messages
'stored_messages',
apiviews.StoredMessageListAPIView.as_view(),
name='api_stored_message_list'
),
path( # /mail/api/stored_message/<uuid>
'stored_message/<uuid:uuid>',
apiviews.StoredMessageRetrieveAPIView.as_view(),
name='api_stored_message_retrieve'
),
])),
# User views
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment