|
@@ -31,6 +31,7 @@ class SampleAntrag(Antrag):
|
|
|
}
|
|
|
})
|
|
|
self.instance = result
|
|
|
+ self.set_documents()
|
|
|
return
|
|
|
|
|
|
raise Exception(f'No offer available for product {self.product_name}')
|
|
@@ -98,8 +99,6 @@ class SampleAntrag(Antrag):
|
|
|
# updates files in attachment activity
|
|
|
#
|
|
|
|
|
|
- print('\n*** Update Attachments')
|
|
|
-
|
|
|
# get documents activity
|
|
|
document_activity = next(filter(
|
|
|
lambda activity: activity.get('name') == "Documents",
|
|
@@ -116,7 +115,7 @@ class SampleAntrag(Antrag):
|
|
|
attachments = next(filter(
|
|
|
lambda field: field.get('name') == "Attachments",
|
|
|
document_activity['fields']
|
|
|
- ))
|
|
|
+ ), None)
|
|
|
|
|
|
print('Document Activity:')
|
|
|
print(document_activity)
|
|
@@ -129,10 +128,54 @@ class SampleAntrag(Antrag):
|
|
|
attachments['valueChosenOrEntered'] = [
|
|
|
{
|
|
|
"id": file.id,
|
|
|
- "filename": file.filename,
|
|
|
+ "name": file.filename,
|
|
|
"created": file.created.strftime(date_format),
|
|
|
"type": file.type,
|
|
|
+ "link": f"api/files/{file.id}",
|
|
|
} for index, file in enumerate(antrag_files)
|
|
|
+ ]
|
|
|
+
|
|
|
+ def set_documents(self):
|
|
|
+ #
|
|
|
+ # updates files in attachment activity
|
|
|
+ #
|
|
|
+
|
|
|
+ # get documents activity
|
|
|
+ document_activity = next(filter(
|
|
|
+ lambda activity: activity.get('name') == "Documents",
|
|
|
+ self.instance['possible_activities'],
|
|
|
+ ), None)
|
|
|
+
|
|
|
+ if document_activity is None:
|
|
|
+ raise Exception('Document Activity not found')
|
|
|
+
|
|
|
+ # get documents field
|
|
|
+ documents = next(filter(
|
|
|
+ lambda field: field.get('name') == "Documents",
|
|
|
+ document_activity['fields']
|
|
|
+ ), None)
|
|
|
+
|
|
|
+ # create field if not exist
|
|
|
+ if documents is None:
|
|
|
+ documents = {
|
|
|
+ "fieldType": 2,
|
|
|
+ "name": "Documents",
|
|
|
+ "brief": "Documents",
|
|
|
+ "tooltip": "Here you can manage the documents",
|
|
|
+ "fieldDataType": "Documents",
|
|
|
+ }
|
|
|
+ document_activity['fields'].append(documents)
|
|
|
+
|
|
|
+ # get files from db
|
|
|
+ antrag_docs = File.query.filter_by(type="document").group_by(File.filename).all()
|
|
|
+ documents['valueChosenOrEntered'] = [
|
|
|
+ {
|
|
|
+ "id": file.id,
|
|
|
+ "name": file.filename,
|
|
|
+ "created": file.created.strftime(date_format),
|
|
|
+ "signed": "Yes" if file.processed else "No",
|
|
|
+ "link": f"api/files/{file.id}",
|
|
|
+ } for file in antrag_docs
|
|
|
]
|
|
|
|
|
|
|
|
@@ -160,6 +203,7 @@ class SampleAntrag(Antrag):
|
|
|
|
|
|
self.update_auto_brands()
|
|
|
self.update_attachments()
|
|
|
+ self.set_documents()
|
|
|
|
|
|
|
|
|
def executeActivity(self, data):
|