暂无描述

Denis Merigoux 8a6406c5b4 Merge pull request #14 from denismerigoux/multi-seum 5 年之前
bot abe85fa2af Allow multiple seums in one call in Telegram bot 5 年之前
counter 0290e21bdd Add regex constraint on trigram field 5 年之前
locale 0290e21bdd Add regex constraint on trigram field 5 年之前
seum 9094c8513c Modified default settings 8 年之前
static 8acb360d3a Permissions and updated database fetch script 8 年之前
.gitignore 0290e21bdd Add regex constraint on trigram field 5 年之前
LICENSE.txt 8acb360d3a Permissions and updated database fetch script 8 年之前
README.md 312545a7b7 Inactive users queries 8 年之前
deploy.sh 30f2e2e91e Small CSS modification for seum counters 8 年之前
fecthLatestDB.sh 8acb360d3a Permissions and updated database fetch script 8 年之前
manage.py 8fc3c05f22 First model for seum counter 9 年之前
requirements.txt 431ec42fa8 Add the Telegram SeumBookBot! 8 年之前

README.md

seum-counter

Installation

Clone the repo, then create a virtualenv with Python 3, then install the required packages with :

pip install -r requirements.txt

Then copy and paste the settings file template located in folder seum:

cd seum && cp settings.py.default settings.py

In order to use correctly the internationalisation, compile the locale files:

python manage.py compilemessages

To update the locale file for the project, use

django-admin makemessages -l fr --ignore=env

where env is the name of the folder containing your virtualenv.

Running the server

Developement

First, comment out the lines below "#Production settings" in seum/settings.py.

You will also need to apply the unapplied migrations:

python manage.py migrate

Then simply use the django command:

python manage.py runserver 0.0.0.0:8000

If you want to use the Django Debug Toolbar, follow the instructions from the https://django-debug-toolbar.readthedocs.io/en/1.6/installation.html.
You just have to edit your settings.py file.

Production

Install the packages needed to run an Apache server with wsgi_mod :

sudo apt-get install apache2 libapache2-mod-wsgi-py3

Then add the following content to the file /etc/apache2/sites-available/000-default.conf, inside the <VirtualHost> tag :

Alias /static <path-to-project-folder>/static
<Directory <path-to-project-folder>/static>
     Require all granted
</Directory>

<Directory <path-to-project-folder>/seum>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess seum python-path=<path-to-project-folder>:<path-to-project-folder>/<name-of-virtualenv>/lib/python3.5/site-packages
WSGIProcessGroup seum
WSGIScriptAlias / <path-to-project-folder>/seum/wsgi.py

To give Apache the permission to serve the files, execute these three commands :

chmod 664 <path-to-project-folder>/db.sqlite3
sudo chown :www-data <path-to-project-folder>/db.sqlite3
sudo chown :www-data <path-to-project-folder>

To launch or restart the server, simply run :

sudo service apache2 restart

Backup data

To backup the database, execute the command

python manage.py dumpdata --exclude contenttypes > seum.json

You can then restore your data into a freshly migrated new database with

python manage.py loaddata seum.json

Helpful commands

Inactive users

To track down inactive users, launch python manage.py shell and type

no_reset = Counter.objects.annotate(num_resets=Count('resets__counter')).filter(num_resets=0)
no_like = Counter.objects.annotate(num_likes=Count('likes')).filter(num_likes=0)
[ (u.user.email, u.trigramme) for u in (no_rest & no-like)]