diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 67cbf24..38962c5 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3473,6 +3473,8 @@ def set_custom_key_fields(session, project, fields, types, data): if types[idx] != "list": # Only Lists use data, strip it otherwise data[idx] = None + else: + data[idx] = [item.strip() for item in data[idx].split(',')] if key in current_keys: issuekey = current_keys[key] diff --git a/pagure/lib/model.py b/pagure/lib/model.py index d3dde2d..19707a4 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -1002,44 +1002,18 @@ class IssueKeys(BASE): @property def data(self): ''' Return the list of items ''' - items = {} if self.key_data: - items = json.loads(self.key_data) + return json.loads(self.key_data) else: return None - return items['list'] - - @property - def data_string(self): - ''' Take the list from key_data and convert it to a string. - This is used by the project settings custom field section. ''' - - if self.key_data: - mylist = json.loads(self.key_data) - else: - return "" - - return_str = "" - first_item = True - if mylist: - for item in mylist['list']: - if first_item: - return_str = item - first_item = False - else: - return_str = return_str + ", " + item - return return_str @data.setter def data(self, list_str): - ''' Ensures the list items are properly saved. ''' + ''' Store the list in JSON. ''' if list_str is None: self.key_data = None else: - list_list = [item.strip() for item in list_str.split(',')] - list_data = {} - list_data['list'] = list_list - self.key_data = json.dumps(list_data) + self.key_data = json.dumps(list_str) class IssueValues(BASE): diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 740c21c..a0a90c3 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -733,7 +733,7 @@
+ value={% if field.data is none %}""{% else %}"{{ field.data | join(', ') }}"{% endif %} class="form-control"/>
{% endfor %} diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 6ef7579..1a75cb7 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -1911,10 +1911,12 @@ class PagureFlaskApiIssuetests(tests.Modeltests): # Check that the bugzilla field correctly had its data removed if key.name == "bugzilla" and key.data is not None: assert False + # Check that the reviewstatus list field still has its list - if (key.name == "reviewstatus" and - key.data_string != 'ack, nack, needs review'): - assert False + if (key.name == "reviewstatus"): + for item in ['ack', 'nack', 'needs review']: + if item not in key.data: + assert False # No value specified while we try to create the field output = self.app.post(