Commit graph

67 commits

Author SHA1 Message Date
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
4b95ec41ed
Merge branch 'fix-merge-type' into pu 2021-10-07 23:21:28 -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
dc11a88ed3
change(FastAPI): depend on auth_required redirect for pkgbase actions
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 00:40:22 -07:00
Kevin Morris
8bc1fab74d
change(FastAPI): automate request login requirement
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 00:27:51 -07:00
Kevin Morris
889c5b1e21
fix(FastAPI): pkgbase actions template
Display Delete, Merge and Disown actions based on user credentials.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-06 22:09:58 -07:00
Steven Guikal
1bce53bbb7 fix(FastAPI): mark user and passwd as required fields 2021-10-05 14:36:46 -04:00
Steven Guikal
1956be0f46 fix(FastAPI): prefill login fields with entered data 2021-10-05 14:13:48 -04:00
Steven Guikal
f392b3607e fix(FastAPI): add missing translation filter for request type
Signed-off-by: Steven Guikal <void@fluix.one>
2021-10-04 17:42:55 -04:00
Steven Guikal
9af76a73a3 fix(FastAPI): include MergeBaseName in merge request type
This was done on the dedicated requests page, but missed on the
dashboard.

Signed-off-by: Steven Guikal <void@fluix.one>
2021-10-04 17:36:10 -04: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
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
c164abe256
feat(FastAPI): add Requests navigation item
Along with this, created a new test suite at test/test_html.py,
which has the responsibility of testing various HTML things
that are not suitable for another test suite.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:43:01 -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
0895dd07ee
feat(FastAPI): add /pkgbase/{name}/comments/{id}/pin (post)
In addition, fix up some templates to display pinned comments,
and include the unpin form input for pinned comments, which is
not yet implemented.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 16:59:38 -07:00
Kevin Morris
59d04d6e0c
fix(FastAPI): comment.html template rendering
Deleters and edits were not previously taken into account.
This fix addresses that issue using User.has_credential.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 16:59:21 -07:00
Kevin Morris
fc28aad245
feat(FastAPI): add pkgbase comments (new, edit)
In PHP, this was implemented using an /rpc type 'get-comment-form'.
With FastAPI, we've decided to reorganize this into a non-RPC route:
`/pkgbase/{name}/comments/{id}/form`, rendered via the new
`templates/partials/packages/comment_form.html` template.

When the comment_form.html template is provided a `comment` object,
it will produce an edit comment form. Otherwise, it will produce a new
comment form.

A few new FastAPI routes have been introduced:

- GET `/pkgbase/{name}/comments/{id}/form`
    - Produces a JSON response based on {"form": "<form_markup>"}.
