diff --git a/Pipfile.lock b/Pipfile.lock index d5af237..eb6a58f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "bada6492eb644146a379953968b5a33e9b7948f427ac26a75f5ce0f02e740d79" + "sha256": "1c6dd3283c1e30c39d3b45f8fa2e45dce8a838546802be43e1679cd74169b893" }, "pipfile-spec": 6, "requires": { @@ -279,62 +279,62 @@ }, "coverage": { "hashes": [ - "sha256:015eddc5ccd5364dcb902eaecf9515636806fa1e0d5bef5769d06d0f31b54523", - "sha256:04aefca5190d1dc7a53a4c1a5a7f8568811306d7a8ee231c42fb69215571944f", - "sha256:05ac5f60faa0c704c0f7e6a5cbfd6f02101ed05e0aee4d2822637a9e672c998d", - "sha256:0bbddc54bbacfc09b3edaec644d4ac90c08ee8ed4844b0f86227dcda2d428fcb", - "sha256:1d2a830ade66d3563bb61d1e3c77c8def97b30ed91e166c67d0632c018f380f0", - "sha256:239a4e75e09c2b12ea478d28815acf83334d32e722e7433471fbf641c606344c", - "sha256:244f509f126dc71369393ce5fea17c0592c40ee44e607b6d855e9c4ac57aac98", - "sha256:25a5caf742c6195e08002d3b6c2dd6947e50efc5fc2c2205f61ecb47592d2d83", - "sha256:296a7d9bbc598e8744c00f7a6cecf1da9b30ae9ad51c566291ff1314e6cbbed8", - "sha256:2e079c9ec772fedbade9d7ebc36202a1d9ef7291bc9b3a024ca395c4d52853d7", - "sha256:33ca90a0eb29225f195e30684ba4a6db05dbef03c2ccd50b9077714c48153cac", - "sha256:33fc65740267222fc02975c061eb7167185fef4cc8f2770267ee8bf7d6a42f84", - "sha256:341dd8f61c26337c37988345ca5c8ccabeff33093a26953a1ac72e7d0103c4fb", - "sha256:34d6d21d8795a97b14d503dcaf74226ae51eb1f2bd41015d3ef332a24d0a17b3", - "sha256:3538d8fb1ee9bdd2e2692b3b18c22bb1c19ffbefd06880f5ac496e42d7bb3884", - "sha256:38a3b98dae8a7c9057bd91fbf3415c05e700a5114c5f1b5b0ea5f8f429ba6614", - "sha256:3d5a67f0da401e105753d474369ab034c7bae51a4c31c77d94030d59e41df5bd", - "sha256:50084d3516aa263791198913a17354bd1dc627d3c1639209640b9cac3fef5807", - "sha256:55f689f846661e3f26efa535071775d0483388a1ccfab899df72924805e9e7cd", - "sha256:5bc5a8c87714b0c67cfeb4c7caa82b2d71e8864d1a46aa990b5588fa953673b8", - "sha256:62bda40da1e68898186f274f832ef3e759ce929da9a9fd9fcf265956de269dbc", - "sha256:705f3d7c2b098c40f5b81790a5fedb274113373d4d1a69e65f8b68b0cc26f6db", - "sha256:75e3f4e86804023e991096b29e147e635f5e2568f77883a1e6eed74512659ab0", - "sha256:7b2a19e13dfb5c8e145c7a6ea959485ee8e2204699903c88c7d25283584bfc08", - "sha256:7cec2af81f9e7569280822be68bd57e51b86d42e59ea30d10ebdbb22d2cb7232", - "sha256:8383a6c8cefba1b7cecc0149415046b6fc38836295bc4c84e820872eb5478b3d", - "sha256:8c836309931839cca658a78a888dab9676b5c988d0dd34ca247f5f3e679f4e7a", - "sha256:8e317953bb4c074c06c798a11dbdd2cf9979dbcaa8ccc0fa4701d80042d4ebf1", - "sha256:923b7b1c717bd0f0f92d862d1ff51d9b2b55dbbd133e05680204465f454bb286", - "sha256:990fb20b32990b2ce2c5f974c3e738c9358b2735bc05075d50a6f36721b8f303", - "sha256:9aad68c3f2566dfae84bf46295a79e79d904e1c21ccfc66de88cd446f8686341", - "sha256:a5812840d1d00eafae6585aba38021f90a705a25b8216ec7f66aebe5b619fb84", - "sha256:a6519d917abb15e12380406d721e37613e2a67d166f9fb7e5a8ce0375744cd45", - "sha256:ab0b028165eea880af12f66086694768f2c3139b2c31ad5e032c8edbafca6ffc", - "sha256:aea7da970f1feccf48be7335f8b2ca64baf9b589d79e05b9397a06696ce1a1ec", - "sha256:b1196e13c45e327d6cd0b6e471530a1882f1017eb83c6229fc613cd1a11b53cd", - "sha256:b368e1aee1b9b75757942d44d7598dcd22a9dbb126affcbba82d15917f0cc155", - "sha256:bde997cac85fcac227b27d4fb2c7608a2c5f6558469b0eb704c5726ae49e1c52", - "sha256:c4c2872b3c91f9baa836147ca33650dc5c172e9273c808c3c3199c75490e709d", - "sha256:c59d2ad092dc0551d9f79d9d44d005c945ba95832a6798f98f9216ede3d5f485", - "sha256:d1da0a2e3b37b745a2b2a678a4c796462cf753aebf94edcc87dcc6b8641eae31", - "sha256:d8b7339180d00de83e930358223c617cc343dd08e1aa5ec7b06c3a121aec4e1d", - "sha256:dd4b3355b01273a56b20c219e74e7549e14370b31a4ffe42706a8cda91f19f6d", - "sha256:e08c470c2eb01977d221fd87495b44867a56d4d594f43739a8028f8646a51e0d", - "sha256:f5102a92855d518b0996eb197772f5ac2a527c0ec617124ad5242a3af5e25f85", - "sha256:f542287b1489c7a860d43a7d8883e27ca62ab84ca53c965d11dac1d3a1fab7ce", - "sha256:f78300789a708ac1f17e134593f577407d52d0417305435b134805c4fb135adb", - "sha256:f81bc26d609bf0fbc622c7122ba6307993c83c795d2d6f6f6fd8c000a770d974", - "sha256:f836c174c3a7f639bded48ec913f348c4761cbf49de4a20a956d3431a7c9cb24", - "sha256:fa21a04112c59ad54f69d80e376f7f9d0f5f9123ab87ecd18fbb9ec3a2beed56", - "sha256:fcf7d1d6f5da887ca04302db8e0e0cf56ce9a5e05f202720e49b3e8157ddb9a9", - "sha256:fd27d8b49e574e50caa65196d908f80e4dff64d7e592d0c59788b45aad7e8b35" + "sha256:018a12985185038a5b2bcafab04ab833a9a0f2c59995b3cec07e10074c78635f", + "sha256:02ff6e898197cc1e9fa375581382b72498eb2e6d5fc0b53f03e496cfee3fac6d", + "sha256:042183de01f8b6d531e10c197f7f0315a61e8d805ab29c5f7b51a01d62782747", + "sha256:1014fbf665fef86cdfd6cb5b7371496ce35e4d2a00cda501cf9f5b9e6fced69f", + "sha256:1137f46adb28e3813dec8c01fefadcb8c614f33576f672962e323b5128d9a68d", + "sha256:16852febd96acd953b0d55fc842ce2dac1710f26729b31c80b940b9afcd9896f", + "sha256:2174e7c23e0a454ffe12267a10732c273243b4f2d50d07544a91198f05c48f47", + "sha256:2214ee920787d85db1b6a0bd9da5f8503ccc8fcd5814d90796c2f2493a2f4d2e", + "sha256:3257fdd8e574805f27bb5342b77bc65578e98cbc004a92232106344053f319ba", + "sha256:3684bc2ff328f935981847082ba4fdc950d58906a40eafa93510d1b54c08a66c", + "sha256:3a6612c99081d8d6134005b1354191e103ec9705d7ba2754e848211ac8cacc6b", + "sha256:3d7564cc09dd91b5a6001754a5b3c6ecc4aba6323baf33a12bd751036c998be4", + "sha256:44da56a2589b684813f86d07597fdf8a9c6ce77f58976727329272f5a01f99f7", + "sha256:5013ed890dc917cef2c9f765c4c6a8ae9df983cd60dbb635df8ed9f4ebc9f555", + "sha256:54317c2b806354cbb2dc7ac27e2b93f97096912cc16b18289c5d4e44fc663233", + "sha256:56b4eafa21c6c175b3ede004ca12c653a88b6f922494b023aeb1e836df953ace", + "sha256:581ea96f92bf71a5ec0974001f900db495488434a6928a2ca7f01eee20c23805", + "sha256:5cd64adedf3be66f8ccee418473c2916492d53cbafbfcff851cbec5a8454b136", + "sha256:5df54843b88901fdc2f598ac06737f03d71168fd1175728054c8f5a2739ac3e4", + "sha256:65e528e2e921ba8fd67d9055e6b9f9e34b21ebd6768ae1c1723f4ea6ace1234d", + "sha256:6aae5cce399a0f065da65c7bb1e8abd5c7a3043da9dceb429ebe1b289bc07806", + "sha256:6cfb5a4f556bb51aba274588200a46e4dd6b505fb1a5f8c5ae408222eb416f99", + "sha256:7076b4b3a5f6d2b5d7f1185fde25b1e54eb66e647a1dfef0e2c2bfaf9b4c88c8", + "sha256:73ca8fbc5bc622e54627314c1a6f1dfdd8db69788f3443e752c215f29fa87a0b", + "sha256:79b356f3dd5b26f3ad23b35c75dbdaf1f9e2450b6bcefc6d0825ea0aa3f86ca5", + "sha256:7a892be37ca35eb5019ec85402c3371b0f7cda5ab5056023a7f13da0961e60da", + "sha256:8192794d120167e2a64721d88dbd688584675e86e15d0569599257566dec9bf0", + "sha256:820bc841faa502e727a48311948e0461132a9c8baa42f6b2b84a29ced24cc078", + "sha256:8f894208794b164e6bd4bba61fc98bf6b06be4d390cf2daacfa6eca0a6d2bb4f", + "sha256:a04e990a2a41740b02d6182b498ee9796cf60eefe40cf859b016650147908029", + "sha256:a44963520b069e12789d0faea4e9fdb1e410cdc4aab89d94f7f55cbb7fef0353", + "sha256:a6bb74ed465d5fb204b2ec41d79bcd28afccf817de721e8a807d5141c3426638", + "sha256:ab73b35e8d109bffbda9a3e91c64e29fe26e03e49addf5b43d85fc426dde11f9", + "sha256:aea072a941b033813f5e4814541fc265a5c12ed9720daef11ca516aeacd3bd7f", + "sha256:b1ccf5e728ccf83acd313c89f07c22d70d6c375a9c6f339233dcf792094bcbf7", + "sha256:b385d49609f8e9efc885790a5a0e89f2e3ae042cdf12958b6034cc442de428d3", + "sha256:b3d45ff86efb129c599a3b287ae2e44c1e281ae0f9a9bad0edc202179bcc3a2e", + "sha256:b4a474f799456e0eb46d78ab07303286a84a3140e9700b9e154cfebc8f527016", + "sha256:b95c3a8cb0463ba9f77383d0fa8c9194cf91f64445a63fc26fb2327e1e1eb088", + "sha256:c5986ee7ea0795a4095ac4d113cbb3448601efca7f158ec7f7087a6c705304e4", + "sha256:cdd31315fc20868c194130de9ee6bfd99755cc9565edff98ecc12585b90be882", + "sha256:cef4649ec906ea7ea5e9e796e68b987f83fa9a718514fe147f538cfeda76d7a7", + "sha256:d05c16cf4b4c2fc880cb12ba4c9b526e9e5d5bb1d81313d4d732a5b9fe2b9d53", + "sha256:d2e344d6adc8ef81c5a233d3a57b3c7d5181f40e79e05e1c143da143ccb6377d", + "sha256:d45d3cbd94159c468b9b8c5a556e3f6b81a8d1af2a92b77320e887c3e7a5d080", + "sha256:db14f552ac38f10758ad14dd7b983dbab424e731588d300c7db25b6f89e335b5", + "sha256:dbc5958cb471e5a5af41b0ddaea96a37e74ed289535e8deca404811f6cb0bc3d", + "sha256:ddbd2f9713a79e8e7242d7c51f1929611e991d855f414ca9996c20e44a895f7c", + "sha256:e16f3d6b491c48c5ae726308e6ab1e18ee830b4cdd6913f2d7f77354b33f91c8", + "sha256:e2afe743289273209c992075a5a4913e8d007d569a406ffed0bd080ea02b0633", + "sha256:e564c2cf45d2f44a9da56f4e3a26b2236504a496eb4cb0ca7221cd4cc7a9aca9", + "sha256:ed550e7442f278af76d9d65af48069f1fb84c9f745ae249c1a183c1e9d1b025c" ], "index": "pypi", "markers": "python_version >= '3.8'", - "version": "==7.5.3" + "version": "==7.5.4" }, "diff-cover": { "hashes": [ diff --git a/src/affiliation.py b/src/affiliation.py index a21b9c1..9ddc9a9 100644 --- a/src/affiliation.py +++ b/src/affiliation.py @@ -45,22 +45,43 @@ def __init__( """ # pylint: disable=too-many-arguments self.id = id_ - self.name = name - self.coordinator = coordinator - self.coordinator_email = coordinator_email + self.name = name if name else "" + self.coordinator = coordinator if coordinator else "" + self.coordinator_email = coordinator_email if coordinator_email else "" self.status = status - self.type = type_ - self.family = family - self.members = members - self.approvers = approvers - self.clinvar_submitter_ids = clinvar_submitter_ids + self.type = type_ if type_ else "" + self.family = family if family else "" + self.members = members if members else [] + self.approvers = approvers if approvers else [] + self.clinvar_submitter_ids = ( + clinvar_submitter_ids if clinvar_submitter_ids else [] + ) self.errors: dict = {} @classmethod - def _row_to_affiliation(cls, row: tuple) -> object: + def _row_to_affiliation(cls, row: tuple) -> "Affiliation": """Convert table row to instance of affiliations object.""" return cls(*row) + @classmethod + def get_by_id(cls, id_) -> Optional["Affiliation"]: + """Return an affiliation matching a given ID.""" + con = sqlite3.connect(DB_FILE) # type: ignore + cur = con.cursor() + try: + cur.execute("SELECT * FROM affiliations WHERE id = ?", (id_,)) + result = cur.fetchone() + except sqlite3.Error as err: + logger.error("Unable to get affiliation by ID") + logger.error("Error code: %s", err.sqlite_errorcode) + logger.error("Error name: %s", err.sqlite_errorname) + con.rollback() + result = None + con.close() + if result: + return cls._row_to_affiliation(result) + return None + @classmethod def all(cls) -> Optional[List]: """Return all affiliations in the database.""" diff --git a/src/app.py b/src/app.py index 40b92b0..d3f1ed7 100644 --- a/src/app.py +++ b/src/app.py @@ -46,6 +46,21 @@ def index(): return render_template("index.html", affiliations=affiliations_set, email=email) +@app.route("/edit") +def edit(): + """Edit an existing affiliation.""" + logger.info("User accessed edit") + affil_id = request.args.get("affil") + if not affil_id: + return redirect(url_for("index")) + email = session["email"] if "email" in session else None + # TODO(sanchegm): Redirect to main page if user is not logged in. + affiliation = Affiliation.get_by_id(affil_id) + if not affiliation: + return redirect(url_for("index")) + return render_template("edit.html", affiliation=affiliation, email=email) + + @app.route("/login", methods=["GET", "POST"]) def login(): """The login route. diff --git a/src/app_test.py b/src/app_test.py index a3654a7..f3e83a4 100644 --- a/src/app_test.py +++ b/src/app_test.py @@ -50,3 +50,17 @@ def test_sha_route(): response = CLIENT.get("/sha") assert response.status_code == 200 assert len(response.text) == 40 # SHA-1 is 40 characters in length. + + +def test_edit_route(): + """Ensure edit route redirects.""" + response = CLIENT.get("/edit?affil=10000") + assert response.status_code == 200 + assert "Submit" in response.text + assert " + + + + +
+

ID: {{affiliation.id}}

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+{% endif %} +{% endblock %} \ No newline at end of file diff --git a/src/templates/index.html b/src/templates/index.html index e7fc738..091eb36 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,20 +1,20 @@ {% extends 'base.html' %} {% block header %} -

ClinGen Affiliations Service

- +

ClinGen Affiliations Service

+ {% endblock %} {% block content %} -
- - +
+
+ @@ -24,31 +24,35 @@

ClinGen Affiliations Service

+ - - - + + {% for affiliation in affiliations %} - - - - - - - - - - - - - + + + + + + + + + + + + + {% endfor %} - -
Links ID Status Type FamilyClinVar Submitter IDs Members ApproversClinVar Submitter IDs
- Edit - View - {{ affiliation.id }}{{ affiliation.name }}{{ affiliation.coordinator }}{{ affiliation.coordinator_email }}{{ affiliation.status }}{{ affiliation.type }}{{ affiliation.family }}{{ affiliation.members }}{{ affiliation.approvers }}{{ affiliation.clinvar_submitter_ids }}
+ + + + + + + {{ affiliation.id }}{{ affiliation.name }}{{ affiliation.coordinator if affiliation.coordinator else "None" }}{{ affiliation.coordinator_email if affiliation.coordinator_email else "None" }}{{ affiliation.status }}{{ affiliation.type if affiliation.type else "None" }}{{ affiliation.family if affiliation.family else "None" }}{{ affiliation.clinvar_submitter_ids if affiliation.clinvar_submitter_ids else "None" }}{{ affiliation.members if affiliation.members else "None" }}{{ affiliation.approvers if affiliation.approvers else "None" }}
-
+ + + {% endblock %} \ No newline at end of file diff --git a/src/templates/login.html b/src/templates/login.html index 5c2de05..e865e21 100644 --- a/src/templates/login.html +++ b/src/templates/login.html @@ -1,16 +1,16 @@ {% extends 'base.html' %} {% block header %} -

ClinGen Affiliations Service

- +

ClinGen Affiliations Service

+ {% endblock %} {% block content %} -
- - - - -
-
-{% endblock %} +
+ + + + +
+
+{% endblock %} \ No newline at end of file diff --git a/src/templates/signup.html b/src/templates/signup.html index 11e33cd..f1d6e0f 100644 --- a/src/templates/signup.html +++ b/src/templates/signup.html @@ -1,15 +1,16 @@ {% extends 'base.html' %} {% block header %} -

ClinGen Affiliations Service

- +

ClinGen Affiliations Service

+ {% endblock %} {% block content %} -

- To sign up for the ClinGen Affiliations Service, go to - curation.clinicalgenome.org, - and create an account there. Then use the login you created - here. -

-{% endblock %} +

+ To sign up for the ClinGen Affiliations Service, go to + curation.clinicalgenome.org, + and create an account there. Then use the login you created + here. +

+{% endblock %} \ No newline at end of file