Skip to content

Commit

Permalink
Fix: View users org dropdown not consistently populating with selecte…
Browse files Browse the repository at this point in the history
…d organization (#150)

* Prevent duplicates in dropdown from the view instead of in template

* Remove unused import from testing
  • Loading branch information
edmondsgarrett committed May 17, 2023
1 parent fbc6bdd commit 0f4d061
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 0 additions & 9 deletions apcd-cms/src/apps/view_users/templates/view_users.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ <h1>View Users</h1>
window.location.href = `/administration/view-users/?filter=${filter}`;
window.location.load();
}

/* remove duplicates from dropdown */

const options = []

document.querySelectorAll('#organizationFilter > option').forEach((option) => {
if (options.includes(option.value)) option.remove()
else options.push(option.value)
})
</script>

{% endblock %}
6 changes: 4 additions & 2 deletions apcd-cms/src/apps/view_users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def _set_user(usr):
table_entries = []
for user in user_content:
table_entries.append(_set_user(user,))
context['filter_options'].append(user[4])
org_name = user[4]
if org_name not in context['filter_options']: # prevent duplicates
context['filter_options'].append(user[4])

filter = self.request.GET.get('filter')

Expand All @@ -53,5 +55,5 @@ def _set_user(usr):

context.update(paginator(self.request, table_entries))
context['pagination_url_namespaces'] = 'administration:view_users'

return context

0 comments on commit 0f4d061

Please sign in to comment.