Skip to content

Commit

Permalink
[chores:refactoring] Added helper methods in AbstractObjectLocationForm
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy authored Jan 8, 2025
1 parent 96f7ba1 commit 83a0138
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions django_loci/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# set initial values for custom fields
initial = {}
obj = self.instance
location = obj.location
floorplan = obj.floorplan
location = self._get_initial_location()
floorplan = self._get_initial_floorplan()
if location:
initial.update(
{
Expand All @@ -249,6 +248,12 @@ def __init__(self, *args, **kwargs):
]
self.initial.update(initial)

def _get_initial_location(self):
return self.instance.location

def _get_initial_floorplan(self):
return self.instance.floorplan

@cached_property
def floorplan_model(self):
return self.Meta.model.floorplan.field.remote_field.model
Expand Down

0 comments on commit 83a0138

Please sign in to comment.