Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Multiuser properties to components. #264

Merged
merged 28 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2e835c7
Alter json description
Jan 31, 2017
b15201f
Create multuser support migration
Jan 31, 2017
472893c
Fix json_description format
Feb 1, 2017
5f734c9
Add multiuser server-side for preferences and properties
Feb 3, 2017
ba0516b
Fix @migration_utils style
Feb 3, 2017
9a9c463
Add multiuser to component parsers
Feb 3, 2017
6d151b8
Fix multiuser properties not being built properly
Feb 3, 2017
0177720
Fix parsers not using unicode strings
Feb 7, 2017
ddf6dd0
Fix multiuser migrations
Feb 7, 2017
2372541
Add multiuser variable handling
Feb 7, 2017
30ce3dc
Add persistent variables to operators
Feb 8, 2017
b017a8f
Fix users with no permissions adding multiuser properties to iwidgets
Feb 9, 2017
48c1c81
Add migration tests multiuser structure
Feb 9, 2017
1c2dd4e
Improve multiuser description
Feb 9, 2017
ed13f62
Fix tests rest-api iwidget properties post multiuser requires permission
Feb 9, 2017
0d5d51b
Fix wiring post/patch properties typo and add default values
Feb 9, 2017
df218ae
Add multiuser documentation
Feb 10, 2017
0d05474
Refactor client operator properties
Feb 15, 2017
c6e0b18
Fix parsing json description no longer needed
Feb 15, 2017
4c9196f
Fix missing the multiuser property on test checks
Feb 15, 2017
f339066
cleanup
Feb 15, 2017
2b33905
Fix user value being overwritten
Feb 15, 2017
b799626
Refactor checkWiring logic
Feb 16, 2017
67107e0
Add wiring preferences/properties tests
Feb 16, 2017
f39f1e1
Fix error when saving wiring with no changes as an allowed user
Feb 16, 2017
2bc6f66
Improve wiring tests
Feb 16, 2017
65fb099
Add more operator variables tests
Feb 17, 2017
a5b7f19
Rename tests
Feb 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/wirecloud/catalogue/migrations/0002_alter_json_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2017-01-30 12:24
from __future__ import unicode_literals

from django.db import migrations
import wirecloud.commons.fields


class Migration(migrations.Migration):

dependencies = [
('catalogue', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='catalogueresource',
name='json_description',
field=wirecloud.commons.fields.JSONField(default={}, verbose_name='JSON description'),
),
]
3 changes: 2 additions & 1 deletion src/wirecloud/catalogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from whoosh.query import And, Every, Or, Term
from whoosh.sorting import FieldFacet, FunctionFacet

from wirecloud.commons.fields import JSONField
from wirecloud.commons.searchers import get_search_engine
from wirecloud.commons.utils.http import get_absolute_reverse_url
from wirecloud.commons.utils.template.parsers import TemplateParser
Expand Down Expand Up @@ -65,7 +66,7 @@ class CatalogueResource(models.Model):

popularity = models.DecimalField(_('popularity'), default=0, max_digits=2, decimal_places=1)

json_description = models.TextField(_('JSON description'))
json_description = JSONField(_('JSON description'))

