`damned-lies` is a **translation-tracking Web application** originally aimed to help the GNOME Translation project. It is written in Python based on the [Django](https://www.djangoproject.com) framework.
`damned-lies` is a **translation-tracking Web application** originally aimed to help the GNOME Translation project. It
is written in Python and is based on the [Django](https://www.djangoproject.com) framework.
You can find the Data model in the `/docs` directory.
## Requirements
## Contribute and install
To run properly, `damned-lies` requires at least **Python 3.6** and **Django 3**.
Python dependencies are listed in the `requirements.txt` file alongside this README document. In order to install them, you will need to have the following dependencies installed:
Then, define `USE_DEBUG_TOOLBAR` to `True` in `damnedlies/local_settings.py` to use it.
## Installation
Once Python dependencies are installed, you will need some further steps in order to have a working environment.
1. Create a `damnedlies/local_settings.py` and overwrite settings to match your requirements and your configuration layouts. Typical settings to customize include: `DATABASES`, `SECRET_KEY`, `DEBUG`, `STATIC_SERVE`, `ADMINS`, `ADMIN_GROUP`, `SITE_DOMAIN`, `SCRATCHDIR`, and various `EMAIL` settings.
Please refer to Database configuration below for more information.
`SCRATCHDIR` should point to an existing directory, writable by the web application user.
Create the `MEDIA_ROOT` directory, and the `upload` and `upload-backup` directories inside it, also writable by the web application user.
Note also that if you don’t want to really send mail when testing the app, you can set the `EMAIL_BACKEND` setting as follows to redirect mail to the console:
2. Run the following command to execute the database migrations:
```bash
./manage.py migrate
```
3. In production, you will have to run the following command:
```bash
./manage.py collectstatic
```
Then configure your Web server to statically serve this directory. For example, with the HTTPd server (*aka* Apache HTTP Server), a simple alias directive is enough:
```apacheconf
Alias /static /absolute/path/to/djamnedlies/static
```
4.**Optionally**, if you want to populate the database with sample data, run:
```bash
./manage.py loaddata sample_data
```
5. You should now be able to launch the development server to check if all is running well:
```bash
./manage.py runserver
```
6. Configure Sites in admin interface (“View on site” link, site address in sent mail).
## Running tests
To execute the tests, run this command:
```bash
python manage.py test[optional path to run partial tests]
```
Read [the Django testing documentation](https://docs.djangoproject.com/en/stable/topics/testing/) for more details about testing in Django projects.
<!-- This should be moved to a documentation instead of remaining in the README file -->
## Maintenance tasks
There is a management command to run maintenance tasks (clean never-activated accounts, inactivate unused roles, …):
```bash
./manage.py run-maintenance
```
Note: it might be useful to add the command in a cron schedule.
<!-- This should be moved to a documentation instead of remaining in the README file -->
## Databases
It’s important to use the Unix Domain Socket connection to obtain good performances.
### PostgreSQL
In the `DATABASES['default']` dictionary, you just need to define `ENGINE = 'django.db.backends.postgresql_psycopg2'` and the `NAME` key.
Leave the `HOST` setting empty to use `UDS`.
In the `DATABASES['default']` dictionary, you just need to define `ENGINE = 'django.db.backends.postgresql'`
and the `NAME` key. Leave the `HOST` setting empty to use `UDS`.
### MySQL
Create a database in UTF8, either with `default-character-set = utf8` under `[mysqld]` section in the `my.cnf` file or with an explicit SQL instruction:
Create a database in UTF8, either with `default-character-set = utf8` under `[mysqld]` section in the `my.cnf` file or
with an explicit SQL instruction:
```sql
CREATEDATABASE<DATABASE_NAME>charset=utf8;
CREATE
DATABASE<DATABASE_NAME>charset=utf8;
```
Then, you have to update your `damnedlies/local_settings.py`:
```python
DATABASES={
'default'{
'default':{
'ENGINE':'django.db.backends.mysql',
'NAME':'<your database name>',
'USER':'<your user>',
'PASSWORD':'<your password>',
'HOST'='/var/run/mysqld/mysqld.sock',
'OPTIONS'={
'HOST':'/var/run/mysqld/mysqld.sock',
'OPTIONS':{
'read_default_file':'/etc/mysql/my.cnf',
}
}
}
```
Grep for `ANSI_QUOTES` in the source code to find the `models.py` which use a hack to workaround the double quotes interpretation in MySQL. The best solution is to run the MySQL server with the [`ANSI_QUOTES` mode](http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html)(`sql-mode="ANSI_QUOTES"` in `my.cnf`), but it can be damaging for other applications.
## Translations
To be able to also extract strings from various database fields, a wrapper script has been created around the standard Django `makemessages` command. The script also copy po files in `/po` directory.
Run `python manage.py update-trans` to update translations when there are string changes.
After translation files in po directory have been updated, there is another script to put back po files in `locale/<ll>/LC_MESSAGES/django.po` and call Django’s compile_messages command.
Run `python manage.py compile-trans`.
Grep for `ANSI_QUOTES` in the source code to find the `models.py` which use a hack to workaround the double quotes
interpretation in MySQL. The best solution is to run the MySQL server with
the [`ANSI_QUOTES` mode](http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html)(`sql-mode="ANSI_QUOTES"` in `my.cnf`),