Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
concrexit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
70
Issues
70
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
thalia
concrexit
Commits
fbcab5d2
Commit
fbcab5d2
authored
Oct 13, 2019
by
Gijs Hendriksen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sent time to push notification, in order to sort API results
parent
fe7f37a7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
6 deletions
+40
-6
website/pushnotifications/api/serializers.py
website/pushnotifications/api/serializers.py
+1
-1
website/pushnotifications/api/viewsets.py
website/pushnotifications/api/viewsets.py
+3
-1
website/pushnotifications/locale/nl/LC_MESSAGES/django.mo
website/pushnotifications/locale/nl/LC_MESSAGES/django.mo
+0
-0
website/pushnotifications/locale/nl/LC_MESSAGES/django.po
website/pushnotifications/locale/nl/LC_MESSAGES/django.po
+7
-3
website/pushnotifications/migrations/0015_auto_20191013_1642.py
...e/pushnotifications/migrations/0015_auto_20191013_1642.py
+22
-0
website/pushnotifications/models.py
website/pushnotifications/models.py
+7
-1
No files found.
website/pushnotifications/api/serializers.py
View file @
fbcab5d2
...
...
@@ -41,4 +41,4 @@ class MessageSerializer(ModelSerializer):
class
Meta
:
model
=
Message
fields
=
(
'pk'
,
'title'
,
'body'
,
'url'
,
'category'
)
fields
=
(
'pk'
,
'title'
,
'body'
,
'url'
,
'category'
,
'time'
)
website/pushnotifications/api/viewsets.py
View file @
fbcab5d2
from
django.utils.translation
import
get_language_from_request
from
rest_framework
import
permissions
,
viewsets
from
rest_framework
import
permissions
,
viewsets
,
filters
from
rest_framework.decorators
import
action
from
rest_framework.response
import
Response
...
...
@@ -52,6 +52,8 @@ class DeviceViewSet(viewsets.ModelViewSet):
class
MessageViewSet
(
viewsets
.
ReadOnlyModelViewSet
):
permission_classes
=
(
permissions
.
IsAuthenticated
,)
queryset
=
Message
.
objects
.
all
()
filter_backends
=
(
filters
.
OrderingFilter
,)
ordering_fields
=
(
'time'
,)
serializer_class
=
MessageSerializer
def
get_queryset
(
self
):
...
...
website/pushnotifications/locale/nl/LC_MESSAGES/django.mo
View file @
fbcab5d2
This diff was suppressed by a .gitattributes entry.
website/pushnotifications/locale/nl/LC_MESSAGES/django.po
View file @
fbcab5d2
...
...
@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-
03-02 16:51+01
00\n"
"PO-Revision-Date: 2019-
03-02 16:52+01
00\n"
"POT-Creation-Date: 2019-
10-13 16:50+02
00\n"
"PO-Revision-Date: 2019-
10-13 16:51+02
00\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
...
...
@@ -11,7 +11,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit
2.2
.1\n"
"X-Generator: Poedit
1.8.7
.1\n"
#: admin.py
msgid "Enable selected devices"
...
...
@@ -90,6 +90,10 @@ msgstr "mislukt"
msgid "success"
msgstr "succesvol"
#: models.py
msgid "time"
msgstr "tijd"
#: templates/admin/pushnotifications/change_form.html
msgid "Send message"
msgstr "Verstuur bericht"
website/pushnotifications/migrations/0015_auto_20191013_1642.py
0 → 100644
View file @
fbcab5d2
# Generated by Django 2.2.1 on 2019-10-13 14:42
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'pushnotifications'
,
'0014_fix_typo'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'scheduledmessage'
,
name
=
'time'
,
),
migrations
.
AddField
(
model_name
=
'message'
,
name
=
'time'
,
field
=
models
.
DateTimeField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'time'
),
),
]
website/pushnotifications/models.py
View file @
fbcab5d2
...
...
@@ -3,6 +3,7 @@ import datetime
from
django.conf
import
settings
from
django.db
import
models
from
django.utils
import
timezone
from
django.utils.translation
import
override
from
django.utils.translation
import
ugettext_lazy
as
_
from
firebase_admin
import
messaging
...
...
@@ -126,6 +127,11 @@ class Message(models.Model, metaclass=ModelTranslateMeta):
blank
=
True
,
null
=
True
,
)
time
=
models
.
DateTimeField
(
verbose_name
=
_
(
'time'
),
blank
=
True
,
null
=
True
,
)
def
__str__
(
self
):
return
'{}: {}'
.
format
(
self
.
title
,
self
.
body
)
...
...
@@ -187,6 +193,7 @@ class Message(models.Model, metaclass=ModelTranslateMeta):
self
.
sent
=
True
self
.
success
=
success_total
self
.
failure
=
failure_total
self
.
time
=
timezone
.
now
()
self
.
save
()
return
None
...
...
@@ -204,5 +211,4 @@ class ScheduledMessage(Message, metaclass=ModelTranslateMeta):
objects
=
ScheduledMessageManager
()
scheduled
=
models
.
BooleanField
(
default
=
True
)
time
=
models
.
DateTimeField
()
executed
=
models
.
DateTimeField
(
null
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment