comses / comses.net

comses.net wagtail site
https://www.comses.net
GNU General Public License v3.0
17 stars 16 forks source link

split incoming tags #377

Open alee opened 6 years ago

alee commented 6 years ago

Multiple fixes for this:

  1. frontend shouldn't allow tags over 100 chars (always)
  2. frontend could split by ';' or ','
  3. backend serializer should raise a validation error if tag names > 100 chars (always)
  4. backend could split by ';' or ',' as well but this seems magical and could strip out legitimate semicolony tags (not sure if that should exist though)

Thoughts?

TagSerializer(data=[OrderedDict([('name', 'Energy security; energy landscape; Egypt; multi-criteria decision analysis; agent-based modeling; Geographic Information System')])], many=True):
    name = CharField()
cpritcha commented 6 years ago
  1. sure
  2. would take some work. There is an issue about 2 on shentao/vue-multiselect#575 so maybe someone will get around to fixing it eventually (or I could attempt it as well). We would also need to split tags on the input event since it was likely that the tags from copy pasted from a journal article.
  3. from a serializer override so that's an easy fix
  4. splitting on ';' and ',' on the backend makes sense to me. I don't see why there would ever be commas or semicolons in a tag name
cpritcha commented 6 years ago

Actually 2 shouldn't be too hard either so long as it's acceptable to have a large search string and then when the user presses enter the incoming string is split by ';' and ','. An incremental split would be more difficult (creating a new tag as soon as the user presses ',' or ';').

alee commented 6 years ago

Yes, split on enter / onBlur / whenever the submitter moves on from the tag input field