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.
This commit is contained in:
Lucas Verney 2017-05-04 15:33:20 +02:00
parent 9d7707ec4c
commit 49f5b6a714
2 changed files with 7 additions and 1 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ build
config/
node_modules
flatisfy/web/static/assets
data/

View File

@ -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!")