Skip to content

Commit

Permalink
Fix None comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
rixx committed Nov 14, 2024
1 parent 4d5bab5 commit a182e13
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pretalx_salesforce/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ def get_object(self):

@context
def last_sync(self):
last_speaker_sync = SpeakerProfileSalesforceSync.objects.order_by(
"last_synced"
).last()
last_submission_sync = SubmissionSalesforceSync.objects.order_by(
"last_synced"
).last()
last_speaker_sync = getattr(
SpeakerProfileSalesforceSync.objects.order_by("last_synced").last(),
"last_synced",
None,
)
last_submission_sync = getattr(
SubmissionSalesforceSync.objects.order_by("last_synced").last(),
"last_synced",
None,
)
if not last_speaker_sync and not last_submission_sync:
return None
if not last_speaker_sync:
return last_submission_sync.last_synced
return last_submission_sync
if not last_submission_sync:
return last_speaker_sync.last_synced
return max(last_speaker_sync.last_synced, last_submission_sync.last_synced)
return last_speaker_sync
return max(last_speaker_sync, last_submission_sync)

def post(self, request, *args, **kwargs):
if "sync-now" not in request.POST:
Expand Down

0 comments on commit a182e13

Please sign in to comment.