+ Added SUPPORTED_LANGUAGES, a global constant dictionary of
language => display pairs for languages we support.
+ Add Translator.get_translator, a function used to retrieve a
translator after initializing it (if needed). Use `fallback=True`
while creating languages, in case we setup a language that we
don't have a translation for, it will noop the translation.
This is particularly useful for "en," since we do not translate
it, but doing this will allow us to go through our normal translation
flow in any case.
+ Added typing.
+ Added get_request_language, a function that grabs the language for
a request session, defaulting to aurweb.config [options] default_lang.
+ Added get_raw_translator_for_request, a function that retrieves
the concrete translation object for a given language.
+ Added tr, a jinja2 contextfilter that can be used to inline translate
strings in jinja2 templates.
+ Added `python-jinja` dep to .gitlab-ci.yml. This needs to be
included in documentation before this set is merged in.
+ Introduce pytest units (test_l10n.py) in `test` along with
__init__.py, which marks `test` as a test package.
+ Additionally, fix up notify.py to use the global translator. Also
reduce its source width to <= 80 by newlining some code.
+ Additionally, prepare locale in .gitlab-ci.yml and add
aurweb.config [options] localedir to config.dev with YOUR_AUR_ROOT
like others.
Signed-off-by: Kevin Morris <kevr@0cost.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Additionally, we now ask for two more favors from contributors:
1. All source modified or added within a patchset **must** maintain
equivalent or increased coverage by providing tests that use the
functionality.
2. Please keep your source within an 80 column width.
PS: Sneak a few test Makefile and gitlab fixes.
Signed-off-by: Kevin Morris <kevr@0cost.org>
Important note: Python tests will repeatedly clear out tables
that they test against; for this reason, one should always run
the shell tests first. The __init__.py file is necessary for
coverage to collect data from the tests being run.
At this point in FastAPI development, I'd like to encourage a
few things going forward:
1. Any time you contribute to the FastAPI codebase, you **must**
maintain equal or increased coverage on the overall source.
Developers are highly appreciated for adding tests in your
specific domain of addition or modification that may be missing
coverage. Our goal is 100% coverage, and all newly added files
**must** have 100% coverage through tests.
2. All source should be formatted with the autopep8 tool and
kept within an 80 column width, with the exception of HTML
templates.
Signed-off-by: Kevin Morris <kevr@0cost.org>
When using the sendmail() function with smtplib.SMTP or
smtplib.SMTP_SSL, the list of actual recipients for the email (to be
translated to RCPT commands) has to be provided as a parameter.
Update the notification script and add all Cc recipients to that
parameter.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This is the common convention for TAP, and makes harnesses like prove
automatically detect them. Plus, test suites don’t have to be shell
scripts anymore.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
The new schema was generated with sqlacodegen and then manually adjusted
to fit schema/aur-schema.sql faithfully, both in the organisation of the
code and in the SQL generated by SQLAlchemy.
Initializing the database now requires the new tool aurweb.initdb.
References to aur-schema.sql have been updated and the old schema
dropped.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
First, this gets rid of the deprecation warnings Python displayed.
Second, this fixes the case where a link contained a pair of
underscores, which used to be interpreted as an emphasis because the
linkify processor ran after the emphasis processor.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
When an FS#123 is part of a code block, it must not be converted into a
link. FS#123 may also appear inside an URL, in which case regular
linkifaction of URLs must take precedence.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Fixes a few edge cases:
- URLs within code blocks used to get redundant <> added, breaking bash
code snippets like `curl https://...` into `curl <https://...>`.
- Links written with markdown's <https://...> syntax also used to get an
extra pair of brackets.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since commit eeaa1c3 (Separate text from footer in notification emails,
2020-01-04), information about unsubscribing from notifications is added
in a signature block. Fix the test cases accordingly.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since commit a66c7fa (notify.py: Use a/an correctly when sending request
notifications, 2019-08-09), the body of notification emails sent when
filing orphan requests refers to "an orphan request" instead of "a
orphan request".
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Use disjoint sets of IDs for users, package bases, package comments and
package requests to ensure the notification script expects the
parameters in the same order we pass them.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since commit a7865ef (Make the locale directory configurable,
2018-07-22), we need to specify the locale directory in the
configuration file.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Mention both the package base name and the request type in the subject
of request closure notification.
Implements FS#41607.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Add support for translating notification emails and send localized
notifications, based on the user's language preferences. Also, update
the translations Makefile to add strings from the notification script
to the message catalog.
Implements FS#31850.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Add a script to periodically remove old IP addresses from the users
database.
The login IP addresses are stored for spam protection and to prevent
from abuse. It is quite unlikely that we ever need the IP address of a
user whose last login is more than a week old. It makes sense to remove
such IP addresses to protect our users' privacy.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
git/auth is run as an AutherizedKeysCommand which does not get the
environment variables passed to it, so AUR_OVERWRITE always got
hard-set to '0' by it. Instead we need to perform the actual privilege
check in git/update instead.
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since c5302d3 (Require TUs to explicitly request to overwrite a pkgbase,
2017-07-24), non-fast-forward pushes require setting the AUR_OVERWRITE
environment variable. Make sure that git-auth passes this variable to
git-serve when it should (and does not pass it if it shouldn't).
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since commit c5302d3 (Require TUs to explicitly request to overwrite a
pkgbase, 2017-07-24), non-fast-forward pushes are denied even for
Trusted Users, unless the AUR_OVERWRITE environment variable is set.
Mark the test case performing a non-fast-forward push from a TU
account as test_must_fail and add another test case performing the
same operation with AUR_OVERWRITE=1.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
In addition to the packages list and the package base list, also create
a list of registered user names.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since commit 09cb61a (schema: Remove invalid default values for TEXT
columns, 2017-04-15), the PackageRequests.Comments and
PackageRequests.ClosureComment fields no longer have a default value.
Initialize these fields explicitly whenever a new row is added to the
PackageRequests table.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Since commit 09cb61a (schema: Remove invalid default values for TEXT
columns, 2017-04-15), the PackageBases.FlaggerComment field no longer
has a default value. Initialize this field explicitly whenever a new row
is added to the PackageBases table.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
With the new Markdown support, text paragraphs are now properly
converted to HTML paragraphs, so we no longer need to keep line breaks.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Automatically detect Git commit identifiers, shorten them, and make them
link to the cgit interface.
Implements FS#43290.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Support Markdown syntax in package comments. Among other things, this
makes it easier to paste command line output and patches.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Instead of converting package comments from plain text to HTML code when
they are displayed, do the conversion when the comment is posted and
store the rendered result in the database. The conversion itself is done
by a Python script which uses Bleach for sanitizing the text.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Instead of making all tests fail, error out during initialization if the
SQLite schema has not been generated.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Allow for automatically converting the schema into a schema that works
with SQLite by running `make` from the schema/ subdirectory. Use the new
Makefile in the test suite.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Make sure that out-of-date notifications are sent to package base
maintainers as well as co-maintainers.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
The scripts were moved to aurweb/scripts/ in commit 3718860 (Make
maintenance scripts installable, 2016-10-17). Update the paths in the
test suite accordingly.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
When disowning a package base via the SSH interface, auto-accept all
pending orphan requests for the affected package.
Also, add a test case that checks whether (only) orphan requests
belonging to disowned packages are closed correctly.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>