From e4cca3b7170f059b0b5f975a8333d11986236e2f Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Aug 18 2020 07:33:21 +0000 Subject: frontend: rename model attributes id_ to id Otherwise the serializing hack in helpers.py:Serializer.to_dict() chokes (the function doesn't expect a different object name from the table attribute name). --- diff --git a/frontend/coprs_frontend/coprs/logic/complex_logic.py b/frontend/coprs_frontend/coprs/logic/complex_logic.py index b5a4113..b183850 100644 --- a/frontend/coprs_frontend/coprs/logic/complex_logic.py +++ b/frontend/coprs_frontend/coprs/logic/complex_logic.py @@ -342,7 +342,7 @@ class ProjectForking(object): fbuild.result_dir = '{:08}'.format(fbuild.id) fbuild.build_chroots = [ self.create_object(models.BuildChroot, c, - exclude=["id_", "build_id", "result_dir", + exclude=["id", "build_id", "result_dir", "copr_chroot_id"]) for c in build_chroots ] diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py index 4c64eb8..63c47d1 100644 --- a/frontend/coprs_frontend/coprs/models.py +++ b/frontend/coprs_frontend/coprs/models.py @@ -1411,7 +1411,7 @@ class CoprChroot(db.Model, helpers.Serializer): which means that there's only one configuration at any time. """ - id_ = db.Column('id', db.Integer, primary_key=True) + id = db.Column('id', db.Integer, primary_key=True) __table_args__ = ( # For now we don't allow adding multiple CoprChroots having the same @@ -1524,7 +1524,7 @@ class BuildChroot(db.Model, helpers.Serializer): name="build_chroot_mock_chroot_id_build_id_uniq"), ) - id_ = db.Column('id', db.Integer, primary_key=True) + id = db.Column('id', db.Integer, primary_key=True) # The copr_chrot field needs to be nullable because we don't remove # BuildChroot when we delete CoprChroot. diff --git a/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py b/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py index 87a7a25..e2c6166 100644 --- a/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py +++ b/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py @@ -207,7 +207,7 @@ class TestCoprChrootsLogic(CoprsTestCase): assert len(self.c2.copr_chroots) == 2 assert self.mc3 in self.c2.mock_chroots old_copr_chroot = self.c2.copr_chroots[1] - old_bch_ids = [bch.id_ for bch in old_copr_chroot.build_chroots] + old_bch_ids = [bch.id for bch in old_copr_chroot.build_chroots] CoprChrootsLogic.update_from_names(self.c2.user, self.c2, ["fedora-17-x86_64"]) assert len(self.c2.copr_chroots) == 1 assert self.mc3 not in self.c2.mock_chroots @@ -218,7 +218,7 @@ class TestCoprChrootsLogic(CoprsTestCase): new_copr_chroot = self.c2.copr_chroots[1] assert old_copr_chroot != new_copr_chroot - assert old_bch_ids == [bch.id_ for bch in new_copr_chroot.build_chroots] + assert old_bch_ids == [bch.id for bch in new_copr_chroot.build_chroots] class TestPinnedCoprsLogic(CoprsTestCase): diff --git a/pylintrc b/pylintrc index 2199d94..30f5206 100644 --- a/pylintrc +++ b/pylintrc @@ -84,7 +84,7 @@ variable-rgx=[a-z_][a-zA-Z0-9_]{,30}$ inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ # Regular expression which should only match correct class sttribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,42}|(__.*__))$ +class-attribute-rgx=id|([A-Za-z_][A-Za-z0-9_]{2,42}|(__.*__))$ # Good variable names which should always be accepted, separated by a comma good-names=i,j,k,ex,Run,_