diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-02 16:46:15 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-02 16:46:15 +0200 | 
| commit | 7520106958557d7bf9eab12ea2d3fce127f0dcff (patch) | |
| tree | 0848d67ba250628706662102c1e9e26c598ae2cc /ishtar_common/serializers.py | |
| parent | 826174d9e21b7d8b9c963cf0bf118045c4867d49 (diff) | |
| download | Ishtar-7520106958557d7bf9eab12ea2d3fce127f0dcff.tar.bz2 Ishtar-7520106958557d7bf9eab12ea2d3fce127f0dcff.zip  | |
Serialization: directory
Diffstat (limited to 'ishtar_common/serializers.py')
| -rw-r--r-- | ishtar_common/serializers.py | 22 | 
1 files changed, 19 insertions, 3 deletions
diff --git a/ishtar_common/serializers.py b/ishtar_common/serializers.py index 6d25efdb6..03433df89 100644 --- a/ishtar_common/serializers.py +++ b/ishtar_common/serializers.py @@ -161,7 +161,7 @@ def generic_get_results(model_list, dirname, no_geo=True):                  new_result += result_to_add                  result[key] = json.dumps(new_result, indent=2) -        excluded_fields = [] +        excluded_fields = ["history_modifier", "history_creator"]          if hasattr(model, "SERIALIZATION_EXCLUDE"):              excluded_fields = list(model.SERIALIZATION_EXCLUDE)          if no_geo: @@ -269,6 +269,20 @@ def geo_serialization(archive=False, return_empty_types=False,      return full_archive +DIRECTORY_MODEL_LIST = [ +    models.Organization, models.Person, models.Author +] + + +def directory_serialization(archive=False, return_empty_types=False, +                            archive_name=None): +    result = generic_get_results(DIRECTORY_MODEL_LIST, "common_directory") +    full_archive = archive_serialization( +        result, archive_dir="common_directory", archive=archive, +        return_empty_types=return_empty_types, archive_name=archive_name) +    return full_archive + +  def restore_serialized(archive_name, delete_existing=False):      with zipfile.ZipFile(archive_name, "r") as zip_file:          # check version @@ -280,9 +294,11 @@ def restore_serialized(archive_name, delete_existing=False):              )          DIRS = ( -            ("types", [None]), ("common_configuration", CONF_MODEL_LIST), +            ("types", [None]), +            ("common_configuration", CONF_MODEL_LIST),              ("common_imports", IMPORT_MODEL_LIST), -            ("common_geo", GEO_MODEL_LIST) +            ("common_geo", GEO_MODEL_LIST), +            ("common_directory", DIRECTORY_MODEL_LIST),          )          namelist = zip_file.namelist()          for current_dir, model_list in DIRS:  | 
