Skip to content

Commit

Permalink
Merge pull request #77 from dimagi/clean-up-form
Browse files Browse the repository at this point in the history
remove ._form and .get_form and add explicit form DictProperty
  • Loading branch information
czue committed Dec 23, 2013
2 parents 3ae5780 + 649337b commit a90a160
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions couchforms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ class XFormInstance(SafeSaveDocument, UnicodeMixIn, ComputedDocumentMixin):
received_on = DateTimeProperty()
partial_submission = BooleanProperty(default=False) # Used to tag forms that were forcefully submitted without a touchforms session completing normally
history = SchemaListProperty(XFormOperation)

@property
def get_form(self):
"""public getter for the xform's form instance, it's redundant with
_form but wrapping that access gives future audit capabilities"""
return self._form

form = DictProperty()

@classmethod
def get(cls, docid, rev=None, db=None, dynamic_properties=True):
Expand Down Expand Up @@ -137,29 +131,25 @@ def get_forms_by_user(cls, user, start=None, end=None):
docs = iter_docs(cls.get_db(), [r['id'] for r in results])
return (cls(doc) for doc in docs)

@property
def _form(self):
return self[const.TAG_FORM]

@property
def type(self):
return self._form.get(const.TAG_TYPE, "")
return self.form.get(const.TAG_TYPE, "")

@property
def name(self):
return self._form.get(const.TAG_NAME, "")
return self.form.get(const.TAG_NAME, "")

@property
def version(self):
return self._form.get(const.TAG_VERSION, "")
return self.form.get(const.TAG_VERSION, "")

@property
def uiversion(self):
return self._form.get(const.TAG_UIVERSION, "")
return self.form.get(const.TAG_UIVERSION, "")

@property
def metadata(self):
if (const.TAG_META) in self._form:
if (const.TAG_META) in self.form:
def _clean(meta_block):
# couchdbkit chokes on dates that aren't actually dates
# so check their validity before passing them up
Expand Down Expand Up @@ -363,10 +353,6 @@ class SubmissionErrorLog(XFormError):
here.
"""
md5 = StringProperty()

# this is here as a bit of an annoying hack so that __unicode__ works
# when called from the base class
form = DictProperty()

def __unicode__(self):
return "Doc id: %s, Error %s" % (self.get_id, self.problem)
Expand Down

0 comments on commit a90a160

Please sign in to comment.