@property
def local_uri_part(self):
Expand Down
3 changes: 1 addition & 2 deletions src/wirecloud/catalogue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def add_packaged_resource(file, user, wgt_file=None, template=None, deploy_only=

if not deploy_only:
resource_info.update(overrides)

resource = CatalogueResource.objects.create(
short_name=resource_info['name'],
vendor=resource_info['vendor'],
Expand All @@ -236,7 +235,7 @@ def add_packaged_resource(file, user, wgt_file=None, template=None, deploy_only=
template_uri=file_name,
creation_date=now(),
popularity='0.0',
json_description=json.dumps(resource_info)
json_description=resource_info
)

return resource
Expand Down
2 changes: 1 addition & 1 deletion src/wirecloud/catalogue/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class ResourceDocumentationEntry(Resource):
def read(self, request, vendor, name, version):

resource = get_object_or_404(CatalogueResource, vendor=vendor, short_name=name, version=version)
resource_info = json.loads(resource.json_description)
resource_info = resource.json_description
if resource_info['doc'] == '':
raise Http404

Expand Down
33 changes: 17 additions & 16 deletions src/wirecloud/commons/fixtures/user_with_workspaces.json

Large diffs are not rendered by default.

32 changes: 24 additions & 8 deletions src/wirecloud/commons/tests/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def setUpClass(cls):
'label': 'Preference label',
'description': 'Preference description',
'default': 'value',
'value': None
'value': None,
'multiuser': False,
},
{
'name': 'pref2',
Expand All @@ -141,7 +142,8 @@ def setUpClass(cls):
'label': 'Preference label',
'description': 'Preference description',
'default': '',
'value': '5'
'value': '5',
'multiuser': False,
}
],
'properties': [
Expand All @@ -152,6 +154,7 @@ def setUpClass(cls):
'label': 'Prop1',
'description': 'description 1',
'default': 'value1',
'multiuser': False,
},
{
'name': 'prop2',
Expand All @@ -160,6 +163,7 @@ def setUpClass(cls):
'label': 'Prop2',
'description': 'description 2',
'default': 'value2',
'multiuser': False,
}
],
'wiring': {
Expand Down Expand Up @@ -258,7 +262,8 @@ def setUpClass(cls):
'label': '__MSG_pref1_label__',
'description': '__MSG_pref1_description__',
'default': 'value',
'value': None
'value': None,
'multiuser': False,
},
{
'name': 'pref2',
Expand All @@ -268,7 +273,8 @@ def setUpClass(cls):
'label': '__MSG_pref2_label__',
'description': '__MSG_pref2_description__',
'default': '',
'value': '5'
'value': '5',
'multiuser': False,
}
],
'properties': [
Expand All @@ -279,6 +285,7 @@ def setUpClass(cls):
'label': '__MSG_prop1_label__',
'description': '__MSG_prop1_description__',
'default': 'value1',
'multiuser': False,
},
{
'name': 'prop2',
Expand All @@ -287,6 +294,7 @@ def setUpClass(cls):
'label': '__MSG_prop2_label__',
'description': '__MSG_prop2_description__',
'default': 'value2',
'multiuser': False,
}
],
'wiring': {
Expand Down Expand Up @@ -1125,7 +1133,8 @@ def setUpClass(cls):
'label': 'Preference label',
'description': 'Preference description',
'default': '',
'value': None
'value': None,
'multiuser': False,
},
{
'name': 'pref2',
Expand All @@ -1135,7 +1144,8 @@ def setUpClass(cls):
'label': 'Preference label',
'description': 'Preference description',
'default': 'value',
'value': '5'
'value': '5',
'multiuser': False,
}
],
'properties': [
Expand All @@ -1146,6 +1156,7 @@ def setUpClass(cls):
'label': 'Prop1',
'description': 'description 1',
'default': 'value1',
'multiuser': False,
},
{
'name': 'prop2',
Expand All @@ -1154,6 +1165,7 @@ def setUpClass(cls):
'label': 'Prop2',
'description': 'description 2',
'default': 'value2',
'multiuser': False,
}
],
'wiring': {
Expand Down Expand Up @@ -1326,7 +1338,8 @@ def setUpClass(cls):
'label': '',
'description': '',
'default': '',
'value': None
'value': None,
'multiuser': False,
},
{
'name': 'pref2',
Expand All @@ -1336,7 +1349,8 @@ def setUpClass(cls):
'label': '',
'description': '',
'default': '',
'value': None
'value': None,
'multiuser': False,
},
],
'properties': [],
Expand Down Expand Up @@ -1379,6 +1393,7 @@ def setUpClass(cls):
'label': '',
'description': '',
'default': '',
'multiuser': False,
},
{
'name': 'prop2',
Expand All @@ -1387,6 +1402,7 @@ def setUpClass(cls):
'label': '',
'description': '',
'default': '',
'multiuser': False,
},
],
'wiring': {
Expand Down
8 changes: 5 additions & 3 deletions src/wirecloud/commons/utils/template/parsers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _check_behaviour_view_fields(self, data):
self._check_connection_handles(connection)

def _add_translation_index(self, value, **kwargs):
index = get_trans_index(value)
index = get_trans_index(text_type(value))
if not index:
return

Expand All @@ -187,7 +187,7 @@ def _add_translation_index(self, value, **kwargs):

def _init(self):

self._check_string_fields(('title', 'description', 'longdescription', 'email', 'homepage','doc', 'changelog', 'image', 'smartphoneimage', 'license', 'licenseurl', 'issuetracker'))
self._check_string_fields(('title', 'description', 'longdescription', 'email', 'homepage', 'doc', 'changelog', 'image', 'smartphoneimage', 'license', 'licenseurl', 'issuetracker'))
self._check_contacts_fields(('authors', 'contributors'))

# Normalize/check preferences and properties (only for widgets and operators)
Expand All @@ -199,11 +199,13 @@ def _init(self):
self._check_string_fields(('label', 'description', 'default'), place=preference)
self._check_boolean_fields(('readonly', 'secure'), place=preference, default=False)
self._check_string_fields(('value',), place=preference, null=True, default=None)
self._check_boolean_fields(('multiuser',), place=preference, default=False)

for prop in self._info['properties']:
self._check_string_fields(('name', 'type'), place=prop, required=True)
self._check_string_fields(('label', 'description', 'default'), place=prop)
self._check_boolean_fields(('secure',), place=prop, default=False)
self._check_boolean_fields(('multiuser',), place=prop, default=False)

if self._info['type'] == 'widget':

Expand Down Expand Up @@ -251,7 +253,7 @@ def _init(self):
for behaviour in self._info['wiring']['visualdescription']['behaviours']:
self._check_behaviour_view_fields(behaviour)

if not 'wiring' in self._info:
if 'wiring' not in self._info:
self._info['wiring'] = {}

self._check_array_fields(('inputs', 'outputs'), place=self._info['wiring'], required=False)
Expand Down
10 changes: 6 additions & 4 deletions src/wirecloud/commons/utils/template/parsers/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def _init(self):
def _add_translation_index(self, value, **kwargs):

if value not in self._translation_indexes:
self._translation_indexes[value] = []
self._translation_indexes[value].append(kwargs)
self._translation_indexes[text_type(value)] = []
self._translation_indexes[text_type(value)].append(kwargs)

def _get_translation_field(self, namespace, element, subject, translation_name, required=True, **kwargs):

Expand Down Expand Up @@ -203,7 +203,7 @@ def _parse_people_field(self, namespace, element, subject):
def _parse_extra_info(self):

if self._info['type'] == 'widget' or self._info['type'] == 'operator':
self._parse_widget_info()
self._parse_component_info()
elif self._info['type'] == 'mashup':
self._parse_workspace_info()

Expand Down Expand Up @@ -542,7 +542,7 @@ def _parse_wiring_views(self, wiring_element):
self._info['wiring']['outputs'] = outputs
# END TODO

def _parse_widget_info(self):
def _parse_component_info(self):

# Preference info
self._info['preferences'] = []
Expand All @@ -561,6 +561,7 @@ def _parse_widget_info(self):
'default': self._get_field(WIRE, 'default', preference, required=False),
'value': self._get_field(WIRE, 'value', preference, required=False, default=None),
'secure': self._get_field(WIRE, 'secure', preference, required=False).lower() == 'true',
'multiuser': self._get_field(WIRE, 'multiuser', preference, required=False).lower() == 'true'
}
if preference_info['type'] == 'list':
preference_info['options'] = []
Expand All @@ -587,6 +588,7 @@ def _parse_widget_info(self):
'description': self._get_translation_field(DCTERMS, 'description', prop, var_name + '_description', required=False, type='vdef', variable=var_name, field='description'),
'default': self._get_field(WIRE, 'default', prop, required=False),
'secure': self._get_field(WIRE, 'secure', prop, required=False).lower() == 'true',
'multiuser': self._get_field(WIRE, 'multiuser', prop, required=False).lower() == 'true',
})

self._parse_wiring_info()
Expand Down
Loading