Skip to content

Instantly share code, notes, and snippets.

@kidig
Created August 3, 2017 11:41
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 kidig/d5438851547c455159845c462a02e9c2 to your computer and use it in GitHub Desktop.
Save kidig/d5438851547c455159845c462a02e9c2 to your computer and use it in GitHub Desktop.
finish_statuses = ['finished', 'cancelled']
if self.status == self.STATUS_FINISHED:
if not self.event_type == self.TYPE_DELIVERY:
delivery = self.booking.booking_events.filter(event_type=self.TYPE_DELIVERY).first()
if delivery and delivery.status not in [finish_statuses]:
raise ValidationError({'status': ['Please finish/cancel delivery event first.']})
# delivery.status = 'finished'
# but
# delivery.status not in [finish_statuses] is FALSE!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment