Skip to content

Commit

Permalink
Delete duplicate R25 events
Browse files Browse the repository at this point in the history
When multiple matching R25 events are found, and one or more are missing space reservations, delete them.
  • Loading branch information
btb committed Feb 19, 2020
1 parent 570ff15 commit 25d6ba2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ems_r25/management/commands/ems2r25.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,20 @@ def handle(self, *args, **options):
events = get_events(starts_with="%d_" % booking.id,
scope='extended',
include='reservations')
r25_event = events[0]

if len(events) > 1:
logger.warning("\tFound multiple R25 events")
for event in events:
if event.reservations[0].space_reservation is None:
logger.warning("\tFound R25 event with no space "
"reservation %s: %s" %
(event.event_id, event.name))
if options['update']:
logger.debug("\tDeleting!")
delete_event(event.event_id)
else:
r25_event = event

logger.debug("\tFound R25 event %s: '%s'" %
(r25_event.event_id, r25_event.name))

Expand Down

0 comments on commit 25d6ba2

Please sign in to comment.