prologin / concours-site

Source code of the Prologin contest website

Home Page:https://gitlab.com/prologin/concours/site

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  • Git
  • Python 3
  • NPM (for Javascript & CSS assets)
  • PostgreSQL
  • Redis (for training & contest)
  • texlive (for latexmk, pdflatex, and a few packages).

You can use the following commands to install those dependencies:

  • For Archlinux:

    sudo pacman -S --needed git python3 npm postgresql imagemagick redis \
                            texlive-core
    sudo systemctl enable --now redis
  • For Ubuntu and Debian ≥ 10 (buster):

    sudo apt install git python3 python3-venv npm postgresql imagemagick \
                     redis-server texlive
  • For Debian ≤ 9 (stretch)

    curl https://deb.nodesource.com/setup_8.x | sudo bash
    sudo apt install git python3 python3-venv nodejs postgresql imagemagick \
                     redis-server texlive

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:

  • for Ubuntu and Debian, the previous step (installation) should be enough.

  • for Archlinux, you have to initialize the database cluster and enable postgresql.service:

    sudo -u postgres initdb -D '/var/lib/postgres/data'
    sudo systemctl enable --now postgresql
  • for other platforms and more information, refer to the PostgreSQL installation documentation .

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:

  • create the semifinal settings (eg. prologin/settings/semifinal.py) using the following template:
    cp prologin/prologin/settings/{semifinal.sample,semifinal}.py
  • check that the settings match your database, edition, correctors etc.
  • do not create the minimal context;
  • don't forget to migrate the database for the next step;
  • import the user data you previously exported:
    # activate venv, export DJANGO_SETTINGS_MODULE
    ./prologin/manage.py semifinal_bootstrap export-semifinal-2016-center.json
  • during the initial setup, you may want to set DEBUG = True in the settings. Do not forget to set it to False during the contest.

Troubleshooting

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

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

About

Source code of the Prologin contest website

https://gitlab.com/prologin/concours/site

License:GNU General Public License v3.0


Languages

Language:Python 60.7%Language:HTML 30.4%Language:CSS 3.6%Language:TeX 2.9%Language:JavaScript 1.5%Language:Makefile 0.5%Language:Shell 0.4%Language:Dockerfile 0.0%