Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Adds the ability to specifiy the submission id manually
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed Aug 27, 2015
1 parent fc63494 commit 8474508
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
Unreleased
~~~~~~~~~~

- Adds the ability to specifiy the submission id manually.
[href]

- Adds the ability to pass a custom base class to the parse_form function.
[href]

Expand Down
8 changes: 4 additions & 4 deletions onegov/form/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def query(self):

return query

def add(self, name, form, state):
def add(self, name, form, state, id=None):
""" Takes a filled-out form instance and stores the submission
in the database. The form instance is expected to have a ``_source``
parameter, which contains the source used to build the form (as only
Expand All @@ -156,7 +156,7 @@ def add(self, name, form, state):
_mapper = inspect(FormSubmission).polymorphic_map.get(state)

submission = (_mapper and _mapper.class_ or FormSubmission)()
submission.id = uuid4()
submission.id = id or uuid4()
submission.name = name
submission.state = state

Expand All @@ -174,7 +174,7 @@ def add(self, name, form, state):

return submission

def add_external(self, form, state):
def add_external(self, form, state, id=None):
""" Takes a filled-out form instance and stores the submission
in the database. The form instance is expected to have a ``_source``
parameter, which contains the source used to build the form (as only
Expand All @@ -185,7 +185,7 @@ def add_external(self, form, state):
"""

return self.add(name=None, form=form, state=state)
return self.add(name=None, form=form, state=state, id=id)

def complete_submission(self, submission):
""" Changes the state to 'complete', if the data is valid. """
Expand Down

0 comments on commit 8474508

Please sign in to comment.