52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
# combo-plugin-gnm - Combo GNM plugin
|
|
# Copyright (C) 2018 Entr'ouvert
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from django import template
|
|
from django.conf import settings
|
|
from django.core.urlresolvers import reverse
|
|
|
|
from webpush.models import PushInformation
|
|
|
|
|
|
register = template.Library()
|
|
|
|
|
|
@register.inclusion_tag('webpush_checkbox.html', takes_context=True)
|
|
def webpush_checkbox(context):
|
|
group = context.get('webpush', {}).get('group')
|
|
url = reverse('save_webpush_info')
|
|
request = context['request']
|
|
user_subscription_browser_list = [info.subscription.browser for info in PushInformation.objects.filter(user=request.user)]
|
|
print user_subscription_browser_list
|
|
return {
|
|
'group': group,
|
|
'url': url,
|
|
'request': request,
|
|
'user_subscription_browser_list': user_subscription_browser_list
|
|
}
|
|
|
|
|
|
@register.inclusion_tag('webpush_scripts.html', takes_context=True)
|
|
def webpush_scripts(context):
|
|
return
|
|
|
|
|
|
@register.assignment_tag(takes_context=True)
|
|
def get_webpush_vars(context):
|
|
vapid_public_key = getattr(settings, 'WEBPUSH_SETTINGS', {}).get('VAPID_PUBLIC_KEY', '')
|
|
return {'vapid_public_key': vapid_public_key}
|