Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
bug 1330357: Allow mixed case interest tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitlock committed Jan 20, 2017
1 parent 6abdc10 commit 826cf93
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
15 changes: 1 addition & 14 deletions kuma/core/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,9 @@ def all_ns(self, namespace=None):

if namespace is not None:
# Namespace requested, so generate filtered set
# TODO: Do this in the DB query? Might not be worth it.
#
# On databases with case-insensitive collation, we can end
# up with duplicate tags (the same tag, differing only by
# case, like 'javascript' and 'JavaScript') in some
# cases. The most common instance of this is user
# tags, which are coerced to lowercase on save to avoid
# the problem, but because there are a large number of
# these duplicates already existing, we do a quick filter
# here to ensure we don't return a bunch of dupes that
# differ only by case.
seen = []
results = []
for tag in tags:
if tag.name.startswith(namespace) and tag.name.lower() not in seen:
seen.append(tag.name.lower())
if tag.name.startswith(namespace):
results.append(tag)
return results

Expand Down
6 changes: 2 additions & 4 deletions kuma/static/js/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@
$(document).ready(function(){

// Convert interests text field into a tag-it widget
// also lowercase to deal with database weirdness
var interests = $('#id_user-interests').val().toLowerCase();
var interests = $('#id_user-interests').val();
$('#id_user-interests').hide()
.val(interests)
.after('<ul id="tagit-interests"></ul>')
Expand All @@ -108,9 +107,8 @@
$('#tagit-interests .tagit-new input').attr('placeholder', gettext('New interest...'));

// Convert the expertise text field into tag list
// lowercase to deal with database weirdness
// checkboxes sync'd to interests
var expertise = $('#id_user-expertise').val().toLowerCase();
var expertise = $('#id_user-expertise').val();
$('#id_user-expertise').hide()
.val(expertise)
.after('<ul id="tags-expertise" class="tags"></ul>');
Expand Down
2 changes: 1 addition & 1 deletion kuma/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def user_edit(request, username):
# Update tags from form fields
for field, tag_ns in field_to_tag_ns:
field_value = user_form.cleaned_data.get(field, '')
tags = [tag.lower() for tag in parse_tags(field_value)]
tags = parse_tags(field_value)
new_user.tags.set_ns(tag_ns, *tags)

return redirect(edit_user)
Expand Down

0 comments on commit 826cf93

Please sign in to comment.