Closed AlexanderPico closed 8 years ago
apps/views.py: 43
try:
tag = get_object_or_404(Tag, name = 'systems biology')
if tag:
idx = sorted_tags.index(tag)
if idx >= 0:
sorted_tags.pop(idx)
sorted_tags.insert(0, tag)
except Http404:
idx = 0
Cool. It looks like you've got this working (for the 'scripting' tag) on apps-dev. Can you do this on apps-test for 'collections'?
We are switching over on Monday and it'd be great to have this in place.
Tried the code above and the code found at apps-dev:
try:
tag = get_object_or_404(Tag, name = 'collections')
idx = sorted_tags.index(tag)
sorted_tags.pop(idx)
sorted_tags.insert(0, tag)
except Http404:
idx = 0
Neither seems to bump "collections" up to the top.
Right. That copy/paste was messy :) I tried matching the tab/sp indentation currently at apps-dev as precisely as I could...
Any other code changes that might be relevant?
Probably easiest if you ask Barry to add your IP address to the whitelist so you can reproduce the fix. Or check the fix into repo and I'll pull it.
Ok. Got it! Added your code, which worked fine for "scripting", but even on apps-test where there is a tag for "collections" that was leading to a 500 error. This error traced back to a ZeroDivisionError just a few lines below your code, so I added a try/except and it now appears to be working and solid.
We should override the dynamic sorting of category tags and pin "collections" to the top.