Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
4dfdc644ea | |||
769b80f812 | |||
acc58c0a2b | |||
e4e83a188c | |||
55b50f302c | |||
df5b99ed56 | |||
e043067b39 | |||
f58c238ef6 | |||
64eb0eb64e | |||
bb736468db | |||
|
46fc815479 | ||
a2968f3e47 | |||
2d6574807f | |||
|
9f2ef3c556 | ||
|
600c23c9a4 | ||
|
b4319bba5f | ||
|
56143c3436 | ||
|
80445ef2c2 | ||
|
b4d28a6f97 | ||
351ec5a090 | |||
d976d6b653 | |||
0239368e69 | |||
fcf37fe0b3 | |||
94cc7787c9 | |||
34a4a0b9aa | |||
4e66551ac9 | |||
506d97ba5a | |||
40aa6efdcf | |||
303027434d | |||
d13bd0adb6 | |||
3c1397a348 |
200
INSTALL.md
Normal file
200
INSTALL.md
Normal file
@@ -0,0 +1,200 @@
|
||||
# Preparing
|
||||
|
||||
- [ ] Install and configure Mailsystem (postfix) so it is possible to send mails
|
||||
- [ ] Install python ```apt install python3 python3-pip python3-venv python3-virtualenv```
|
||||
- [ ] Install uwsgi ```apt install uwsgi uwsgi-plugin-python3```
|
||||
- [ ] Install and configure mariadb-server ```mysql_secure_installation```
|
||||
- [ ] Install and configure nginx und let's encrypt or similar
|
||||
- [ ] Install git ```apt install git```
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
- [ ] Create databases for carom and carom-int
|
||||
|
||||
```
|
||||
-- carom
|
||||
CREATE DATABASE carom DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
|
||||
CREATE USER 'carom'@'localhost' IDENTIFIED BY 'xxx';
|
||||
GRANT ALL PRIVILEGES ON carom.* TO 'carom'@'localhost';
|
||||
CREATE DATABASE `carom-int` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
|
||||
CREATE USER 'carom-int'@'localhost' IDENTIFIED BY 'xxx';
|
||||
GRANT ALL PRIVILEGES ON `carom-int`.* TO 'carom-int'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
Passphrases should be replaced by useful characters
|
||||
|
||||
- [ ] Create systemd unit file for uwsgi (/etc/systemd/system/uwsgi.service):
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=uWSGI Emperor service
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown www-data:www-data /run/uwsgi'
|
||||
ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/apps-enabled
|
||||
Restart=always
|
||||
KillSignal=SIGQUIT
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
- [ ] Reread systemd configs for uwsgi
|
||||
|
||||
```
|
||||
systemctl daemon-reload
|
||||
systemctl enable uwsgi.service
|
||||
systemctl restart uwsgi.service
|
||||
```
|
||||
|
||||
- [ ] Checkout carom
|
||||
|
||||
```
|
||||
cd /srv
|
||||
git clone http://git.einsle.de/carom/carom-server.git carom
|
||||
git clone http://git.einsle.de/carom/carom-server.git carom-int
|
||||
cd carom-int
|
||||
git checkout develop
|
||||
git pull
|
||||
cd ..
|
||||
```
|
||||
|
||||
- [ ] Install pipenv
|
||||
|
||||
```
|
||||
pip3 install –upgrade pipenv
|
||||
```
|
||||
|
||||
- [ ] Install mysqlclient
|
||||
|
||||
```
|
||||
apt install libmariadbclient-dev
|
||||
```
|
||||
|
||||
In environments carom run
|
||||
|
||||
```
|
||||
pipenv install mysqlclient
|
||||
```
|
||||
|
||||
```
|
||||
git checkout -- Pipfile Pipfile.lock
|
||||
git status
|
||||
```
|
||||
|
||||
- [ ] Create caromserver/local_settings.py for both environments:
|
||||
|
||||
```
|
||||
cd caromserver
|
||||
cp local_settings_example.py local_settings.py
|
||||
vi local_settings.py
|
||||
ALLOWED_HOSTS, ADMINS, DEBUG should be filled
|
||||
SECRET_KEY use pwgen 50 1 to create content for
|
||||
DATABASES settings
|
||||
cd ..
|
||||
mkdir .venv
|
||||
pipenv install
|
||||
pipenv run python manage.py migrate
|
||||
pipenv run python manage.py collectstatic
|
||||
```
|
||||
|
||||
Do it for /srv/carom and /srv/carom-int
|
||||
|
||||
- [ ] Create Superuser Accounts using:
|
||||
|
||||
```
|
||||
pipenv run python manage.py createsuperuser
|
||||
```
|
||||
|
||||
- [ ] Create config File for uwsgi/carom
|
||||
|
||||
```
|
||||
# carom...ini file
|
||||
[uwsgi]
|
||||
plugin = python3
|
||||
chdir = /srv/carom/
|
||||
module = caromserver.wsgi:application
|
||||
home = /srv/carom/.venv/
|
||||
master = true
|
||||
processes = 5
|
||||
vacuum = true
|
||||
uid = www-data
|
||||
gid = www-data
|
||||
workers = 2
|
||||
socket = /run/uwsgi/carom.socket
|
||||
chmod-socket = 660
|
||||
log-date = true
|
||||
```
|
||||
|
||||
Create it for /etc/uwsgi/apps-available/carom.ini and carom-int.ini and link it
|
||||
to /etc/uwsgi/apps-enabled/
|
||||
|
||||
```
|
||||
systemctl restart uwsgi.service
|
||||
```
|
||||
|
||||
Show at syslog for errors and fix it.
|
||||
|
||||
- [ ] Create Config File for nginx/carom
|
||||
|
||||
```
|
||||
upstream socket_carom {
|
||||
server unix:///run/uwsgi/carom.socket;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name carom...;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
server_name carom...;
|
||||
ssl_certificate /etc/ssl/certs/xxx;
|
||||
ssl_certificate_key /etc/ssl/private/xxx;
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
charset utf-8;
|
||||
client_max_body_size 75M; # adjust to taste
|
||||
location /media {
|
||||
alias /srv/carom/media;
|
||||
}
|
||||
location /static {
|
||||
alias /srv/carom/staticfiles;
|
||||
}
|
||||
location / {
|
||||
uwsgi_pass socket_carom;
|
||||
include /etc/nginx/uwsgi_params;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Create it for /etc/ngin/sites-available/carom... and carom-int... and link it
|
||||
to /etc/ngin/sites-enabled/
|
||||
|
||||
Path to certificates must be modified.
|
||||
|
||||
```
|
||||
systemctl restart nginx
|
||||
```
|
||||
|
||||
- [ ] Create update.sh in carom and carom-int root dir
|
||||
|
||||
```
|
||||
pushd /srv/carom/
|
||||
git pull
|
||||
pipenv update
|
||||
pipenv run python manage.py migrate
|
||||
pipenv run python manage.py collectstatic --noinput
|
||||
touch /etc/uwsgi/apps-enabled/carom.ini
|
||||
popd
|
||||
```
|
||||
|
||||
Path to uwsgi config file (in apps-enabled) musst be matching.
|
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, date
|
||||
|
||||
from django import template
|
||||
from django.db.models import Sum
|
||||
@@ -10,8 +10,14 @@ register = template.Library()
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
def display_daily_sale(location):
|
||||
start_date = datetime.now().replace(hour=5, minute=0, second=0, microsecond=0)
|
||||
end_date = start_date + timedelta(days=1)
|
||||
date = datetime.now().replace(hour=6, minute=0, second=0, microsecond=0)
|
||||
now = datetime.now()
|
||||
if now < date:
|
||||
start_date = date - timedelta(days=1)
|
||||
end_date = date
|
||||
else:
|
||||
start_date = date
|
||||
end_date = date + timedelta(days=1)
|
||||
prize__sum = Accounting.objects.filter(desk__client__location=location,
|
||||
time_to__range=(start_date, end_date)).aggregate(Sum('prize'))
|
||||
if prize__sum['prize__sum'] is None:
|
||||
|
@@ -163,7 +163,7 @@ EMAIL_PORT = 25
|
||||
URL_LOCATION_PROCESSOR = 'http://127.0.0.1:8000/billard/process_locationdata'
|
||||
|
||||
PRODUCT_INFO = 'CAROM-DEV'
|
||||
PRODUCT_VERSION = 'v 1.0.0'
|
||||
PRODUCT_VERSION = 'v 1.0.1'
|
||||
|
||||
INTERNAL_IPS = ['127.0.0.1']
|
||||
|
||||
|
BIN
static/img/billiard.ico
Normal file
BIN
static/img/billiard.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
@@ -8,6 +8,7 @@
|
||||
<meta name="description" content="carom billard management">
|
||||
<meta name="author" content="Robert Einsle <robert@einsle.de>">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{% static 'img/billiard.ico' %}">
|
||||
{% block header %}
|
||||
{% endblock %}
|
||||
<!-- Bootstrap -->
|
||||
|
Reference in New Issue
Block a user