Skip to content

IPTnet/ipt_connect

Repository files navigation

ipt_connect

A python/django web-based interface to track the grades, compute the rankings and display a lot of interesting statistics on the International Physicists' Tournament.

For Contributor's Guide, see CONTRIBUTING.md.

Status

  • Code: working, v2.0, minor display bugs to fix
  • Documentation: work in progress
  • CI: None

readthedocs

How to use

With Docker

Development

This image runs standard Django web server.

Production without nginx

If you have any web server (for example nginx) on your machine you can use compose-without-nginx.yml. This image uses gunicorn as WSGI server and places ipt_connect.sock file into ipt_connect directory. Configure your web server to work with it. You can see configuration example for nginx here. Don't forget to review your project settings, see deployment checklist for more information.

Production with nginx

If you haven't any web server you can use compose-nginx.yml. This image runs ipt_connect with nginx and automatically installs Let's Encrypt certificate.

  • Open compose-nginx.yml and change things:
    • Set timezone to your local, for example TZ=UTC. For more timezone values check /usr/share/zoneinfo directory.
    • LE_EMAIL should be your email and LE_FQDN should be your site domain.
  • Replace www.example.com in service.conf by your domain.
  • Don't forget to review your project settings, see deployment checklist for more information.

Without Docker

Not recommended way!

  • Install the requirements pip install -r requirements.txt
  • Run python manage.py runserver
  • Open 127.0.0.1:8000/IPTdev/

F.A.Q:

How to sign in with the default superuser?

How to add superuser and sign in to site?

  • Run python manage.py createsuperuser
  • Set username, email address and password.
  • Run python manage.py runserver
  • Open 127.0.0.1:8000/admin/ and sign in.

How to switch between languages?

Сhange LANGUAGE_CODE values in this file to switch the language. Available values:

  • en-us
  • ru

I added new text to the template. How сan I update language files?

Run python manage.py makemessages -a -e=html -i=grappelli/*

How to compile language files?

Language files are compiled automatically when the server starts.

How to add a new language?

  • Run python manage.py makemessages -l de -e=html -i=grappelli/* where de is the locale name for the message file you want to create.
  • Translate all text in the file, which will be create.
  • Run application.

How to start a new tournament?

  • Run python manage.py flush
  • Sign in as superuser and add new participants, jury members and etc.

This command just deletes all the data of current tournament(s). If you want to start a new tournament in adition to existent, read below.

What if I have the list of participants somewhere else?

Then you can avoid inserting the participants and jurors by hand. Log in as superuser and navigate to http://127.0.0.1:8000/IPTdev/upload_csv/. Select a CSV file and click Upload. Note that the format of CSV file is hardcoded in views.py. Don't hesitate to adjust it for your needs!

How to add (clone) a tournament?

./clone-instance.sh IPTdev IPT2019 IPTdev is the name of existing instance. IPT2019 is the name of instance to be created.

Look to the commits being done to see the details.

There are three main parts of the new tournament:

  • IPT2019 folder with the code
  • Records in ipt_connect/urls.py and ipt_connect/settings.py
  • Tables in the database

If you are deploying an instance, which you created locally, to the remote server - then you have to do the required steps manually. Just create the instance locally and look at the commits which wil be created.

Notice: this clones only structure of the tournament, i.e. you have an empty table for teams, no registered jurors, etc.

How to see modifications in html code after a new commit?

Until the proper CI is set, we use this simple tool to check how changes in our python code affect the real generated HTML code.

Dumper - utility for collect all pages

  • Install the requirements pip install -r requirements.txt

  • To do dump:

    • Run python manage.py runserver
    • Run cd IPTdev/utils
    • Run python dumper.py Path to dump will be printed into the terminal
  • Compare dumps:

    • Using diff -bBwEZ ...
    • Using meld
    • Using your another favourite tool to find difference in HTML code :)

How to run tests?

  • Run python manage.py test

Note: as for now (17 Jul 2020), there are some errors related to grappelli and loginas. Just ignore them. However, there should be no errors related to ipt_connect itself.

Link checking

  • Run python manage.py test IPTdev.utils.link_parser

The Internet is constantly changing, new files and pages appear, and old ones are deleted. And links can change their address. Broken links can damage the site. An internal link may not work due to erroneous address or removed/non-existing page. Finally, no one is safe from errors of programmers or administrators. Each dead link causes negative reaction from users. This utility crawls all the mentioned links and returns the list of non-working ones.