Commit graph

63 commits

Author SHA1 Message Date
Kevin Morris
3e3706911c
change(python): move test_pkgbase tests to their own suite
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-15 21:43:23 -08:00
Kevin Morris
c735f9868b
change(routers.packages): delete_package -> pkgbase_delete_instance
`delete_package` was processing package deletions through `Package`
instances. This doesn't make sense; if we delete a package, we want
to target its package base.

This new function vastly simplifies the previous.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-01 12:29:50 -08:00
Kevin Morris
fc229d755b
change(python): refactor & centralize comaintainer management
This commit centralizes comaintainer management with a few new
functions and uses them more appropriately within routes:

- aurweb.packages.util.latest_priority
- aurweb.packages.util.remove_comaintainer
- aurweb.packages.util.remove_comaintainers
- aurweb.packages.util.add_comaintainer
- aurweb.packages.util.add_comaintainers
- aurweb.packages.util.rotate_comaintainers

Closes #117

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-29 19:50:17 -08:00
Kevin Morris
2baf061b96
test(routers.packages): fix package view dependency test
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-26 17:03:16 -08:00
Kevin Morris
56bd60559c
fix(packages.search): fix default ordering & improve performance
- Use queries more closely aligned to PHP's implementation; removes
  the need for separate vote/notification queries.
- Default sort by popularity

Closes #214

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-25 11:15:20 -08:00
Kevin Morris
50eec96dd0
fix(routers.packages): fix related package metadata
Closes #218

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-21 18:02:37 -08:00
Kevin Morris
22093c5c38
fix(routers.packages): restrict /pkgbase/{name}/voters to those with creds
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-19 17:15:47 -08:00
Kevin Morris
d6d41cdbad
fix(templates): add missing empty package results text
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-16 22:01:14 -08:00
Kevin Morris
26b1674c9e
fix(requests): rework handling of requests
This commit changes several things about how we were handling
package requests.

Modifications (requests):
-------------
- `/requests/{id}/close` no longer provides an Accepted selection.
  All manual request closures will cause a rejection.
- Relevent `pkgbase` actions now trigger request closures:
  `/pkgbase/{name}/delete` (deletion), `/pkgbase/{name}/merge` (merge)
  and `/pkgbase/{name}/disown` (orphan).
- Comment fields have been added to
  `/pkgbase/{name}/{delete,merge,disown}`, which is used to set the
  `PackageRequest.ClosureComment` on pending requests. If the comment
  field is left blank, a closure comment is autogenerated.
- Autogenerated request notifications are only sent out once
  as a closure notification.
- Some markup has been fixed.

Modifications (disown/orphan):
-----------------------------
- Orphan requests are now handled through the same path as
  deletion/merge.
- We now check for due date when disowning as non-maintainer;
  previously, this was only done for display and not functionally.
  This check applies to Trusted Users' disowning of a package.

This style of notification flow does reduce our visibility, but
accounting can still be done via the close request; it includes
the action, pkgbase name and the user who accepted it.

Closes #204

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 19:09:51 -08:00
Kevin Morris
7f981b9ed7
fix(fastapi): utilize auto_{orphan,deletion}_age
Didn't get this in when the initial request port went down;
here it is.

Auto-accept orphan requests when the package has been out of
date for longer than auto_orphan_age.

Auto-accept deletion requests by the package's maintainer
if the package has been uploaded within auto_deletion_age
seconds ago.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 21:27:03 -08:00
Kevin Morris
fa43f6bc3e
change(aurweb): add parallel tests and improve aurweb.db
This change utilizes pytest-xdist to perform a multiproc test
run and reworks aurweb.db's code. We no longer use a global
engine, session or Session, but we now use a memo of engines
and sessions as they are requested, based on the PYTEST_CURRENT_TEST
environment variable, which is available during testing.

Additionally, this change strips several SQLite components
out of the Python code-base.

SQLite is still compatible with PHP and sharness tests, but
not with our FastAPI implementation.

More changes:
------------
- Remove use of aurweb.db.session global in other code.
- Use new aurweb.db.name() dynamic db name function in env.py.
- Added 'addopts' to pytest.ini which utilizes multiprocessing.
    - Highly recommended to leave this be or modify `-n auto` to
      `-n {cpu_threads}` where cpu_threads is at least 2.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:59 -08:00
