@@ -352,10 +352,19 @@ def create_document(
352
352
self .approved_field : metadata .get (self .approved_field , None ),
353
353
self .approved_by_field : metadata .get (self .approved_by_field , None ),
354
354
self .approval_signature_field : metadata .get (self .approval_signature_field , None ),
355
- self .journal_field : []
356
355
}
357
356
}
358
357
358
+ # data_dict['metadata'][self.journal_field] = []
359
+ journal = []
360
+ journal .append (
361
+ {
362
+ "data" : convert_data_to_dict .copy (),
363
+ "metadata" : data_dict ['metadata' ].copy (),
364
+ }
365
+ )
366
+ data_dict ['metadata' ][self .journal_field ] = journal
367
+
359
368
# document_id = self.databases[form_name].insert(data_dict)
360
369
_ = self .databases [form_name ].insert (data_dict , document_id = document_id )
361
370
@@ -448,10 +457,14 @@ def update_document(
448
457
journal = document ['metadata' ].get (self .journal_field )
449
458
journal .append (
450
459
{
451
- self .last_modified_field : current_timestamp .isoformat (),
452
- self .last_editor_field : metadata .get (self .last_editor_field , None ),
453
- self .ip_address_field : metadata .get (self .ip_address_field , None ),
454
- ** dropping_unchanged_data ,
460
+ "data" : {
461
+ ** dropping_unchanged_data ,
462
+ },
463
+ "metadata" : {
464
+ self .last_modified_field : current_timestamp .isoformat (),
465
+ self .last_editor_field : metadata .get (self .last_editor_field , None ),
466
+ self .ip_address_field : metadata .get (self .ip_address_field , None ),
467
+ },
455
468
}
456
469
)
457
470
@@ -551,14 +564,17 @@ def sign_document(
551
564
journal = document ['metadata' ].get (self .journal_field )
552
565
journal .append (
553
566
{
554
- self .signature_field : signature ,
555
- self .last_modified_field : current_timestamp .isoformat (),
556
- self .last_editor_field : metadata .get (self .last_editor_field , None ),
557
- self .ip_address_field : metadata .get (self .ip_address_field , None ),
567
+ "metadata" : {
568
+ self .signature_field : signature ,
569
+ self .last_modified_field : current_timestamp .isoformat (),
570
+ self .last_editor_field : metadata .get (self .last_editor_field , None ),
571
+ self .ip_address_field : metadata .get (self .ip_address_field , None ),
572
+ },
558
573
}
559
574
)
560
575
561
576
577
+
562
578
# Here we update only a few metadata fields ... fields like approval and signature should be
563
579
# handled through separate API calls.
564
580
document ['metadata' ][self .last_modified_field ] = current_timestamp .isoformat ()
@@ -669,13 +685,18 @@ def delete_document(self, form_name:str, document_id:str, limit_users:Union[bool
669
685
journal = document ['metadata' ].get (self .journal_field )
670
686
journal .append (
671
687
{
672
- self .last_modified_field : current_timestamp .isoformat (),
673
- self .last_editor_field : metadata .get (self .last_editor_field , None ),
674
- self .ip_address_field : metadata .get (self .ip_address_field , None ),
675
- self .is_deleted_field : restore == False , # Here we base the value for _is_deleted based on the `restore` param
688
+ "metadata" : {
689
+ self .last_modified_field : current_timestamp .isoformat (),
690
+ self .last_editor_field : metadata .get (self .last_editor_field , None ),
691
+ self .ip_address_field : metadata .get (self .ip_address_field , None ),
692
+ self .is_deleted_field : restore == False , # Here we base the value for _is_deleted based on the `restore` param
693
+ },
676
694
}
677
695
)
678
696
697
+
698
+
699
+
679
700
# Here we update only a few metadata fields ... fields like approval and signature should be
680
701
# handled through separate API calls. The most important here are _is_deleted and _journal.
681
702
document ['metadata' ][self .last_modified_field ] = current_timestamp .isoformat ()
0 commit comments