- POST `/pkgbase/{name}/comments'
    - Creates a new comment.
- POST `/pkgbase/{name}/comments/{id}`
    - Edits an existing comment.

In addition, some Javascript has been modified for our new routes.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 16:59:10 -07:00
Kevin Morris
5e95cfbc8a
fix(FastAPI): get_pkgbase -> get_pkg_or_base
`get_pkgbase` has been replaced with `get_pkg_or_base`, which is
quite similar, but it does take a new `cls` keyword argument which
is to be the model class which we search for via its `Name` column.

Additionally, this change fixes a bug in the `/packages/{name}` route
by supplying the Package object in question to the context and modifying
the template to use it instead of a hacky through-base workaround.

Examples:

    pkgbase = get_pkg_or_base("some_pkgbase_name", PackageBase)
    pkg = get_pkg_or_base("some_package_name", Package)

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 16:59:09 -07:00
Kevin Morris
fbd91f346a
feat(FastAPI): add /pkgbase/{name}/voters (get)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 12:28:32 -07:00
Kevin Morris
5cf7062092
feat(FastAPI): add /packages (get) search
In terms of performance, most queries on this page win over
PHP in query times, with the exception of sorting by Voted or
Notify (https://gitlab.archlinux.org/archlinux/aurweb/-/issues/102).
Otherwise, there are a few modifications: described below.

* Pagination
    * The `paginate` Python module has been used in the FastAPI
      project
      here to implement paging on the packages search page. This
      changes how pagination is displayed, however it serves the
      same purpose. We'll take advantage of this module in other
      places as well.
* Form action
    * The form action for actions now use `POST /packages` to
      perform. This is currently implemented and will be
      addressed in a follow-up commit.
* Input names and values
    * Input names and values have been modified to satisfy the
      snake_case naming convention we'd like to use as much as
      possible.
    * Some input names and values were modified to comply with
      FastAPI Forms: (IDs[<id>]) -> (IDs, <id>).

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-19 12:44:19 -07:00
Kevin Morris
6298b1228a
feat(FastAPI): add templates/partials/widgets/pager.html
A pager that can be used for paginated result tables.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-19 12:44:19 -07:00
Kevin Morris
4de18d8134
fix(FastAPI): voted/notified query efficiency
Previously, we were running a single ORM query for every single package
to check for its voted or notified states. Now, we perform a single
ORM query for each of the set of voted or notified packages in
relation with the request user.

This improves performance drastically at the expense of some
manual code additions and set-dependency; i.e. we add a bit
more complexity and roundabout way of getting our data.

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

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-19 00:34:08 -07:00
Kevin Morris
ab8a44cede
fix(FastAPI): only show comments partial if they exist
This was incorrectly displaying a comment section header
when no comments existed.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-12 00:47:34 -07:00
Kevin Morris
ad3016ef4f
fix: /account/{name}/edit Account Type selection
The "Account Type" selection was not properly being rendered
due to an incorrect equality. This has been fixed in
templates/partials/account_form.html.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-08 17:36:37 -07:00
Kevin Morris
210e459ba9
Eradicate the dedupe_qs filter
The new `extend_query` and `urlencode` filters are way cleaner ways
to achieve what we did with `dedupe_qs`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-31 14:44:29 -07:00
Kevin Morris
49cc12f99d
jinja2: rename filter 'urlencode' to 'quote_plus'
urlencode does more than just a quote_plus. Using urlencode
was not sensible, so this commit addresses that.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-31 13:28:54 -07:00
Kevin Morris
55c29c4519
partials/packages/details.html: Add package request count
This was missed during the original implementation merge.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-30 18:58:03 -07:00
Kevin Morris
1c26ce52a5
[FastAPI] include DepArch in dependency list
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-30 18:48:53 -07:00
Kevin Morris
a72ab61902
[FastAPI] fix dashboard template
Some columns should only be shown when a user is authenticated.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-25 16:57:19 -07:00
Kevin Morris
5a175bd92a
routers.html: add authenticated dashboard to homepage
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-17 21:59:13 -07:00
Kevin Morris
469c141f6b [FastAPI] bugfix: remove use of scalar() in plural context
Anything where we can have more than one of something, scalar()
cannot be used.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-17 20:59:38 -07:00
Kevin Morris
d9cdd5faef
[FastAPI] Modularize homepage and add side panel
This puts one more toward completion of the homepage
overall; we'll need to still implement the authenticated
user dashboard after this.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-17 19:58:32 -07:00
Kevin Morris
4ade8b0539 routers.packages: Simplify some existence checks
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-09 23:42:54 -07:00
Kevin Morris
04d1c81d3d bugfix: fix extra dependency annotations
These were being displayed regardless of the dep type
and state of DepDesc. This is fixed with this commit.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-27 22:05:42 -07:00
Kevin Morris
88569b6d09 add /pkgbase/{name} route
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-27 20:48:40 -07:00
Kevin Morris
ae3d302c47 implement /packages/{name} as its own route
A few things added with this commit:

- aurweb.packages.util
    - A module providing package and pkgbase helpers.
- aurweb.template.register_filter
    - A decorator that can be used to register a filter:
      @register_filter("some_filter") def f(): pass

Additionally, template partials have been split off a bit
differently. Changes:

- /packages/{name} is defined in packages/show.html.
- partials/packages/package_actions.html is now
  partials/packages/actions.html.
- partials/packages/details.html has been added.
- partials/packages/comments.html has been added.
- partials/packages/comment.html has been added.
- models.dependency_type additions: name and id constants.
- models.relation_type additions: name and id constants.
- models.official_provider additions: base official url constant.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-27 20:48:40 -07:00
Kevin Morris
2d3d03e01e templates: Translate pkgbase.html and partials
+ Include the `is_maintainer` context key.
+ Use `is_maintainer` in more locations.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-27 20:48:40 -07:00
Leonidas Spyropoulos
1e1c0c3fe5 [FastAPI] Basic pkgbase template
Co-author: Kevin Morris <kevr@0cost.org>

Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-27 20:48:40 -07:00
Kevin Morris
ae953ce19b Merge branch 'pu_accounts' into pu 2021-07-13 21:57:06 -07:00
Kevin Morris
021a1c8fb6 add /accounts/ (get, post) routes
Slight markup changes, same style overall and same
form parameters as the PHP implementation.

In addition, we've disabled the "left" and "right"
navigation buttons when we're at the border of the
table.

CSS Changes:

- Added similar styling to submit `<buttons>` that submit `<input>` had.
- Added .results tr td[align="{left,right}"] styling to align
  the result table's `More -->` button to the right of the table.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-01 11:08:56 -07:00
Kevin Morris
450469e3d6 add /addvote/ (get, post) routes
Another part of the "Trusted User" collection of routes.
This allows a Trusted User to create a proposal.

New Routes:

- get `/addvote/`
- post `/addvote/`

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-01 11:08:44 -07:00
Kevin Morris
3a74f76ff9 FastAPI: use internal typeahead and remove jquery
Awesome!

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 22:56:48 -07:00
Kevin Morris
a26e703343 bugfix: use empty string if backup_email is None
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-28 04:04:52 -07:00
Kevin Morris
987f825714 Merge branch 'account_form' into pu 2021-06-27 09:09:42 -07:00
Jelle van der Waa
222d995e95
Use backup_email field for backup email
The context gives backup_email and not backup for the backup email
field.

Fixes: #91
2021-06-27 17:29:44 +02:00
Jelle van der Waa
b2491ddc07
Use type=email for email fields
Setting the input type gives the use a hint that the field should be an
email and also shows an error when a non-email is filled into the email
field.
2021-06-27 17:25:46 +02:00
Jelle van der Waa
12911a101e
Port homepage intro to fastapi
Port the main home page content to fastapi.
2021-06-27 15:17:04 +02:00