Skip to content

Instantly share code, notes, and snippets.

@amiraliakbari
Created October 3, 2015 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiraliakbari/0e556f1f8a7810415621 to your computer and use it in GitHub Desktop.
Save amiraliakbari/0e556f1f8a7810415621 to your computer and use it in GitHub Desktop.
Refactoring Exercise
def get_page_from_queue():
pages = Page.objects.filter(username=q_key)
if pages:
page = pages[0]
setattr(page, 'priority', q_value)
page.save()
else:
pq = PageQueue(username=q_key, priority=q_value)
pq.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment