Skip to content

Commit

Permalink
Do not attempt syncing UpcomingInvoice objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jleclanche committed Jun 11, 2020
1 parent 7324995 commit ca3b5d4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions djstripe/management/commands/djstripe_sync_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,27 @@ def handle(self, *args, **options):
for model in model_list:
self.sync_model(model)

def sync_model(self, model):
model_name = model.__name__

def _should_sync_model(self, model):
if not issubclass(model, models.StripeModel):
self.stdout.write("Skipping {} (not a StripeModel)".format(model_name))
return
return False, "not a StripeModel"

if model.stripe_class is None:
self.stdout.write("Skipping {} (no stripe_class)".format(model_name))
return
return False, "no stripe_class"

if not hasattr(model.stripe_class, "list"):
self.stdout.write("Skipping {} (no stripe_class.list)".format(model_name))
return False, "no stripe_class.list"

if model is models.UpcomingInvoice:
return False, "Upcoming Invoices are virtual only"

return True, ""

def sync_model(self, model):
model_name = model.__name__

should_sync, reason = self._should_sync_model(model)
if not should_sync:
self.stdout.write(f"Skipping {model}: {reason}")
return

self.stdout.write("Syncing {}:".format(model_name))
Expand Down

0 comments on commit ca3b5d4

Please sign in to comment.