Skip to content

Commit

Permalink
improvement log for sync_plans command
Browse files Browse the repository at this point in the history
  • Loading branch information
ma1onso committed Jan 26, 2020
1 parent 0830c85 commit b7e7ee2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions depayco/management/commands/sync_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@ def handle(self, *args, **options):

if 'message' in response and response['message'] == 'Plan no encontrado':
plans.create(plan_data=settings_plan)

self.stdout.write(self.style.SUCCESS(
f'Successfully create plan {settings_plan["id_plan"]} on epayco and local DB'
))

elif response['success'] and not Plan.objects.filter(id=settings_plan['id_plan']).exists():
plans.sync_plan_from_epayco_data(epayco_plan_data=settings_plan)

self.stdout.write(self.style.SUCCESS(
f'Successfully create plan {settings_plan["id_plan"]} on local DB (from existing data on epayco)'
))

elif response['success']:
plans.update(plan_id=settings_plan['id_plan'], plan_data=settings_plan)

self.stdout.write(self.style.SUCCESS(
'Successfully create or update plan "%s" on epayco and local DB' %
settings_plan['id_plan']
))
self.stdout.write(self.style.SUCCESS(
f'Successfully update plan {settings_plan["id_plan"]} on epayco and local DB'
))

except AttributeError:
self.stdout.write(self.style.WARNING('Is needed configure PLANS in settings.py'))

0 comments on commit b7e7ee2

Please sign in to comment.