`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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>