Support setting the timezone as well as the language via query params:
The timezone parameter previously only worked on certain pages.
While we're at it, let's also add the language as a param.
Refactor code for timezone and language functions.
Remove unused AURTZ cookie.
Signed-off-by: moson <moson@archlinux.org>
Users can (accidentally) override context vars with query params.
This may lead to issues when rendering templates (e.g. "comments=").
Signed-off-by: moson <moson@archlinux.org>
Avoid using special characters and use '<sup>' HTML tag instead.
To not rely on user's fonts Unicode coverage.
Closes: #490
Signed-off-by: Hanabishi <1722-hanabishi@users.noreply.gitlab.archlinux.org>
When setting up a context with user provided variables,
we should not override any existing values previously set.
Signed-off-by: moson <moson@archlinux.org>
Wrong config option was used to display the minimum length error msg.
(username_min_len instead of passwd_min_len)
Signed-off-by: moson <moson@archlinux.org>
Renaming of symbols. Functions, variables, values, DB values, etc.
Basically everything that is not user-facing.
This only covers "Trusted User" things:
tests, comments, etc. will covered in a following commit.
Dependencies might reside in the AUR or official repositories.
Add "AUR" as superscript letters to indicate if a package/provider
is present in the AUR.
Signed-off-by: moson <moson@archlinux.org>
It could happen that test data is already generated by a previous test.
(running in the same worker)
Make sure we clear everything before performing our checks.
Signed-off-by: moson <moson@archlinux.org>
All tests within a file run in the same worker and out test DB names
are unique per file as well. We don't really need a locking
mechanism here.
Same is valid for the test-emails. The only potential issue is that it
might try to create the same directory multiple times and thus run
into an error. However, that can be covered by specifying
"exist_ok=True" with os.makedirs such that those errors are ignored.
Signed-off-by: moson <moson@archlinux.org>
Also removed the logic for deploying to the long gone aur-dev box.
Ansible will be added in a upcoming commit for configurating and
deploying aurweb on the VM.
[1] https://docs.gitlab.com/ee/ci/review_apps/
We should check if a user (target) exists before validating permissions.
Otherwise things crash when a TU is trying to edit an account that
does not exist.
Fixes: aurweb-errors#529
Signed-off-by: moson <moson@archlinux.org>
Problem is that we join with PackageBase, thus we are missing
requests for packages that were deleted.
Fixes: #483
Signed-off-by: moson <moson@archlinux.org>
Allows us to set different cache eviction timespans for search queries
and statistics.
Stats and especially "last package updates" should probably be refreshed
more often, whereas we might want to cache search results for a bit
longer.
So this gives us a bit more flexibility playing around with different
settings and tweak things.
Signed-off-by: moson <moson@archlinux.org>
The new module/class helps us constructing queries and count records to
expose various statistics on the homepage. We also utilize for some new
prometheus metrics (package and user gauges).
Record counts are being cached with Redis.
Signed-off-by: moson <moson@archlinux.org>
We currently validate all commits going from latest -> oldest.
It would be nicer to go oldest -> latest so that, in case of errors,
we would indicate which commit "introduced" the problem.
Signed-off-by: moson <moson@archlinux.org>
The current query is a bit mixed up. The intention was to return the
number of unaccepted records. Now it does also count all records
that were accepted by some other user though.
Let's check the total number of terms vs. the number of accepted
records (by our user) instead.
Signed-off-by: moson <moson@archlinux.org>
The chance of finding multiple object IDs when performing lookups with
a shortened SHA1 hash (7 digits) seems to be quite high.
In those cases pygit2 will throw an error.
Let's catch those exceptions and gracefully handle them.
Fixes: aurweb-errors#496 (and alike)
Signed-off-by: moson <moson@archlinux.org>
Some fixes for the /rss endpoints
* Load all data in one go:
Previously data was lazy loaded thus it made several sub-queries per
package (> 200 queries for composing the rss data for a single request).
Now we are performing a single SQL query.
(request time improvement: 550ms -> 130ms)
This also fixes aurweb-errors#510 and alike
* Remove some "dead code":
The fields "source, author, link" were never included in the rss output
(wrong or insufficient data passed to the different entry.xyz functions)
Nobody seems to be missing them anyways, so let's remove em.
* Remove "Last-Modified" header:
Obsolete since nginx can/will only handle "If-Modified-Since" requests
in it's current configuration. All requests are passed to fastapi anyways.
Signed-off-by: moson <moson@archlinux.org>
In some translations we might be missing replacement placeholders (%).
This turns out to be problematic when calling the format function.
Wrap the jinja2 format function and just return the string unformatted
when % is missing.
Fixes: #341
Signed-off-by: moson <moson@archlinux.org>
Our set of keys returned by "util.parse_ssh_keys" is unordered so we
have to adapt our test to not rely on a specific order for multiple keys.
Fixes: 5ccfa7c0fd ("fix: same ssh key entered multiple times")
Signed-off-by: moson <moson@archlinux.org>
Users might accidentally past their ssh key multiple times
when they try to register or edit their account.
Convert our of list of keys to a set, removing any double keys.
Signed-off-by: moson <moson@archlinux.org>