Skip to content

Commit

Permalink
Merge pull request #33390 from dimagi/es/app-man-repr
Browse files Browse the repository at this point in the history
Add `__repr__`s for app, module, and form
  • Loading branch information
esoergel authored Aug 24, 2023
2 parents 77c2ca5 + 278d2db commit 541e75b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions corehq/apps/app_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,9 @@ class FormBase(DocumentSchema):
# computed datums IDs that are allowed in endpoints
function_datum_endpoints = StringListProperty()

def __repr__(self):
return f"{self.doc_type}(id='{self.id}', name='{self.default_name()}', unique_id='{self.unique_id}')"

@classmethod
def wrap(cls, data):
data.pop('validation_cache', '')
Expand Down Expand Up @@ -2247,6 +2250,9 @@ def __init__(self, *args, **kwargs):
super(ModuleBase, self).__init__(*args, **kwargs)
self.assign_references()

def __repr__(self):
return f"{self.doc_type}(id='{self.id}', name='{self.default_name()}', unique_id='{self.unique_id}')"

@property
def is_surveys(self):
return self.case_type == ""
Expand Down Expand Up @@ -4591,6 +4597,10 @@ class Application(ApplicationBase, ApplicationMediaMixin, ApplicationIntegration

family_id = StringProperty() # ID of earliest parent app across copies and linked apps

def __repr__(self):
return (f"{self.doc_type}(id='{self._id}', domain='{self.domain}', "
f"name='{self.name}', copy_of={repr(self.copy_of)})")

def has_modules(self):
return len(self.get_modules()) > 0 and not self.is_remote_app()

Expand Down

0 comments on commit 541e75b

Please sign in to comment.