Skip to content

Instantly share code, notes, and snippets.

@jakul
Created November 13, 2014 09:54
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 jakul/e020364c4b984b701f12 to your computer and use it in GitHub Desktop.
Save jakul/e020364c4b984b701f12 to your computer and use it in GitHub Desktop.
update pays pension field
from jobs.models import *
import datetime
starts_on = datetime.date(2014,1,1)
# Update all ongoing jobs which don't have pays_pension but should
jobs = Job.objects.filter(status__in=[Job.STATUS_POSTED, Job.STATUS_FILLED, Job.STATUS_STARTED], pays_pension='').exclude(practice__pays_pension='')
for job in jobs:
job.pays_pension = job.practice.pays_pension
job.save()
# Update all jobs which are completed and don't have pays_pension but should
jobs = Job.objects.filter(pays_pension='', locum_invoiced=False, status='completed', starts_on__gte=starts_on).exclude(practice__pays_pension='').order_by('-starts_on')
for job in jobs:
job.pays_pension = job.practice.pays_pension
job.save()
# Do one manually
jj = Job.objects.get(id=10531)
jj.pays_pension
jj.pays_pension = jj.practice.pays_pension
jj.save()
# Get the invoice id for the "create trello card" announcement
jj.locuminvoice.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment