applications: add visible flag (#75115) #23
|
@ -32,7 +32,7 @@ class InstallForm(forms.Form):
|
|||
class MetadataForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Application
|
||||
fields = ['name', 'slug', 'description', 'documentation_url', 'icon']
|
||||
fields = ['name', 'slug', 'description', 'documentation_url', 'icon', 'visible']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('applications', '0011_element_type'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='application',
|
||||
name='visible',
|
||||
field=models.BooleanField(
|
||||
default=True,
|
||||
help_text='If enabled, the application will be visible in the services where it is installed.',
|
||||
verbose_name='Visible',
|
||||
),
|
||||
),
|
||||
]
|
|
@ -92,6 +92,11 @@ class Application(models.Model):
|
|||
description = models.TextField(verbose_name=_('Description'), blank=True)
|
||||
documentation_url = models.URLField(_('Documentation URL'), blank=True)
|
||||
editable = models.BooleanField(default=True)
|
||||
visible = models.BooleanField(
|
||||
verbose_name=_('Visible'),
|
||||
help_text=_('If enabled, the application will be visible in the services where it is installed.'),
|
||||
default=True,
|
||||
)
|
||||
elements = models.ManyToManyField('Element', blank=True, through='Relation')
|
||||
creation_timestamp = models.DateTimeField(default=now)
|
||||
last_update_timestamp = models.DateTimeField(auto_now=True)
|
||||
|
@ -274,6 +279,7 @@ class Version(models.Model):
|
|||
'description': app.description,
|
||||
'documentation_url': app.documentation_url,
|
||||
'icon': os.path.basename(app.icon.name) if app.icon.name else None,
|
||||
'visible': app.visible,
|
||||
'version_number': self.number,
|
||||
'version_notes': self.notes,
|
||||
'elements': [],
|
||||
|
|
|
@ -239,10 +239,12 @@ def test_create_application(app, admin_user, settings, analyze):
|
|||
resp = resp.click('Metadata')
|
||||
resp.form['description'] = 'Lorem ipsum'
|
||||
resp.form['documentation_url'] = 'http://foo.bar'
|
||||
resp.form['visible'] = False
|
||||
resp = resp.form.submit().follow()
|
||||
application = Application.objects.get(slug='test')
|
||||
assert application.icon.name == ''
|
||||
assert application.documentation_url == 'http://foo.bar'
|
||||
assert application.visible is False
|
||||
|
||||
# add forms
|
||||
assert '/add/forms/' in resp
|
||||
|
@ -284,6 +286,7 @@ def test_create_application(app, admin_user, settings, analyze):
|
|||
assert b'"documentation_url": "http://foo.bar"' in resp.content
|
||||
assert b'"version_number": "1.0"' in resp.content
|
||||
assert b'"version_notes": "Foo bar blah."' in resp.content
|
||||
assert b'"visible": false' in resp.content
|
||||
|
||||
resp = app.get('/applications/manifest/test/versions/')
|
||||
versions = [e.text() for e in resp.pyquery('h3').items()]
|
||||
|
@ -326,10 +329,12 @@ def test_create_application(app, admin_user, settings, analyze):
|
|||
'image/png',
|
||||
)
|
||||
resp.form['documentation_url'] = '' # and reset documentation_url
|
||||
resp.form['visible'] = True
|
||||
resp = resp.form.submit().follow()
|
||||
application.refresh_from_db()
|
||||
assert re.match(r'applications/icons/foo(_\w+)?.png', application.icon.name)
|
||||
assert application.documentation_url == ''
|
||||
assert application.visible is True
|
||||
|
||||
# try an icon in an invalid format
|
||||
resp = app.get('/applications/manifest/test/metadata/')
|
||||
|
@ -353,6 +358,7 @@ def test_create_application(app, admin_user, settings, analyze):
|
|||
assert b'"documentation_url": ""' in resp.content
|
||||
assert b'"version_number": "2.0"' in resp.content
|
||||
assert b'"version_notes": "Foo bar blah. But with an icon."' in resp.content
|
||||
assert b'"visible": true' in resp.content
|
||||
version = Version.objects.latest('pk')
|
||||
assert version.number == '2.0'
|
||||
assert version.notes == 'Foo bar blah. But with an icon.'
|
||||
|
|
Loading…
Reference in New Issue