Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions fmrest/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def create(self, record: Record,
def create_record(self, field_data: Dict[str, Any],
portals: Optional[Dict[str, Any]] = None,
scripts: Optional[Dict[str, List]] = None,
request_layout: Optional[str] = None) -> Optional[int]:
request_layout: Optional[str] = None,
date_format: Optional[str] = None) -> Optional[int]:
"""Creates a new record with given field data and returns new internal record id.

Parameters
Expand All @@ -255,13 +256,23 @@ def create_record(self, field_data: Dict[str, Any],
the value stored in the Server instance's layout attribute and is
useful if you have a shared Server instance in a multi-threaded
program.
date_format : str, optional
The date format. Choices are:
'us' for US format MM/DD/YYYY,
'file' for file locale format,
'iso-8601' for ISO format YYYY-MM-DD.
If not specified, the default value is 'us'.
"""
path = self._get_api_path('record', request_layout)

request_data: Dict = {'fieldData': field_data}

if portals:
request_data['portalData'] = portals

if date_format:
request_data['dateFormats'] = self._date_format_for_keyword(date_format)

# build script param object in FMSDAPI style
script_params = build_script_params(scripts) if scripts else None
if script_params:
Expand All @@ -286,7 +297,8 @@ def edit(self, record: Record, validate_mod_id: bool = False,
def edit_record(self, record_id: int, field_data: Dict[str, Any],
mod_id: Optional[int] = None, portals: Optional[Dict[str, Any]] = None,
scripts: Optional[Dict[str, List]] = None,
request_layout: Optional[str] = None) -> bool:
request_layout: Optional[str] = None,
date_format: Optional[str] = None) -> bool:
"""Edits the record with the given record_id and field_data. Return True on success.

Parameters
Expand Down Expand Up @@ -318,6 +330,12 @@ def edit_record(self, record_id: int, field_data: Dict[str, Any],
the value stored in the Server instance's layout attribute and is
useful if you have a shared Server instance in a multi-threaded
program.
date_format : str, optional
The date format. Choices are:
'us' for US format MM/DD/YYYY,
'file' for file locale format,
'iso-8601' for ISO format YYYY-MM-DD.
If not specified, the default value is 'us'.
"""
path = self._get_api_path(
'record_action', request_layout).format(record_id=record_id)
Expand All @@ -329,6 +347,9 @@ def edit_record(self, record_id: int, field_data: Dict[str, Any],
if portals:
request_data['portalData'] = portals

if date_format:
request_data['dateFormats'] = self._date_format_for_keyword(date_format)

# build script param object in FMSDAPI style
script_params = build_script_params(scripts) if scripts else None
if script_params:
Expand Down