Kevin Morris
686c032290
feat(fastapi): add id="licenses" to package details licenses
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:55:04 -08:00
Kevin Morris
7aa959150e
feat(fastapi): add id="conflicts" to package details conflicts
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:54:30 -08:00
Kevin Morris
a33e9bd571
feat(fastapi): add Replaces field to package details
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:15:29 -08:00
Kevin Morris
50a9690c2d
feat(fastapi): add Provides field in package details
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:15:03 -08:00
Kevin Morris
363afff332
feat(fastapi): add /pkgbase/{name}/keywords (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 17:36:08 -08:00
Kevin Morris
c28f1695ed
fix(fastapi): support by maintainer search with no keywords
In this case, package search should return orphaned packages.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 16:24:53 -07:00
Kevin Morris
9464de108f
feat(fastapi): add /pkgbase/{name}/comments/{id}/edit (get)
This is needed so that users can edit comments when they don't have
Javascript being used in their browser.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 21:37:52 -07:00
Kevin Morris
7f4c011dc3
fix(fastapi): sanitize PP/O parameters for package search
This definitely leaked through in more areas. We'll need to reuse
this new utility function in a few other routes in upcoming commits.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 20:39:55 -07:00
Kevin Morris
691b7b9091
feat(fastapi): add comment actions to /account/{username}/comments
With this change, we've decoupled some partials shared between
`/pkgbase/{name}` and `/account/{username}/comments`. The comment
actions template now resolves its package base via the `comment`
instance instead of requiring `pkgbase`.

We've also modified the existing package comment routes to
support execution from any location using the `next` parameter.
This allows us to reuse code from package comments for
account comments actions.

Moved the majority of comment editing javascript to its own
.js file.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 17:18:49 -07:00
Kevin Morris
adb6252f85
feat(fastapi): add /account/{username}/comments
This commit contains a base template of account comments
in sorted order (based on ColumnTS.desc).

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 13:21:16 -07:00
Kevin Morris
5fb75b9614
feat(fastapi): add /pkgbase/{name}/merge (post)
Changes:

- `via` is not required in FastAPI. We deduce the involved
  requests via their PackageBaseName / MergeBaseName columns
  and set them to Accepted when merged.
- When erroneous input is given, the error is now presented
  on the merge page instead of sending the user to the pkgbase
  page.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 19:03:32 -07:00
Kevin Morris
60bffa4fb6
feat(FastAPI): add /packages (post) action: 'delete'
Improvements:

- Package deletion now creates a PackageRequest on behalf of
  the deleter if one does not yet exist.
- All package deletions are now logged to keep track of who did what.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 18:23:15 -07:00
Kevin Morris
13b344d238
feat(FastAPI): add /packages (post) action: 'disown'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 19:38:14 -07:00
Kevin Morris
f1ad1b9aed
feat(FastAPI): add /packages (post) action: 'adopt'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 19:01:13 -07:00
Kevin Morris
d5520c9ed2
feat(FastAPI): add /packages (post) action: 'unnotify'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 17:38:44 -07:00
Kevin Morris
b277d94e0b
feat(FastAPI): add /packages (post) action: 'notify'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 16:52:04 -07:00
Kevin Morris
fb85cb60a0
feat(FastAPI): add /packages (post) action: 'unflag'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:29:55 -07:00
Kevin Morris
2b9840149e
feat(fastapi): add /pkgbase/{name}/merge (get)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-20 20:31:44 -07:00
Kevin Morris
37f0c352f6
feat(FastAPI): add /pkgbase/{name}/flag-comment (get)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-19 13:39:00 -07:00
Kevin Morris
c588a4e82e
feat(FastAPI): add /packages (post)
The POST /packages route takes an `action`, `merge_into` and `confirm`
form data arguments. It then routes over to `action`'s callback provided
by `PACKAGE_ACTIONS`. This commit does not implement actions, but
mocks out the flow we would expect from the POST route.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-18 17:43:27 -07:00
Kevin Morris
c572a97d1c
fix(fastapi): EXPECTATION_FAILED -> BAD_REQUEST
Usage of EXPECTATION_FAILED in these cases is totally wrong.
EXPECTATION_FAILED is a failure in terms of the HTTP protocol,
not user input. Change all usage of EXPECTATION_FAILED to BAD_REQUEST.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 17:38:33 -07:00
Kevin Morris
2d46811c45
fix(FastAPI): display VCS note when flagging a VCS package
Closes: #131

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 16:16:11 -07:00
Kevin Morris
71b3f781f7
fix(FastAPI): maintainers are allowed to unflag their packages
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 15:11:45 -07:00
Kevin Morris
5bbc94f2ef
fix(FastAPI): add /pkgbase/{name}/flag (get)
This was missed in the [un]flag (post) commit.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-09 18:41:32 -07:00
Kevin Morris
305d077973
feat(FastAPI): add /pkgbase/{name}/adopt (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-08 15:58:00 -07:00
Kevin Morris
63498f5edd
fix(FastAPI): use popupdate when [un]voting
The `aurweb.scripts.popupdate` script is used to maintain
the NumVotes and Popularity field. We could do the NumVotes
change more simply; however, since this is already a long-term
implementation, we're going to use it until we move scripts
over to ORM.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-08 15:29:47 -07:00
Kevin Morris
d38abd7832
feat(FastAPI): add /pkgbase/{name}/delete (get, post)
In addition, we've had to add cascade arguments to backref so
sqlalchemy treats the relationships as proper cascades.

Furthermore, our pkgbase actions template was not rendering
actions properly based on TU credentials.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 20:36:24 -07:00
Kevin Morris
16d516c221
feat(FastAPI): add /pkgbase/{name}/disown (get, post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 20:13:40 -07:00
Kevin Morris
0a02df363a
feat(FastAPI): add /pkgbase/{name}/[un]vote (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 18:22:04 -07:00
Kevin Morris
0dfff2bcb2
feat(FastAPI): add /pkgbase/{name}/[un]notify (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 17:23:14 -07:00
Kevin Morris
8eadb4251d
feat(FastAPI): add /pkgbase/{name}/[un]flag (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 16:04:54 -07:00
Kevin Morris
e5299b5ed4
fix(FastAPI): pkgbase/package tests
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-06 23:17:08 -07:00
Kevin Morris
f6141ff177
feat(FastAPI): add /requests/{id}/close (get, post)
Changes from PHP:

- If a user submits a POST request with an invalid reason,
  they are returned back to the closure form with a BAD_REQUEST status.
- Now, users which created a PackageRequest have the ability to close
  their own.
- Form action has been changed to `/requests/{id}/close`.

Closes https://gitlab.archlinux.org/archlinux/aurweb/-/issues/20

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:47:05 -07:00
Kevin Morris
1c031638c6
feat(FastAPI): add /pkgbase/{name}/request (post)
This change implements the FastAPI version of the
/pkgbase/{name}/request form's action.

Changes from PHP:

- Additional errors are now displayed for the **merge_into** field,
  which are only displayed when the Merge type is selected.
    - If the **merge_into** field is empty, a new error is displayed:
      'The "Merge into" field must not be empty.'
    - If the **merge_into** field is given the name of a package base
      which does not exist, a new error is displayed:
      "The package base you want to merge into does not exist."
    - If the **merge_into** field is given the name of the package
      base that a request is being created for, a new error is
      displayed: "You cannot merge a package base into itself."
- When an error is encountered, users are now brought back to
  the request form which they submitted and an error is displayed
  at the top of the page.
- If an invalid type is provided, users are returned to a BAD_REQUEST
  status rendering of the request form.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:46:49 -07:00
Kevin Morris
ad8369395e
feat(FastAPI): add /pkgbase/{name}/request (get)
This change brings in the package base request form
for new submissions.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:46:48 -07:00
Kevin Morris
1cf9420997
feat(FastAPI): allow reporters to cancel their own requests (1/2)
This change required a slight modification of how we handle
the Requests page. It is now available to all users.

This commit provides 1/2 of the implementation which actually
satisfies this feature. 2/2 will contain the actual implementation
of closures of requests, which will also allow users who created
the request to decide to close it.

Issue: https://gitlab.archlinux.org/archlinux/aurweb/-/issues/20

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:46:38 -07:00
Kevin Morris
99482f9962
feat(FastAPI): added /requests (get) route
Introduces `aurweb.defaults` and `aurweb.filters`.

`aurweb.filters` is a location developers can put their additional
Jinja2 filters and/or functions. We should slowly move all of our
filters over here, where it makes sense.

`aurweb.defaults` is a new module which hosts some default constants
and utility functions, starting with offsets (O) and per page values
(PP).

As far as the new GET /requests is concerned, we match up here to
PHP's implementation, with some minor improvements:

Improvements:

* PP on this page is now configurable: 50 (default), 100, or 250.
    * Example: `https://localhost:8444/requests?PP=250`

Modifications:

* The pagination is a bit different, but serves the exact same purpose.
* "Last" no longer goes to an empty page.
    * Closes: https://gitlab.archlinux.org/archlinux/aurweb/-/issues/14

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:43:48 -07:00
Kevin Morris
4d191b51f9
feat(FastAPI): add /pkgbase/{name}/comaintainers (get, post)
Changes from PHP:

- Form action now points to `/pkgbase/{name}/comaintainers`.
- When an error occurs, users are sent back to
  `/pkgbase/{name}/comaintainers` with an error at the top of the page.
  (PHP used to send people to /pkgbase/, which ended up at a blank
  search page).

Closes: https://gitlab.archlinux.org/archlinux/aurweb/-/issues/51

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 20:19:09 -07:00
Kevin Morris
2efd254974
feat(FastAPI): add /pkgbase/{name}/comments/{id}/unpin (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 16:59:46 -07:00