prologin / concours-site

Source code of the Prologin contest website
https://gitlab.com/prologin/concours/site
GNU General Public License v3.0
10 stars 6 forks source link

Prologin website

This repository contains the source of the website of Prologin: https://prologin.org.

Prologin is a computer science contest in France open to all students under 20, introducing students to the world of programming and algorithms with exciting challenges.

Table of Contents

License

This software is licensed under the GNU General Public License v3.0 or any later version.

Copyright © Association Prologin.

Installation

Requirements

Running the Prologin website requires the following dependencies:

You can use the following commands to install those dependencies:

PostgreSQL Setup

You need to have access to a running PostgreSQL instance to setup the Prologin database. If you don't have that already, this section contains information to setup PostgreSQL for the first time:

Once PostgreSQL is running, you also need an user that will have access to the Prologin database. The easiest way to achieve that is simply to create an account that has the same name as your username and that can create databases:

sudo -u postgres createuser --createdb $USER

Cloning

Clone the website and the other Prologin repositories needed for the different modules of the website:

git clone git@gitlab.com:prologin/concours/site.git
git clone git@gitlab.com:prologin/concours/problems.git # Training exercises (private)
git clone git@gitlab.com:prologin/concours/archives.git # Edition archives (private)
git clone git@gitlab.com:prologin/asso/documents.git    # Admin. documents (private)

Then, enter the website directory:

cd site

Python virtualenv & dependencies

Use a virtual environment to install the Python dependencies of the website:

python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt

Web dependencies

Download the web dependencies from NPM:

( cd assets && npm install )

Configuration

Copy the sample configuration to a file of your choice. I recommend to use dev.py for a development environment:

cp prologin/prologin/settings/{conf.sample,dev}.py

The default settings should work by default if you are following this guide, but if needed, you can edit prologin/prologin/settings/dev.py to adjust some settings.

Creating the database

Create the prologin PostgreSQL database, and run the migrations :

createdb prologin
./prologin/manage.py migrate

Creating the minimal context

(Note: If you would rather work with an anonymized database dump of the website, ask one of the Prologin roots to provide you one.)

The website has to display some data about the current Prologin edition, upcoming events, and the like. That is why it is necessary to setup at least one Edition and the corresponding qualification (a.ka. QCM) Event. As the website crashes intentionally without theses minimal objects, you can not add them using the admin. Use the edition command instead:

./prologin/manage.py edition create
# Answer the questions

Creating a super user

This step is not required but in case you want to access the admin interface, you can create a super user:

./prologin/manage.py createsuperuser
# Answer the questions

Hacking on the website

Every time you need to work on the website:

  1. Enter the virtualenv:
    source .venv/bin/activate
  2. Launch the local dev server:
    make runserver
  3. If needed, you can launch a debug SMTP server to check that mails are correctly sent with the right content. This will print the outbound mails on the console.
    make smtpserver
  4. If needed (mailing, training & contest submissions), you can launch a debug celery worker:
    make celeryworker

Translations

The website user-facing strings are internationalized through Django's internal i18n framework.

You can translate the strings locally by editing the .po files in your editor or using a dedicated software such as poedit.

To ease the community translation process, it is possible to upload the untranslated (English) strings to Transifex, ask people to translate them (eg. using the Transifex web app) and download them back to the repository. To that end, use the provided make commands:

# I've created/update source (English) strings, let's push them
# (we pull before to update local strings just in case)
make tx-pull tx-push
# ... translate on Transifex ...
# Get back the translated strings
make tx-pull
# Commit
git commit prologin/locale -m 'locale: update for <feature>'

Deploying the regional event environment

Exporting user data from production website

Go to https://prologin.org/docs/ and use the “Data export” orange button to obtain a JSON file you have to copy to the machine hosting the regional event website.

Installing the regional event website

Follow the generic installation procedure, with the following differences:

Troubleshooting

On macOS, error: "ImportError: MagickWand shared library not found.".

You can refer to this StackOverflow answer to fix the problem.