Commit 46d91a8c authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch '537-add-categories-to-push-notifications' into 'master'

added a category field and added it to the admin with filtering

Closes #537

See merge request !634
parents 62118c13 74dc7b57
......@@ -30,18 +30,18 @@ class DeviceAdmin(admin.ModelAdmin):
@admin.register(models.Message)
class MessageAdmin(admin.ModelAdmin):
list_display = ('title', 'body', 'sent', 'success', 'failure')
list_display = ('title', 'body', 'category', 'sent', 'success', 'failure')
filter_horizontal = ('users',)
list_filter = ('sent',)
list_filter = ('sent', 'category')
def get_fields(self, request, obj=None):
if obj and obj.sent:
return 'users', 'title', 'body', 'success', 'failure'
return 'users', 'title', 'body'
return 'users', 'title', 'body', 'category', 'success', 'failure'
return 'users', 'title', 'body', 'category'
def get_readonly_fields(self, request, obj=None):
if obj and obj.sent:
return 'users', 'title', 'body', 'success', 'failure'
return 'users', 'title', 'body', 'category', 'success', 'failure'
return super().get_readonly_fields(request, obj)
def change_view(self, request, object_id, form_url='', **kwargs):
......
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-13 20:55+0100\n"
"PO-Revision-Date: 2017-12-17 18:01+0100\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"X-Generator: Poedit 2.0.4\n"
#: admin.py:19
msgid "Enable selected devices"
msgstr "Activeer geselecteerde apparaten"
#: admin.py:23
msgid "Disable selected devices"
msgstr "Deactiveer geselecteerde apparaten"
#: admin.py:27
msgid "Name"
msgstr "Naam"
#: apps.py:7
msgid "Push Notifications"
msgstr "Pushnotificaties"
#: models.py:17
msgid "registration token"
msgstr "registratie token"
#: models.py:20
msgid "active"
msgstr "actief"
#: models.py:21
msgid "Inactive devices will not be sent notifications"
msgstr "Inactieve apparaten zullen geen notificaties ontvangen"
#: models.py:26
msgid "registration date"
msgstr "registratiedatum"
#: models.py:29
msgid "language"
msgstr "taal"
#: models.py:48
msgid "General"
msgstr "Algemeen"
#: models.py:49
msgid "Pizza"
msgstr "Pizza"
#: models.py:50
msgid "Events"
msgstr "Evenementen"
#: models.py:51
msgid "Newsletter"
msgstr "Nieuwsbrief"
#: models.py:52
msgid "Sponsored messages"
msgstr "Gesponsorde berichten"
#: models.py:53
msgid "Photos"
msgstr "Foto's"
#: models.py:54
msgid "Board"
msgstr "Bestuur"
#: models.py:60
msgid "title"
msgstr "titel"
#: models.py:63
msgid "body"
msgstr "bericht"
#: models.py:73
msgid "sent"
msgstr "verzonden"
#: models.py:77
msgid "failure"
msgstr "mislukt"
#: models.py:82
msgid "success"
msgstr "succesvol"
#: templates/admin/pushnotifications/change_form.html:14
msgid "Send message"
msgstr "Verstuur bericht"
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2017-12-17 17:04
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pushnotifications', '0002_auto_20171103_1658'),
]
operations = [
migrations.AddField(
model_name='message',
name='category',
field=models.CharField(choices=[('general', 'General'), ('pizza', 'Pizza'), ('event', 'Events'), ('newsletter', 'Newsletter'), ('sponsor', 'Sponsored messages'), ('photo', 'Photos'), ('board', 'Board')], default='general', max_length=10),
),
]
......@@ -36,6 +36,23 @@ class Device(models.Model):
class Message(models.Model):
GENERAL = 'general'
PIZZA = 'pizza'
EVENT = 'event'
NEWSLETTER = 'newsletter'
SPONSOR = 'sponsor'
PHOTO = 'photo'
BOARD = 'board'
CATEGORIES = (
(GENERAL, _("General")),
(PIZZA, _("Pizza")),
(EVENT, _("Events")),
(NEWSLETTER, _("Newsletter")),
(SPONSOR, _("Sponsored messages")),
(PHOTO, _("Photos")),
(BOARD, _("Board")),
)
users = models.ManyToManyField(django_settings.AUTH_USER_MODEL)
title = models.CharField(
......@@ -46,6 +63,12 @@ class Message(models.Model):
verbose_name=_('body')
)
category = models.CharField(
choices=CATEGORIES,
max_length=10,
default="general"
)
sent = models.BooleanField(
verbose_name=_('sent'),
default=False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment