|
@@ -5,6 +5,7 @@
|
|
|
from flask import url_for
|
|
|
from polzybackend.mediators import Antrag
|
|
|
from polzybackend.models import File
|
|
|
+from polzybackend.utils import date_format
|
|
|
from pms.fast_offer import get_fast_offer, get_value_lists
|
|
|
from functools import reduce
|
|
|
from time import sleep
|
|
@@ -99,36 +100,42 @@ class SampleAntrag(Antrag):
|
|
|
|
|
|
print('\n*** Update Attachments')
|
|
|
|
|
|
- # get attachment activity
|
|
|
- attachment_activity = next(filter(
|
|
|
- lambda activity: activity.get('name') == "Attachments",
|
|
|
+ # get documents activity
|
|
|
+ document_activity = next(filter(
|
|
|
+ lambda activity: activity.get('name') == "Documents",
|
|
|
self.instance['possible_activities'],
|
|
|
), None)
|
|
|
|
|
|
- print(attachment_activity)
|
|
|
- #print(self.instance['possible_activities'])
|
|
|
+ print('Document Activity:')
|
|
|
+ print(document_activity)
|
|
|
|
|
|
- if attachment_activity is None:
|
|
|
- return
|
|
|
+ if document_activity is None:
|
|
|
+ raise Exception('Document Activity not found')
|
|
|
+
|
|
|
+ # get attachment field
|
|
|
+ attachments = next(filter(
|
|
|
+ lambda field: field.get('name') == "Attachments",
|
|
|
+ document_activity['fields']
|
|
|
+ ))
|
|
|
+
|
|
|
+ print('Document Activity:')
|
|
|
+ print(document_activity)
|
|
|
+
|
|
|
+ if attachments is None:
|
|
|
+ raise Exception('Attachment Field not found')
|
|
|
|
|
|
# get files from db
|
|
|
antrag_files = File.query.filter_by(parent_id=self.id).all()
|
|
|
- attachment_activity['fields'] = [
|
|
|
+ attachments['valueChosenOrEntered'] = [
|
|
|
{
|
|
|
- "fieldType": 2 if file.processed else 1,
|
|
|
- "name": f'attachment_{index}',
|
|
|
- "brief": file.filename,
|
|
|
- "fieldDataType": "File",
|
|
|
- "details": json.loads(file.details),
|
|
|
- "endpoint": file.id,
|
|
|
+ "id": file.id,
|
|
|
+ "filename": file.filename,
|
|
|
+ "created": file.created.strftime(date_format),
|
|
|
+ "type": file.type,
|
|
|
} for index, file in enumerate(antrag_files)
|
|
|
]
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
def updateFields(self, data):
|
|
|
#
|
|
|
# updates antrag fields based on data
|