1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django import forms
6 from django.contrib.sites.models import Site
8 from push.models import Notification
9 from push.utils import send_fcm_push
12 class NotificationForm(forms.ModelForm):
16 exclude = ('timestamp', 'message_id')
18 def save(self, commit=True):
19 notification = super(NotificationForm, self).save(commit=commit)
20 wl_base = u'https://' + Site.objects.get_current().domain
21 notification.message_id = send_fcm_push(notification.title, notification.body, wl_base + notification.image.url)