Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1.0
-
Fix Version/s: 1.2.0
-
Component/s: app.editor
-
Labels:None
-
Target Version:
Description
Found a couple of problems with the list view in the Job Designer which uses this sort of URL:
http://hue.host:8088/jobsub/list/?noCache=1289555709277&owner=sam&name=Pi&
The problems are from the list_designs method in hue/apps/jobsub/src/jobsub/views.py which does:
data = JobDesign.objects.order_by('-last_modified') owner = request.GET.get("owner") name = request.GET.get('name') if owner: try: user = User.objects.get(username=owner) data = data.filter(owner=user) except User.DoesNotExist: data = [] else: owner = "" if name: data = data.filter(name__icontains=name) else: name = ''
The issues here are:
- If the username is not fully valid and a name parameter is also specified, then having data = [] will not work because the code below is expecting data to be a QuerySet rather than a list. This could be fixed by having not do anything in the except block since data is already pointing at something valid.
- The fact that one searches for a partial match while the other looks for an exact match is somewhat confusing. It would be nice if the user/owner search were instead just data = data.filter(owner_username_istartswith=owner)
Without testing it, I think that the above code could instead be:
data = JobDesign.objects.order_by('-last_modified') owner = request.GET.get('owner', '') name = request.GET.get('name', '') if owner: data = data.filter(owner__username__istartswith=owner) if name: data = data.filter(name__icontains=name)