Commit graph

2971 commits

Author SHA1 Message Date
Kevin Morris
ae953ce19b Merge branch 'pu_accounts' into pu 2021-07-13 21:57:06 -07:00
Kevin Morris
77d54b5e1b Merge branch 'pu_tu_addvote' into pu 2021-07-13 21:16:41 -07:00
Kevin Morris
e0ee881b67 Docker: fix mariadb-entrypoint user host
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-10 15:05:09 -07:00
Kevin Morris
c54000045c add [pycodestyle] config to setup.cfg
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-10 15:03:07 -07:00
Kevin Morris
7542798335 .gitignore: add more user configs and Python build files
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-10 14:57:19 -07:00
Kevin Morris
80ce10eb0f add /pyrightconfig.json to .gitignore
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-02 11:29:00 -07:00
Kevin Morris
eec09dec3e [FastAPI] add /rss and /rss/modified
There are slight differences in that, with `python-feedgen`,
an empty description field completely omits the description,
but includes the description when there is one.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-01 11:09:09 -07:00
Kevin Morris
8d6e782ba1 add python-feedgen dependency
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-01 11:09:09 -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
bdc913d088 Merge branch 'master' into pu 2021-06-29 23:02:39 -07:00
Kevin Morris
96bc86d153 Merge branch 'typeahead' 2021-06-29 23:02:15 -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
2835dd89ea Merge branch 'typeahead' into pu_typeahead 2021-06-29 22:31:18 -07:00
Kevin Morris
427a30ef8a Docker: Remove deprecated links
In addition, remove some unneeded dependencies on tests.
Though, in the future we _should_ craft tests that use these.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:53:23 -07:00
Kevin Morris
3f60f5048e Docker: add scripts/setup-sqlite.sh
This script purely removes any existing sqlite and is
used before tests are run. This causes the test flow
to run `aurweb.initdb` again (if ever).

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:53:23 -07:00
Kevin Morris
f4406ccf5c Docker: Centralize repo dependencies
Now, we have `docker/scripts/install-deps.sh`, a script used
by both Docker and .gitlab-ci.yml. We can now focus on changing
deps in this script along as well as documentation going forward.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:53:18 -07:00
Kevin Morris
6c7bb04b93 Docker: Improve mariadb init
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:49:57 -07:00
Kevin Morris
4442ba6703 bugfix: return null if config key doesn't exist
This was previously causing a PHP warning due to returning
a missing key.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 10:48:45 -07:00
Kevin Morris
a120af5a00 Docker: remove asset forward to index.php
This makes logging look a little better for development purposes.
Now, `docker-compose logs php-fpm` will only show details about PHP
accesses, while `docker-compose logs nginx` will show accesses
regarding PHP assets.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 10:30:26 -07:00
Kevin Morris
3bacfe6cd9 Docker: increase nginx and php-fpm logging
Log toward stdout/stderr which is accessible via
`docker-compose logs <service>`.

Examples:

- `docker-compose logs nginx`
- `docker-compose logs php-fpm`

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 10:29:24 -07:00
Kevin Morris
af96be7d09 Docker: move nginx config to its own file
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 10:27:45 -07:00
Kevin Morris
2a47aa09cd Merge branch 'pu_php_extra_2' into pu 2021-06-29 10:15:21 -07:00
Leonidas Spyropoulos
c3a29171cd [php] aurweb.spawn avoid permission denied when running as user
Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
2021-06-29 18:02:20 +01:00
Leonidas Spyropoulos
2f5d9c63c4 [php] Support DB mysql backend with port instead of socket
Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
2021-06-29 17:59:46 +01:00
Kevin Morris
dbbafc15fa bugfix: PackageKeyword should have two PKs
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-28 12:44:55 -07:00
Kevin Morris
719fa82ae5 Merge branch 'pu_package' into pu 2021-06-28 09:56:05 -07:00
Kevin Morris
7d695f0c6a Update .gitignore
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-28 09:53:05 -07:00
Kevin Morris
f8d2d4c82a PackageBase.package -> PackageBase.packages
A PackageBase can have more than one package
associated with it.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-28 08:31:13 -07:00
Kevin Morris
3c6b2203e9 Docker: bugfix: /usr/local/bin instead of /aurweb/app/bin
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-28 05:36:12 -07:00
Kevin Morris
28300ee889 bugfix: populate context on invalid password (account edit)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-28 04:12:29 -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
Kevin Morris
acc100eb52 Docker: Fix installation, remove pip, simplify sshd
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-27 06:37:06 -07: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
Kevin Morris
0a3aa40f20 Docker: Fix git sshd
This was completely bugged out. This commit fixes git, provides
two separate cgit servers for the different URL bases and also
supplies a smartgit service for $AURWEB_URL/repo.git interaction.

