Skip to content

Commit

Permalink
Fix save function in locations' model
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna-Baldwa committed Nov 6, 2023
1 parent 96d92d2 commit 338f9da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions locations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def save(self, *args, **kwargs): # pylint: disable =W0222
adj_data = []

if Location.objects.filter(name=self.name).exists():
old_instance = Location.objects.get(name=self.name)
old_instance = Location.objects.filter(name=self.name).first()
if old_instance.connected_locs:
old_instance_adj = old_instance.connected_locs.split(",")
else:
Expand All @@ -57,7 +57,7 @@ def save(self, *args, **kwargs): # pylint: disable =W0222
UpdatedConnectionsLoc = []
for loc in adj_data:
if loc:
loc_object = Location.objects.get(name=loc)
loc_object = Location.objects.filter(name=loc).first()
UpdatedConnectionsLoc.append(loc_object)
UpdateAdjList().add_conns(
self, UpdatedConnectionsLoc
Expand All @@ -66,7 +66,7 @@ def save(self, *args, **kwargs): # pylint: disable =W0222
deleted_connections_locs = []
if deletedConnections:
for loc in deletedConnections:
deleted_loc = Location.objects.get(name=loc)
deleted_loc = Location.objects.filter(name=loc).first()
if deleted_loc is not None:
deleted_connections_locs.append(deleted_loc)
UpdateAdjList().delete_connections(self, deleted_connections_locs)
Expand Down

0 comments on commit 338f9da

Please sign in to comment.