commit: 24047d7602bbdbaae60f88e6811dc8570227161f
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 22 11:58:33 2017 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Sun Jan 22 12:00:24 2017 +0000
URL: https://gitweb.gentoo.org/proj/grumpy.git/commit/?id=24047d76
sync: use ORM magics in sync_packages
ORM knows howto map objects to ids through relationships so skip the
details and focus on the thing you want to do.
backend/lib/sync.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/backend/lib/sync.py b/backend/lib/sync.py
index ba31477..dbb44c2 100644
--- a/backend/lib/sync.py
+++ b/backend/lib/sync.py
@@ -144,7 +144,7 @@ def sync_packages():
if package['name'] in existing_packages:
continue # TODO: Update description once we keep that in DB
else:
- new_pkg = Package(category_id=category.id,
name=package['name'])
+ new_pkg = Package(category=category, name=package['name'])
db.session.add(new_pkg)
db.session.commit()