0001-pwa-add-application-title-parameter-32371.patch
combo/apps/pwa/migrations/0005_pwasettings_application_name.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# Generated by Django 1.11.20 on 2019-04-16 14:08 |
|
3 |
from __future__ import unicode_literals |
|
4 | ||
5 |
from django.db import migrations, models |
|
6 | ||
7 | ||
8 |
class Migration(migrations.Migration): |
|
9 | ||
10 |
dependencies = [ |
|
11 |
('pwa', '0004_pwasettings_application_icon'), |
|
12 |
] |
|
13 | ||
14 |
operations = [ |
|
15 |
migrations.AddField( |
|
16 |
model_name='pwasettings', |
|
17 |
name='application_name', |
|
18 |
field=models.CharField(blank=True, max_length=256, verbose_name='Application Name'), |
|
19 |
), |
|
20 |
] |
combo/apps/pwa/models.py | ||
---|---|---|
36 | 36 | |
37 | 37 |
class PwaSettings(models.Model): |
38 | 38 |
APPLICATION_ICON_SIZES = ['%sx%s' % (x, x) for x in (48, 96, 192, 256, 512)] |
39 |
application_name = models.CharField(_('Application Name'), blank=True, max_length=256) |
|
39 | 40 |
application_icon = models.FileField( |
40 | 41 |
verbose_name=_('Application Icon'), |
41 | 42 |
help_text=_(u'Should be a square of at least 512×512 pixels.'), |
combo/apps/pwa/templates/combo/manifest.json | ||
---|---|---|
1 | 1 |
{% load static thumbnail %}{ |
2 |
"name": "{% firstof global_title "Compte Citoyen" %}", |
|
3 |
"short_name": "{% firstof global_title "Compte Citoyen" %}", |
|
2 |
"name": "{% firstof pwa_settings.application_name global_title "Compte Citoyen" %}",
|
|
3 |
"short_name": "{% firstof pwa_settings.application_name global_title "Compte Citoyen" %}",
|
|
4 | 4 |
"start_url": "{% firstof pwa_start_url "/" %}", |
5 | 5 |
{% if theme_color %} |
6 | 6 |
"background_color": "{{ theme_color }}", |
tests/test_pwa.py | ||
---|---|---|
203 | 203 |
# make sure largest icon is referenced in service worker |
204 | 204 |
resp2 = app.get('/service-worker.js', status=200) |
205 | 205 |
assert resp.json['icons'][-1]['src'].split('/')[-1] in resp.text |
206 | ||
207 | ||
208 |
def test_pwa_application_name(app, admin_user): |
|
209 |
app = login(app) |
|
210 |
assert app.get('/manifest.json', status=200).json['name'] == 'Compte Citoyen' |
|
211 |
pwa_settings = PwaSettings.singleton() |
|
212 |
pwa_settings.application_name = 'My wonderfull app' |
|
213 |
pwa_settings.save() |
|
214 |
assert app.get('/manifest.json', status=200).json['name'] == 'My wonderfull app' |
|
206 |
- |