1655 |
1655 |
formdef = FormDef()
|
1656 |
1656 |
formdef.name = 'baz'
|
1657 |
1657 |
formdef.fields = [
|
1658 |
|
StringField(id='1', label='String', type='string', varname='string'),
|
|
1658 |
StringField(id='00', label='String', type='string', varname='string'),
|
1659 |
1659 |
]
|
1660 |
1660 |
formdef.workflow_id = wf.id
|
1661 |
1661 |
formdef.store()
|
1662 |
1662 |
|
1663 |
1663 |
formdata = formdef.data_class()()
|
1664 |
|
formdata.data = {'1': 'HELLO'}
|
|
1664 |
formdata.data = {'00': 'HELLO'}
|
1665 |
1665 |
formdata.just_created()
|
1666 |
1666 |
formdata.store()
|
1667 |
1667 |
pub.substitutions.feed(formdata)
|
1668 |
1668 |
|
1669 |
1669 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1670 |
item.parent = st1
|
1670 |
1671 |
item.perform(formdata)
|
1671 |
1672 |
|
1672 |
1673 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1674 |
item.parent = st1
|
1673 |
1675 |
item.fields = [{'field_id': 'bo1', 'value': '=form_var_string'}]
|
1674 |
1676 |
item.perform(formdata)
|
1675 |
1677 |
|
... | ... | |
1690 |
1692 |
formdef = FormDef()
|
1691 |
1693 |
formdef.name = 'baz'
|
1692 |
1694 |
formdef.fields = [
|
1693 |
|
StringField(id='1', label='File', type='file', varname='file'),
|
|
1695 |
StringField(id='00', label='File', type='file', varname='file'),
|
1694 |
1696 |
]
|
1695 |
1697 |
formdef.workflow_id = wf.id
|
1696 |
1698 |
formdef.store()
|
... | ... | |
1699 |
1701 |
upload.receive([open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg')).read()])
|
1700 |
1702 |
|
1701 |
1703 |
formdata = formdef.data_class()()
|
1702 |
|
formdata.data = {'1': upload}
|
|
1704 |
formdata.data = {'00': upload}
|
1703 |
1705 |
formdata.just_created()
|
1704 |
1706 |
formdata.store()
|
1705 |
1707 |
|
1706 |
1708 |
pub.substitutions.feed(formdata)
|
1707 |
1709 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1710 |
item.parent = st1
|
1708 |
1711 |
item.fields = [{'field_id': 'bo1', 'value': '=form_var_file_raw'}]
|
1709 |
1712 |
item.perform(formdata)
|
1710 |
1713 |
|
... | ... | |
1728 |
1731 |
formdata = formdef.data_class().get(formdata.id)
|
1729 |
1732 |
pub.substitutions.feed(formdata)
|
1730 |
1733 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1734 |
item.parent = st1
|
1731 |
1735 |
item.fields = [{'field_id': 'bo1', 'value': '=attachments.xxx'}]
|
1732 |
1736 |
item.perform(formdata)
|
1733 |
1737 |
|
... | ... | |
1736 |
1740 |
|
1737 |
1741 |
# check storing a file from an assembled dictionary
|
1738 |
1742 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1743 |
item.parent = st1
|
1739 |
1744 |
item.fields = [{'field_id': 'bo1',
|
1740 |
1745 |
'value': '={"content": "hello world", "filename": "hello.txt"}'}]
|
1741 |
1746 |
item.perform(formdata)
|
... | ... | |
1745 |
1750 |
assert formdata.data['bo1'].get_content() == 'hello world'
|
1746 |
1751 |
|
1747 |
1752 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1753 |
item.parent = st1
|
1748 |
1754 |
item.fields = [{'field_id': 'bo1',
|
1749 |
1755 |
'value': '={"b64_content": "SEVMTE8gV09STEQ=", "filename": "hello.txt"}'}]
|
1750 |
1756 |
item.perform(formdata)
|
... | ... | |
1759 |
1765 |
assert not 'bo1' in formdata.data
|
1760 |
1766 |
|
1761 |
1767 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1768 |
item.parent = st1
|
1762 |
1769 |
item.fields = [{'field_id': 'bo1', 'value': '="HELLO"'}]
|
1763 |
1770 |
item.perform(formdata)
|
1764 |
1771 |
|
1765 |
1772 |
formdata = formdef.data_class().get(formdata.id)
|
1766 |
1773 |
assert not 'bo1' in formdata.data
|
|
1774 |
|
|
1775 |
# check wrong field
|
|
1776 |
item = SetBackofficeFieldsWorkflowStatusItem()
|
|
1777 |
item.parent = st1
|
|
1778 |
item.fields = [{'field_id': 'bo3', 'value': '=form_var_file_raw'}]
|
|
1779 |
item.perform(formdata)
|
|
1780 |
|
|
1781 |
formdata = formdef.data_class().get(formdata.id)
|
|
1782 |
assert not 'bo1' in formdata.data
|
|
1783 |
assert not 'bo3' in formdata.data
|