Commit graph

694 commits

Author SHA1 Message Date
Kevin Morris
bd2ad9b616
change(python): put pkgbase routes & impl into their own modules
Introduces new router:
- `aurweb.routers.pkgbase`

Introduces new package:
- `aurweb.pkgbase`

Introduces new modules:
- `aurweb.pkgbase.actions`
- `aurweb.pkgbase.util`

Changes:
- `pkgbase_{action}_instance` functions are now located in
  `aurweb.pkgbase.actions`.
- `pkgbase`-wise routes have been moved to
  `aurweb.routers.pkgbase`.
- `make_single_context` was moved to
  `aurweb.pkgbase.util.make_context`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-01 21:06:17 -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
278490e103
feat(models.user): add User.__str__ -> User.Username
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-31 18:31:48 -08:00
Kevin Morris
67dd432e86
feat(testing.requests): add Request.__init__
This new constructor is a beginning to making Request a bit more easy
to deal with for standard testing needs. With this commit, users can
now specify a `user` and `authenticated` state while constructing a
Request:

    request = Request(user=some_user, authenticated=True)

By default, the `authenticated` kwarg is set to False and `user` is
set to `aurweb.testing.requests.User()`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-31 18:31:48 -08:00
Kevin Morris
8f8929f324
fix(routers.packages): handle package source display
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-30 23:10:00 -08:00
Kevin Morris
be7a96076e
fix: handle broken packages which have valid provides
Closes #226

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-30 19:49:49 -08:00
Kevin Morris
6fdaeee026
change(packages.util): handle queried record links via .is_official
This removes an unneeded query from our path.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-30 19:49:41 -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
9d3e77bab1
fix(packages.util.pkg_required): correct type hints and docstring
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-29 14:48:12 -08:00
Kevin Morris
3a771fc807
fix(packages.requests): disown as maintainer does not need handle_requests
As a maintainer, we don't deal with requests at all.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-28 18:31:21 -08:00
Kevin Morris
d55dab93da
revert account type permission changes
While this does make more sense to me personally, there is no need
to change how the AUR treats its users; it has been accepted for
ages and not found to be ridden with flaws. Stay with the tried
and true method.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-27 22:41:18 -08:00
Kevin Morris
80ee7f3d4b
fix(routers.accounts): use User.can_edit_user across the board
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-27 16:05:01 -08:00
Kevin Morris
260b67c49e
change(models.user): can_edit_user should check account type id priority
The credential alone does not completely encapsulate our new
requirements for editing an account.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-27 16:04:57 -08:00
Kevin Morris
b27dab99d8
fix(routers.accounts): correct disable decision for More button
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-26 18:35:38 -08:00
Kevin Morris
84a54bb6e6
fix(routers.packages): fix package dependency ordering
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-26 15:33:00 -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
5142447b7e
fix(models.package_source): fix primary key constraints
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-21 16:00:10 -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
36bc9ae29b
fix(notify): gracefully fail notifications
Instead of allowing an exception to propogate through the framework
routes, catch it and log out an error about notifications not being
sent.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-17 18:08:36 -08:00
Kevin Morris
94e8d34948
fix(routers.accounts): use target user's account type for autofill
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-16 16:10:01 -08:00
Kevin Morris
e1543f2e91
fix(templates): import aurweb.auth.creds directly
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-15 16:06:37 -08:00
Kevin Morris
c86f71a4b4
fix(time): unquote timezone when producing it
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-15 14:01:20 -08:00
Kevin Morris
703d655a5e
fix(users.validate): fix type hints
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-14 17:11:52 -08:00
Kevin Morris
f357615bfb
change(users.validate): users can't edit their own account types
This commit also decouples testing regarding this feature
into several test functions.

Signed-off-by: Kevin Morris <kevr@0cost.org>

bump

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-14 16:45:40 -08:00
Kevin Morris
c7751d5d63
fix(util): fix account_url's base url generation
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-14 14:30:34 -08:00
Kevin Morris
02a62532da
fix(python): fix difference parsing of comaintainers
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-13 16:34:44 -08:00
Kevin Morris
de671e9b9c
fix(time): fall through and prefer AURTZ for timezone
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 23:03:26 -08:00
Kevin Morris
c47578f158
fix(auth): refresh the user record on successful auth
This will ensure the state of `request.user` is good to go
for any other users which obtain it after the backend.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 23:01:45 -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
bad57ba502
feat(exceptions): add InvariantError
This exception is to be used when a known invariant is violated.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 15:10:06 -08:00
Kevin Morris
85e6ad03db
feat(testing.email): add Email.dump
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 15:10:04 -08:00
Kevin Morris
452f5d160a
fix(python): remove unneeded newline
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-07 13:50:40 -08:00
Kevin Morris
2df54bd7a0
Merge branch 'fix-package-link' into pu 2021-12-07 12:35:21 -08:00
Kevin Morris
de7e3ab607
fix(logging): restore aurweb logger; null out root logger
After actually digging into how the logger does things,
since the root logger is required and we have specific
level-changing loggers for our components, we must no-op
the root logger to avoid it duplicating logs from the others.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-07 07:45:59 -08:00
Kevin Morris
a9a0adaead
fix(python): fix package_link check
This was failing when it matched more than one record.
This fixes that issue by using an EXISTS query.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-07 07:44:56 -08:00
Kevin Morris
8b350066c1
Merge branch 'fix-package-vote' into pu 2021-12-06 23:45:35 -08:00
Kevin Morris
4667993dad
Merge branch 'fix-comaintainer' into pu 2021-12-06 23:45:20 -08:00
Kevin Morris
0447afa2e5
fix(PackageNotification): add missing backref cascade
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-06 23:02:53 -08:00
Kevin Morris
51b4709ea4
fix(PackageVote): include backref cascade definition
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-06 23:02:06 -08:00
Kevin Morris
57df6db609
fix(PackageComaintainer): populate backref cascade properly
Closes #205

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-06 23:01:04 -08:00
Kevin Morris
cf978e23aa
fix(python): use S argument to decide Suspended
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-04 17:56:02 -08:00
Kevin Morris
0ed752277c
Merge branch 'fix-account-show' into pu 2021-12-04 17:54:36 -08:00
Kevin Morris
8501bba0ac
change(python): rework session timing
Previously, we were just relying on the cookie expiration
for sessions to expire. We were not cleaning up Session
records either.

Rework timing to depend on an AURREMEMBER cookie which is
now emitted on login during BasicAuthBackend processing.

If the SID does still have a session but it's expired,
we now delete the session record before returning.

Otherwise, we update the session's LastUpdateTS to
the current time.

In addition, stored the unauthenticated result value
in a variable to reduce redundancy.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-04 02:16:22 -08:00
Kevin Morris
224a0de784
fix(python): add logged in date field to account/show.html
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-04 01:16:14 -08:00
Kevin Morris
f8bef16d32
Merge branch 'fix-account-links' into pu 2021-12-04 00:25:57 -08:00
Kevin Morris
d0fc56d53f
fix(python): redirect when the request user can't edit target user
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-04 00:14:55 -08:00
Kevin Morris
bfa916c7b2
fix(fastapi): fix PGP Key Fingerprint display for account/show.html
There's a space between every 4 characters in the fingerprint
in PHP; we were missing it in FastAPI. This commit fixes that
inconsistency.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-03 23:40:16 -08:00
Kevin Morris
522177e813
Merge branch 'fix-clean-auth-docs' into pu 2021-12-03 18:29:47 -08:00
Kevin Morris
aa717a4ef9
change(fastapi): no longer care about ResetKey collisions
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-03 17:59:02 -08:00