Skip to content
Snippets Groups Projects
Commit 3e464139 authored by Martin Burchell's avatar Martin Burchell
Browse files

Changed tag delimiter from '|' to ','

Unfortunately bootstrap-tagsinput does not have a configurable
delimiter so settle with ',' for now (no commas allowed in tags).
parent 20155363
No related branches found
No related tags found
1 merge request!46Tagging frontend
......@@ -726,7 +726,7 @@ def test_redirected_to_home_if_next_absent_after_delete(
@pytest.mark.django_db
def test_free_tags_created_on_item_update(view, form):
# Deliberate spaces to be stripped
form.cleaned_data['tags'] = 'Monrovia | Important |age 35-40'
form.cleaned_data['tags'] = 'Monrovia , Important ,age 35-40'
view.form_valid(form)
assert_no_messages(view.request, messages.ERROR)
......@@ -760,7 +760,7 @@ def test_existing_tag_deleted_on_item_update(view, form):
@pytest.mark.django_db
def test_free_tags_created_for_new_item(add_view, form):
form.cleaned_data['tags'] = 'Monrovia|Important|age 35-40'
form.cleaned_data['tags'] = 'Monrovia,Important,age 35-40'
form.cleaned_data['id'] = 0
add_view.form_valid(form)
......@@ -807,4 +807,4 @@ def test_form_initial_values_include_tags(generic_item):
)
initial = view.get_initial()
assert initial['tags'] == 'Monrovia|age 35-40|interesting'
assert initial['tags'] == 'Monrovia,age 35-40,interesting'
......@@ -26,6 +26,7 @@ class AddEditItemView(FormView):
template_name = "hid/add_edit_item.html"
form_class = AddEditItemForm
field_taxonomies = {'tags': 'free-tags'}
tag_delimiter = ','
def _initialize_item(self, item_id, item_type):
""" Initialize the view's item from the given item id or item_type
......@@ -173,7 +174,7 @@ class AddEditItemView(FormView):
field_name = taxonomy_fields.get(taxonomy)
if field_name:
term_names = [t['name'] for t in terms]
initial[field_name] = '|'.join(term_names)
initial[field_name] = self.tag_delimiter.join(term_names)
return initial
......@@ -261,7 +262,7 @@ class AddEditItemView(FormView):
def _add_free_terms(self, item_id, free_terms):
for (taxonomy, value) in free_terms.iteritems():
transport.items.delete_all_terms(item_id, taxonomy)
term_names = [t.strip() for t in value.split('|')]
term_names = [t.strip() for t in value.split(self.tag_delimiter)]
transport.items.add_free_terms(item_id, taxonomy, term_names)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment