wbcore 1.58.2__py2.py3-none-any.whl → 1.58.3__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wbcore/contrib/io/dynamic_preferences_registry.py +11 -1
- wbcore/contrib/io/models.py +7 -1
- wbcore/contrib/io/tasks.py +23 -0
- {wbcore-1.58.2.dist-info → wbcore-1.58.3.dist-info}/METADATA +1 -1
- {wbcore-1.58.2.dist-info → wbcore-1.58.3.dist-info}/RECORD +6 -5
- {wbcore-1.58.2.dist-info → wbcore-1.58.3.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dynamic_preferences.preferences import Section
|
|
2
2
|
from dynamic_preferences.registries import global_preferences_registry
|
|
3
|
-
from dynamic_preferences.types import StringPreference
|
|
3
|
+
from dynamic_preferences.types import IntegerPreference, StringPreference
|
|
4
4
|
|
|
5
5
|
io = Section("io")
|
|
6
6
|
|
|
@@ -13,3 +13,13 @@ class AdministratorMailsPreference(StringPreference):
|
|
|
13
13
|
|
|
14
14
|
verbose_name = "Administrator mails"
|
|
15
15
|
help_text = "The mails (as comma separated string) of the person allow to send directly to the mail backend"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@global_preferences_registry.register
|
|
19
|
+
class ImportSourceDataRetentionPeriod(IntegerPreference):
|
|
20
|
+
section = io
|
|
21
|
+
name = "import_source_retention_period"
|
|
22
|
+
default = 365
|
|
23
|
+
|
|
24
|
+
verbose_name = "Import Source Retention Period"
|
|
25
|
+
help_text = "The number of days to keep the data and log info until cleanup"
|
wbcore/contrib/io/models.py
CHANGED
|
@@ -515,7 +515,9 @@ class Source(models.Model):
|
|
|
515
515
|
import_source = ImportSource.objects.create(
|
|
516
516
|
file=content_file,
|
|
517
517
|
parser_handler=parser_handler,
|
|
518
|
-
save_data=self.
|
|
518
|
+
save_data=self.import_parameters.get(
|
|
519
|
+
"save_data_in_import_source", self.data_backend.save_data_in_import_source
|
|
520
|
+
),
|
|
519
521
|
source=self,
|
|
520
522
|
)
|
|
521
523
|
res.append(import_source)
|
|
@@ -863,6 +865,9 @@ class ImportSource(ImportExportSource):
|
|
|
863
865
|
self.parser_handler.handle(self, {"data": data[self.progress_index :], **parsed_data_copy}, **kwargs)
|
|
864
866
|
if self.errors_log:
|
|
865
867
|
self.status = self.Status.WARNING.name
|
|
868
|
+
# clean log if we don't want to use space to save it
|
|
869
|
+
if not self.save_data:
|
|
870
|
+
self.log = ""
|
|
866
871
|
self.save()
|
|
867
872
|
|
|
868
873
|
def import_data(self, force_reimport: Optional[bool] = False, **kwargs):
|
|
@@ -897,6 +902,7 @@ class ImportSource(ImportExportSource):
|
|
|
897
902
|
raise e
|
|
898
903
|
elif not self.creator: # if a creator is set in this import source, they will receive a proper notification with feedback. No need then to pollute the logger
|
|
899
904
|
logger.error(f"Could not import file {self.file.name} (parser/handler: {self.parser_handler})")
|
|
905
|
+
|
|
900
906
|
self.notify()
|
|
901
907
|
|
|
902
908
|
def notify(self):
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from datetime import date, timedelta
|
|
2
|
+
|
|
3
|
+
from django.db import connection
|
|
4
|
+
from django.utils import timezone
|
|
5
|
+
from dynamic_preferences.registries import global_preferences_registry
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def clean_up_import_source(today: date | None = None):
|
|
9
|
+
if not today:
|
|
10
|
+
today = timezone.now()
|
|
11
|
+
global_preferences = global_preferences_registry.manager()
|
|
12
|
+
retention_period = global_preferences["io__import_source_retention_period"]
|
|
13
|
+
retention_until = today - timedelta(days=retention_period)
|
|
14
|
+
with connection.cursor() as cursor:
|
|
15
|
+
cursor.execute(
|
|
16
|
+
"""
|
|
17
|
+
UPDATE io_importsource
|
|
18
|
+
SET data = '{}'::jsonb,
|
|
19
|
+
log = ''
|
|
20
|
+
WHERE created < %s;
|
|
21
|
+
""",
|
|
22
|
+
(retention_until,),
|
|
23
|
+
)
|
|
@@ -664,16 +664,17 @@ wbcore/contrib/icons/backends/material.py,sha256=hsj_KRjTgHDIFJh4BDWGkx75SmtxklQ
|
|
|
664
664
|
wbcore/contrib/io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
665
665
|
wbcore/contrib/io/admin.py,sha256=Xd6LplibZI4azDt0GvS1-vHaMIGT2TDfBufU0LV2YEw,4813
|
|
666
666
|
wbcore/contrib/io/apps.py,sha256=6k6kj1S5ytYSg8YLWAkuRu39BpZJUuCd4RPH1PmaCng,1304
|
|
667
|
-
wbcore/contrib/io/dynamic_preferences_registry.py,sha256=
|
|
667
|
+
wbcore/contrib/io/dynamic_preferences_registry.py,sha256=9asttbLsmI0x64QGokmLTrs2oCOdLqSYB55mYHmQBPA,844
|
|
668
668
|
wbcore/contrib/io/enums.py,sha256=9Ph2hUn-cjfvTIhPGxlC07qubPS6R3B9ilvC3tpMm8o,417
|
|
669
669
|
wbcore/contrib/io/exceptions.py,sha256=-9pTtBr4oj7qBpKwnsN7sabu5S6gpDkWTXkA4ZaW9EE,690
|
|
670
670
|
wbcore/contrib/io/factories.py,sha256=U5ppoOMM4yd6pla_bscWo9v7ug5W_bWV29ZL4PKLZsU,7053
|
|
671
671
|
wbcore/contrib/io/imports.py,sha256=Hu8ppai06SQ_CDQ2oUbFcwduAhekCp1l1DB89kTn2nQ,13087
|
|
672
672
|
wbcore/contrib/io/mixins.py,sha256=Sy_1mfdJzrIODCRcbfiA6miU8EqKEaJhL7mEjsRhOvY,1297
|
|
673
|
-
wbcore/contrib/io/models.py,sha256=
|
|
673
|
+
wbcore/contrib/io/models.py,sha256=N5umz_bf5PtmrBYhJF5qTGLK-NPx-WbA-tkSVMF1bi0,40469
|
|
674
674
|
wbcore/contrib/io/resources.py,sha256=eGEpmyrtkB3DgFKV6m57OFzyu6jBZUIXkn5Jopeus9M,6953
|
|
675
675
|
wbcore/contrib/io/serializers.py,sha256=oS5od8ni8wUZml1zM_RAdW9VWrw226Ru4v3RBifOnFY,4639
|
|
676
676
|
wbcore/contrib/io/signals.py,sha256=jCGHjt5Qg2T1aIi4BzWYzWYb2YZT82gUMhG68v2rx58,145
|
|
677
|
+
wbcore/contrib/io/tasks.py,sha256=5qCWhoQkqV4dtjoT-odP9FI_Vd5n0l7d3F_7QTPnazM,751
|
|
677
678
|
wbcore/contrib/io/urls.py,sha256=v91WUMYKwQhI9mDnpScP6hvYdGSdQZg0yQzEljCZ4lk,1014
|
|
678
679
|
wbcore/contrib/io/utils.py,sha256=SMjQeUEg_cuBKQfnKGj-qjJDC8Z_xCOQ-t7VZxwCZt4,1359
|
|
679
680
|
wbcore/contrib/io/viewset_mixins.py,sha256=RhO8TE9RPQsubSd2H2XgIJLD92tHu-7_gO8JwROxtHI,11419
|
|
@@ -1230,6 +1231,6 @@ wbcore/viewsets/generics.py,sha256=lKDq9UY_Tyc56u1bqaIEvHGgoaXwXxpZ1c3fLVteptI,1
|
|
|
1230
1231
|
wbcore/viewsets/mixins.py,sha256=IdHd_uixOv3ExKoHxTgL5Bt8OELIwfYwhBZm0nsvZfc,12054
|
|
1231
1232
|
wbcore/viewsets/utils.py,sha256=4520Ij3ASM8lOa8QZkCqbBfOexVRiZu688eW-PGqMOA,882
|
|
1232
1233
|
wbcore/viewsets/viewsets.py,sha256=FPPESunEjlunDr5VFsjTfsquTS3iDSQkw0H6QjMKPqk,6574
|
|
1233
|
-
wbcore-1.58.
|
|
1234
|
-
wbcore-1.58.
|
|
1235
|
-
wbcore-1.58.
|
|
1234
|
+
wbcore-1.58.3.dist-info/METADATA,sha256=Cd0pn3fhP4PMkxnWcJ-4t96sWW1pV0C2fSqMT8eRYPk,2332
|
|
1235
|
+
wbcore-1.58.3.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
|
1236
|
+
wbcore-1.58.3.dist-info/RECORD,,
|
|
File without changes
|