Commit graph

2842 commits

Author SHA1 Message Date
Steven Guikal
db67e83bb8 fix(FastAPI): use elif statements where appropriate
Signed-off-by: Steven Guikal <void@fluix.one>
2021-10-18 15:07:25 -04:00
Kevin Morris
927f5e8567
feat(docker): add gunicorn support & production default
Supply FASTAPI_BACKEND=gunicorn and FASTAPI_WORKERS=<threads_num> to
docker-compose up to use the gunicorn backend.

This is defaulted in production to gunicorn, but FASTAPI_WORKERS
should definitely be configured by any production deployment.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 22:53:46 -07:00
Kevin Morris
28c4e9697b
change(fastapi): simplify model imports across code-base
Closes: #133

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 19:40:00 -07:00
Kevin Morris
bfdc85d7d6
change(rpc): use simplified models package
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 19:35:51 -07:00
Kevin Morris
6d59a97955
feat(fastapi): include all models in aurweb.models package
This gives developers the ability to import models without importing
them directly from their module:

    from aurweb.models import Ban, AccountType

This provides more conciseness:

    from aurweb import models

    def some_func(ban: models.Ban):
        pass

    def some_other_func(user: models.User):
        pass

This more aligns with a Django-style of core model bases.

NOTE: Docker images must be rebuilt with this change, as setup.cfg
has changed. Old Docker images will cause flake8 violation reports.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 19:35:20 -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
6ddf888b67
cleanup: remove int(...) casts on HTTPStatus usage
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 17:33:33 -07:00
Kevin Morris
56eefabc6d
change(fastapi): sanitize cascade backref strings
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 16:24:05 -07:00
Kevin Morris
51320ab22a
change(fastapi): unify all model relationship behavior
Now, we allow the direct relationships and their foreign keys to
be set in all of our models. Previously, we constrained this to
direct relationships, and this forced users to perform a query
in most situations to satisfy that requirement. Now, IDs can be
passed directly.

Additionally, this change removes the need for extraneous imports
when users which to use relationships. We now import and use models
directly instead of passing string-references to them.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 16:24:00 -07:00
Kevin Morris
0c37216626
change(gitignore): add various exclusions
Three new root directories are ignored by git:

- /personal/
    - Personal tools excluded by git.
- /notes/
    - Personal notes excluded by git.
- /vendor/
    - PHP Composer vendor directory. We don't want to commit this
      to git.

And one specific root file:

- /taskell.md
    - Data file for the `taskell` program, used for task tracking.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 15:08:42 -07:00
Kevin Morris
7b7e571e93
change(FastAPI): run test_initdb.py ahead of time in docker
In some cases, when tests fail through Docker, the database
ends up in an invalid state. This causes subsequent runs to
error out with non-sensical DB errors. The `test_initdb.py`
test suite runs tests which setup every modifiable table
in the database, so let's just run it first here to avoid
any invalid test DB state.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 20:16:38 -07:00
Kevin Morris
50634d30b3
Merge branch 'pu_package_keywords_fix' into pu 2021-10-15 20:08:31 -07:00
Kevin Morris
27a6563302
fix(FastAPI): use CRED_PKGBASE_SET_KEYWORDS credential properly
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 19:11:15 -07:00
Kevin Morris
8040ef5a9c
fix(FastAPI): use pkgbase in package actions
Previously, `result` was being used which was directly set to
`pkgbase` before rendering the actions.html partial. It didn't
make much sense. This commit cleans things up a bit.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 19:02:53 -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
81c9312606
add Bug.md GitLab issue template
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 14:08:27 -07:00
Kevin Morris
dd420f8c41
add Feature.md GitLab issue template
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 14:08:17 -07:00
Kevin Morris
b631dcb756
Merge branch 'pu_pkgbase_flag_fix' into pu 2021-10-15 13:50:56 -07:00
Kevin Morris
748faca87d
fix(FastAPI): translate some untranslated strings
Affects: templates/partials/packages/search_actions.html

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-12 18:04:07 -07:00
Kevin Morris
4525a11d92
fix(FastAPI): change a deep copy instead of original
This was updating offsets and causing unintended behavior.
We should be a bit more functional anyway.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-10 01:00:36 -07:00
Kevin Morris
27fbda5e7b
feat(FastAPI): add get_(errors|successes) testing HTML helpers
These functions will allow us to more easily check errors or success
messages when testing routes.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-09 22:04:48 -07:00
Kevin Morris
34c96ed81b
add Feedback.md GitLab issue template
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-09 20:50:41 -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
72d6016da4
Merge branch 'pu_popupdate' into pu 2021-10-08 15:42:50 -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
27c5d17fc8
Merge branch 'fix-email-input' into pu 2021-10-07 23:32:27 -07:00
Kevin Morris
4b95ec41ed
Merge branch 'fix-merge-type' into pu 2021-10-07 23:21:28 -07:00
Kevin Morris
01fb42c5d9
fix(scripts.popupdate): use forced-utc timestamp
Additionally, clean up some controversial PEP-8 warnings by
removing the '+' string concatenation.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 22:46:07 -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
4e7d2295da
fix(FastAPI): add package-related missing backref cascades
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 20:25:24 -07:00
Kevin Morris
0ddc969bdc
feat(FastAPI-dev): add package_delete helper
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 20:25:23 -07:00
Kevin Morris
ed68fa2b57
feat(FastAPI): add aurweb.db.delete_all(iterable)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 20:25:23 -07:00
Kevin Morris
c8d01cc5e8
feat(FastAPI): add aurweb.util.apply_all(iterable, fn)
A helper which allows us to apply a specific function to each
item in an iterable.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 20:25:20 -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
55ebfa0d01
Merge branch 'pu_auth_redirect_vars' into pu 2021-10-07 12:42:53 -07:00
Kevin Morris
2e6f8cb9f4
change(FastAPI): @auth_required login kwarg defaulted to True
We pretty much want @auth_required to send users to login
if we enforce auth requirements but don't otherwise specify
a way to deal with it.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 12:38:34 -07:00
Kevin Morris
a756691d08
change(FastAPI): user_developer_or_trusted_user always True
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 10:00:46 -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
75c49e4f8a
feat(FastAPI): support {named} fmt in auth_required redirect
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-07 00:27:47 -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
33b18907eb
feat(FastAPI): add CRED_PKGBASE_MERGE
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-06 22:30:15 -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
a54a09f61d fix(FastAPI): fix padding on email inputs
Signed-off-by: Steven Guikal <void@fluix.one>
2021-10-05 17:50:22 -04:00
Steven Guikal
1bce53bbb7 fix(FastAPI): mark user and passwd as required fields 2021-10-05 14:36:46 -04:00