From 49f5b6a71438d87627d05089081e408f1716cc31 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Thu, 4 May 2017 15:33:20 +0200 Subject: [PATCH] Status of flats was not correctly set at first import When importing flats for the first time, their status was not correctly set, resulting in flats not being marked as ignored when they should be. This is a bug introduced with the fix for issue #31, now fixed. --- .gitignore | 1 + flatisfy/cmds.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8850236..dc40d0c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build config/ node_modules flatisfy/web/static/assets +data/ diff --git a/flatisfy/cmds.py b/flatisfy/cmds.py index c680692..ece9a31 100644 --- a/flatisfy/cmds.py +++ b/flatisfy/cmds.py @@ -119,7 +119,12 @@ def import_and_filter(config, load_from_db=False): # For each flat already in the db, merge it (UPDATE) # instead of adding it session.merge(flats_objects.pop(each.id)) - # Add (INSERT) all the other flats in the db + + # For any other flat, it is not already in the database, so we can + # just set the status field without worrying + for flat in flats_objects.values(): + flat.status = getattr(flat_model.FlatStatus, status) + session.add_all(flats_objects.values()) LOGGER.info("Done!")