Skip to content

Commit

Permalink
Fixing as per arogachev mentioned
Browse files Browse the repository at this point in the history
  • Loading branch information
safwanrahman committed Dec 10, 2016
1 parent 3132d80 commit 639cdf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions webpush/templates/manifest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% if request.user.is_authenticated or group %}
<link rel="manifest" href="{% url 'webpush_manifest_json' %}">
{% endif %}
3 changes: 0 additions & 3 deletions webpush/templates/webpush.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@

<script id="webpush-js" type="text/javascript" src="{% static 'webpush/webpush.js' %}"></script>
<script id="service-worker-js" type="text/javascript" src="{% static 'webpush/webpush_serviceworker.js' %}"></script>
{% if include_manifest %}
<link rel="manifest" href="{% url 'webpush_manifest_json' %}">
{% endif %}
{% endif %}
15 changes: 9 additions & 6 deletions webpush/templatetags/webpush_notifications.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django import template
from django.conf import settings
from django.core.urlresolvers import reverse

register = template.Library()
Expand All @@ -10,11 +9,15 @@
def webpush(context):
group = context.get('webpush', {}).get('group')
request = context['request']
# If the website already provide a manifest file, we should not include it
# into the template. If `MANIFEST` config is not provided,
# that means we should generate a manifest by default.
include_manifest = settings.WEBPUSH_SETTINGS.get("MANIFEST", True)
return {'group': group, 'include_manifest': include_manifest, 'request': request}
return {'group': group, 'request': request}


@register.filter
@register.inclusion_tag('manifest.html', takes_context=True)
def webpush_manifest(context):
group = context.get('webpush', {}).get('group')
request = context['request']
return {'group': group, 'request': request}


@register.filter
Expand Down

0 comments on commit 639cdf1

Please sign in to comment.