From 9f452a62e58ee6212e64e476c69f19dbdbfffb48 Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Mon, 21 Feb 2022 11:56:57 -0800 Subject: [PATCH 1/9] docs: fix link formatting in CONTRIBUTING --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1b0da60..2deaf237 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ Before sending patches, you are recommended to run `flake8` and `isort`. You can add a git hook to do this by installing `python-pre-commit` and running `pre-commit install`. -[1] https://lists.archlinux.org/listinfo/aur-dev +[1]: https://lists.archlinux.org/listinfo/aur-dev ### Coding Guidelines From 7c3637971571c1b5757d634aa627a91ff96999da Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Mon, 21 Feb 2022 14:18:26 -0800 Subject: [PATCH 2/9] docs(docker): basic usage instructions --- docker/README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docker/README.md diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..dceee74f --- /dev/null +++ b/docker/README.md @@ -0,0 +1,39 @@ +# Aurweb and Docker + +The `INSTALL` document details a manual Aurweb setup, but Docker images are also +provided here to avoid the complications of database configuration (and so +forth). + +### Setup + +Naturally, both `docker` and `docker-compose` must be installed, and your Docker +service must be started: + +```sh +systemctl start docker.service +``` + +The main image - `aurweb` - must be built manually: + +```sh +docker compose build aurweb-image +``` + +### Starting and Stopping the Services + +With the above steps complete, you can bring up an initial cluster: + +```sh +docker compose up +``` + +Subsequent runs will be done with `start` instead of `up`. The cluster can be +stopped with `docker compose stop`. + +### Testing + +With a running cluster, execute the following in a new terminal: + +```sh +docker compose run test +``` From 27f30212e83609fafe2081f3366d376f5ecf69df Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Mon, 21 Feb 2022 14:40:18 -0800 Subject: [PATCH 3/9] docs(docker): note ports and `curl` usage --- docker/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docker/README.md b/docker/README.md index dceee74f..6fa2f142 100644 --- a/docker/README.md +++ b/docker/README.md @@ -37,3 +37,14 @@ With a running cluster, execute the following in a new terminal: ```sh docker compose run test ``` + +### Querying the RPC + +The Fast (Python) API runs on Port 8444, while the legacy PHP version runs +on 8443. You can query one like so: + +```sh +curl -k "https://localhost:8444/rpc/?v=5&type=search&arg=python" +``` + +`-k` bypasses local certificate issues that `curl` will otherwise complain about. From d92f1838404b426c6e3baad103f4dccac1a40e03 Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Wed, 23 Feb 2022 18:12:00 -0800 Subject: [PATCH 4/9] docs(docker): explain how to generate dummy data --- docker/README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 6fa2f142..89dbb739 100644 --- a/docker/README.md +++ b/docker/README.md @@ -16,7 +16,7 @@ systemctl start docker.service The main image - `aurweb` - must be built manually: ```sh -docker compose build aurweb-image +docker compose build ``` ### Starting and Stopping the Services @@ -38,6 +38,21 @@ With a running cluster, execute the following in a new terminal: docker compose run test ``` +### Generating Dummy Data + +Before you can make meaningful queries to the cluster, it needs some data. +Luckily such data can be generated. First, `docker ps` to discover the ID of the +container running the FastAPI. Then: + +```sh +docker exec -it /bin/bash +./scheme/gendummydata.py dummy.sql +mysql aurweb < dummy.sql +``` + +The generation script may prompt you to install other Arch packages before it +can proceed. + ### Querying the RPC The Fast (Python) API runs on Port 8444, while the legacy PHP version runs From 1bb4daa36ac1e92e68a528727581bb781f3d9c00 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Wed, 23 Feb 2022 18:54:35 -0800 Subject: [PATCH 5/9] doc: merge CodingGuidelines into CONTRIBUTING.md Signed-off-by: Kevin Morris --- CONTRIBUTING.md | 17 ++++++++++---- doc/CodingGuidelines | 54 -------------------------------------------- 2 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 doc/CodingGuidelines diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2deaf237..2bb840f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # Contributing -Patches should be sent to the [aur-dev@lists.archlinux.org][1] mailing list. +Patches should be sent to the [aur-dev@lists.archlinux.org][1] mailing list +or included in a merge request on the [aurweb repository][2]. Before sending patches, you are recommended to run `flake8` and `isort`. @@ -8,12 +9,20 @@ You can add a git hook to do this by installing `python-pre-commit` and running `pre-commit install`. [1]: https://lists.archlinux.org/listinfo/aur-dev +[2]: https://gitlab.archlinunx.org/archlinux/aurweb ### Coding Guidelines -1. All source modified or added within a patchset **must** maintain equivalent - or increased coverage by providing tests that use the functionality. +DISCLAIMER: We realise the code doesn't necessarily follow all the rules. +This is an attempt to establish a standard coding style for future +development. -2. Please keep your source within an 80 column width. +1. All source modified or added within a patchset **must** maintain equivalent + or increased coverage by providing tests that use the functionality +2. Please keep your source within an 80 column width +3. Use four space indentation +4. Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) +5. DRY: Don't Repeat Yourself +6. All code should be tested for good _and_ bad cases Test patches that increase coverage in the codebase are always welcome. diff --git a/doc/CodingGuidelines b/doc/CodingGuidelines deleted file mode 100644 index 46537bb2..00000000 --- a/doc/CodingGuidelines +++ /dev/null @@ -1,54 +0,0 @@ -Coding Guidelines -================= - -DISCLAIMER: We realise the code doesn't necessarily follow all the rules. -This is an attempt to establish a standard coding style for future -development. - -Coding style ------------- - -Column width: 79 columns or less within reason. - -Indentation: tabs (standard eight column width) -Please don't add any mode lines. Adjust your editor to display tabs to your -preferred width. Generally code should work with the standard eight column -tabs. - -No short open tags. '' -Try embedding as little XHTML in the PHP as possible. -Consider creating templates for XHTML. - -All markup should conform to XHTML 1.0 Strict requirements. -You can use http://validator.w3.org to check the markup. - -Prevent PHP Notices by using isset() or empty() in conditionals that -reference $_GET, $_POST, or $_REQUEST variables. - -MySQL queries should generally go into functions. - -Submitting patches ------------------- - -!!! PLEASE TEST YOUR PATCHES BEFORE SUBMITTING !!! -Submit uncompressed git-formatted patches to aur-dev@archlinux.org. - -You will need to register on the mailing list before submitting: -https://mailman.archlinux.org/mailman/listinfo/aur-dev - -Base your patches on the master branch as forward development is done there. -When writing patches please keep unnecessary changes to a minimum. - -Try to keep your commits small and focused. -Smaller patches are much easier to review and have a better chance of being -pushed more quickly into the main repo. Smaller commits also makes reviewing -the commit history and tracking down specific changes much easier. - -Try to make your commit messages brief but descriptive. - -Glossary --------- -git-formatted patch: - A patch that is produced via `git format-patch` and is sent via - `git send-email` or as an inline attachment of an email. From 9204b76110daaeb582f373836696f05f9674ce94 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 25 Feb 2022 19:24:29 -0800 Subject: [PATCH 6/9] fix: ...do not add to ActiveTUs when voting on a proposal Straight up bug. Closes #324 Signed-off-by: Kevin Morris --- aurweb/routers/trusted_user.py | 1 - test/test_trusted_user_routes.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/aurweb/routers/trusted_user.py b/aurweb/routers/trusted_user.py index 2d6ea92c..53bcecb7 100644 --- a/aurweb/routers/trusted_user.py +++ b/aurweb/routers/trusted_user.py @@ -220,7 +220,6 @@ async def trusted_user_proposal_post(request: Request, proposal: int, with db.begin(): vote = db.create(models.TUVote, User=request.user, VoteInfo=voteinfo) - voteinfo.ActiveTUs += 1 context["error"] = "You've already voted for this proposal." return render_proposal(request, context, proposal, voteinfo, voters, vote) diff --git a/test/test_trusted_user_routes.py b/test/test_trusted_user_routes.py index e2bf6497..a5c4c5e8 100644 --- a/test/test_trusted_user_routes.py +++ b/test/test_trusted_user_routes.py @@ -650,7 +650,6 @@ def test_tu_proposal_vote(client, proposal): # Store the current related values. yes = voteinfo.Yes - active_tus = voteinfo.ActiveTUs cookies = {"AURSID": tu_user.login(Request(), "testPassword")} with client as request: @@ -661,7 +660,6 @@ def test_tu_proposal_vote(client, proposal): # Check that the proposal record got updated. assert voteinfo.Yes == yes + 1 - assert voteinfo.ActiveTUs == active_tus + 1 # Check that the new TUVote exists. vote = db.query(TUVote, TUVote.VoteInfo == voteinfo, From c7c79a152b50b5536d54332c0d45e57e0462aed6 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 25 Feb 2022 19:44:10 -0800 Subject: [PATCH 7/9] upgrade: bump to v6.0.20 Signed-off-by: Kevin Morris --- aurweb/config.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aurweb/config.py b/aurweb/config.py index c2b8be79..ad8ea100 100644 --- a/aurweb/config.py +++ b/aurweb/config.py @@ -6,7 +6,7 @@ from typing import Any # Publicly visible version of aurweb. This is used to display # aurweb versioning in the footer and must be maintained. # Todo: Make this dynamic/automated. -AURWEB_VERSION = "v6.0.19" +AURWEB_VERSION = "v6.0.20" _parser = None diff --git a/pyproject.toml b/pyproject.toml index b5da9913..88f182be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ # [tool.poetry] name = "aurweb" -version = "v6.0.19" +version = "v6.0.20" license = "GPL-2.0-only" description = "Source code for the Arch User Repository's website" homepage = "https://aur.archlinux.org" From 6a243e90dbf08c3a9db8f757c11471661d18bcc1 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 7 Mar 2022 23:23:49 -0800 Subject: [PATCH 8/9] fix: only reject addvote for users with running proposals This was incorrectly indiscriminately targetting _any_ proposal for a particular user. Signed-off-by: Kevin Morris --- aurweb/routers/trusted_user.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aurweb/routers/trusted_user.py b/aurweb/routers/trusted_user.py index 53bcecb7..cbe3e47d 100644 --- a/aurweb/routers/trusted_user.py +++ b/aurweb/routers/trusted_user.py @@ -274,8 +274,10 @@ async def trusted_user_addvote_post(request: Request, context["error"] = "Username does not exist." return render_addvote(context, HTTPStatus.NOT_FOUND) + utcnow = time.utcnow() voteinfo = db.query(models.TUVoteInfo).filter( - models.TUVoteInfo.User == user).count() + and_(models.TUVoteInfo.User == user, + models.TUVoteInfo.End > utcnow)).count() if voteinfo: _ = l10n.get_translator_for_request(request) context["error"] = _( From f11e8de251af54e78043d8016b12feda38a9ec55 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 7 Mar 2022 23:32:14 -0800 Subject: [PATCH 9/9] upgrade: bump to v6.0.21 Signed-off-by: Kevin Morris --- aurweb/config.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aurweb/config.py b/aurweb/config.py index ad8ea100..9931e7d2 100644 --- a/aurweb/config.py +++ b/aurweb/config.py @@ -6,7 +6,7 @@ from typing import Any # Publicly visible version of aurweb. This is used to display # aurweb versioning in the footer and must be maintained. # Todo: Make this dynamic/automated. -AURWEB_VERSION = "v6.0.20" +AURWEB_VERSION = "v6.0.21" _parser = None diff --git a/pyproject.toml b/pyproject.toml index 88f182be..ce081ce6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ # [tool.poetry] name = "aurweb" -version = "v6.0.20" +version = "v6.0.21" license = "GPL-2.0-only" description = "Source code for the Arch User Repository's website" homepage = "https://aur.archlinux.org"