Docker image needs to be rebuilt with this change:

    $ docker build -t aurweb:latest .

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-27 05:16:12 -07:00
Kevin Morris
83f93c8dbb aurweb.routers.accounts: strip host out of ssh pubkeys
We must store the paired key, otherwise aurweb-git-auth
will fail.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-27 03:54:13 -07:00
Kevin Morris
97c1247b57 /tu/{proposal_id}: Do not show voters if there are none
This was different than PHP.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 04:43:00 -07:00
Kevin Morris
04ab98907a aurweb.asgi: patch invalid f-string
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 04:20:55 -07:00
Kevin Morris
bfffdd4d91 aurweb.asgi: Allow unsafe-inline style-src in CSP
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 04:13:28 -07:00
Kevin Morris
85ba4a33a8 add /tu/{proposal_id} (get, post) routes
This commit ports the `/tu/?id={proposal_id}` PHP routes to
FastAPI into two individual GET and POST routes.

With this port of the single proposal view and POST logic,
several things have changed.

- The only parameter used is now `decision`, which
  must contain `Yes`, `No`, or `Abstain` as a string.
  When an invalid value is given, a BAD_REQUEST response
  is returned in plaintext: Invalid 'decision' value.
- The `doVote` parameter has been removed.
- The details section has been rearranged into a set
  of divs with specific classes that can be used for
  testing. CSS has been added to persist the layout with
  the element changes.
- Several errors that can be discovered in the POST path
  now trigger their own non-200 HTTPStatus codes.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:11:52 -07:00
Kevin Morris
83c038a42a add TUVoteInfo.total_votes()
Returns the sum of TUVoteInfo.Yes, TUVoteInfo.No and
TUVoteInfo.Abstain.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:11:52 -07:00
Kevin Morris
ac1779b705 add util.number_format -> number_format Jinja2 filter
Implement a `number_format` equivalent to PHP's version.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:11:52 -07:00
Kevin Morris
dc4cc9b604 add aurweb.asgi.id_redirect_middleware
A new middleware which redirects requests going to '/route?id=some_id'
to '/route/some_id'. In the FastAPI application, we'll prefer using
restful layouts where possible where resource-based ids are
parameters of the request uri: '/route/{resource_id}'.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:11:52 -07:00
Kevin Morris
e534704a98 [FastAPI] remove unused Requests navbar item
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:10:20 -07:00
Kevin Morris
d674aaf736 add /tu/ (get) index
This commit implements the '/tu' Trusted User index page.

In addition to this functionality, this commit introduces
the following jinja2 filters:

- dt: util.timestamp_to_datetime
- as_timezone: util.as_timezone
- dedupe_qs: util.dedupe_qs
- urlencode: urllib.parse.quote_plus

There's also a new decorator that can be used to enforce
permissions: `account_type_required`. If a user does not
meet account type requirements, they are redirected to '/'.

```
@auth_required(True)
@account_type_required({"Trusted User"})
async def some_route(request: fastapi.Request):
    return Response("You are a Trusted User!")
```

Routes added:

- `GET /tu`: aurweb.routers.trusted_user.trusted_user

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:03:27 -07:00
Kevin Morris
a6bba601a9 add util.get_vote -> get_vote Jinja2 filter
This filter gets a vote of a request's user toward a voteinfo.

Example: {% set vote = (voteinfo | get_vote(request)) %}

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:03:27 -07:00
Kevin Morris
d606ebc0f1 add User.is_trusted_user() and User.is_developer()
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:03:27 -07:00