Convenient interaction with homework for your school
- Unix system
- Python 3.10+
- Docker && Docker-compose
- PostgreSQL (rec: 16)
git clone https://github.com/TabarakoAkula/ChtoZadano.git
cd ChtoZadano
Fill in the data in .env.template
file
Rename file to .env
:
mv .env.template .env
Change {site_name}
to IP-address or domain of your site
docker compose up --build
- Unix | Windows system
- Python 3.10+
- PostgreSQL (rec: 16)
git clone https://github.com/TabarakoAkula/ChtoZadano.git
cd ChtoZadano
Windows:
python -m venv venv
venv\Scripts\activate
Linux:
python -m venv venv
venv/bin/activate
Production:
pip install -r requirements/prod.txt
Development:
pip install -r requirements/dev.txt
Fill in the data in .env.template
file
Rename file to .env
:
mv .env.template .env
cd chtozadano
python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic
python manage.py runserver
python telegram_bot
-
make docker-bash-web
-
cd chtozadano && python3 manage.py createsuperuser
-
cd chtozadano
-
python manage.py createsuperuser
The site allows you to work with database through its admin panel. To enter it, you need to:
- Create superuser
- Go to the address
/admin/
and enter superuser data
- Go to
/user/account/
, pressАдмин панель
and enter superuser data
If you want to upload another data about teachers/subjects/group - change data in this files:
LANGUAGE_CODE
:str
- Select language code for your site server (Internationalization is under development, see #119)TIME_ZONE
:str
- Select in which timezone will be working server (USE_TZ
must be enabled)USE_TZ
:bool
- Use timezone time instead of server time (BE CAREFUL It can ruin adding rows to db)DATA_UPLOAD_MAX_MEMORY_SIZE
:int
- Choose maximum data size to upload to site per request (Change this value innginx.conf
too)FILE_UPLOAD_MAX_MEMORY_SIZE
:int
- Choose file data size to upload to site per request (Change this value innginx.conf
too)
workers
:int
- set number of workers that will serve your site (formula: (2 * number_of_cors) + 1loglevel
:str
set loglevel for gunicorn (Saving in ``chtozadano/logs/gunicorn_access.log|gunicorn_errors.log)
/chtozadano/static_dev/json/subjects.json
/chtozadano/static_dev/json/grades_subjects.json
/chtozadano/static_dev/json/eng_teachers.json
/chtozadano/users/models.py
:
GRADE_CHOICES
LETTER_CHOICES
/chtozadano/homework/models.py
:
GRADE_CHOICES
LETTER_CHOICES
/chtozadano/homework/forms.py
:
GROUP_CHOICES
/chtozadano/templates/users/sign_in.html
line 15
- href to bot
/chtozadano/templates/users/sign_up.html
line 16
- href to bot
{site_name}
- IP address or domain name to be redirected (+ Redirecting from http to https)client_max_body_size
- Choose maximum data size to upload to server per request
You can fast upload your schedule using script in /chtozadano/scripts/add_schedule_script.py
Fill file /chtozadano/scripts/timetable.csv
according to the template:
grade
(f.e.10А
)- lessons in format
weekday
_lesson
, where 0 - Monday (f.e.1_2
=Thuesday_Second lesson
) - Determine the maximum number of lessons and specify it for each day of the week!
If the maximum number of lessons is 4, then the headers will look like this:
grades;0_1;0_2;0_3;0_4;1_1;1_2;1_3;1_4....
There are come required fields:
- Request url -
DOMAIN_URL
(.env
file) - Superuser id -
SUPERUSER_ID
(.env
file) - Api key -
API_KEY
(.env
file)
If you want you can change:
- Filename -
FILENAME
(script
file) - CSV delimiter -
DELIMITER
(script
file) - CSV encoding format -
ENCONDING
(script
file)
- Go to
/chtozadano/scripts
directory - Launch
script
filepython add_schedule_script.py
Project allows ability to log data into files and console.
console
logstelegram bots
- some functions (ex.DeleteOldHomework
) will notify superusers using messages from the botchtozadano/logs/django.log
chtozadano/logs/gunicorn_access.log
chtozadano/logs/gunicorn_errors.log
console
logs
Some scripts which can make your experience easier
make script_name
Scripts:
update
- git pull + restart docker a daemon
docker-rebuildup
- docker stop + build + up as daemon
docker-bash-web
- open bash in
web
container
- open bash in
docker-psql
- open psql in
db
container as userposgresql
- open psql in
docker-clean-all
- prune all containers
docker-clean-old
- prune
non-active
containers
- prune
sort-req
- sort all requirements in
requirements/
:)
- sort all requirements in
In .env
file you can see SITE_TECHNICAL_WORKS
and API_TECHNICAL_WORK
values
If True
- site will be available only for superusers. Other users will see templates/technical_works.html
at any page
If True
- site API will be blocked -> bot will stop working & custom API requests will be unavailable
AChtoZadano
allows to use caching using Redis as well as scheduling tasks using Celery (Celery worker and Celery beat).
The support is already initially enabled in docker containers, but if you want to configure it,
you should change the following parameters:
USE_REDIS
:bool
- Toggle using RedisREDIS_SITE_URL
:str
- URL to Redis database for Site cacheREDIS_BOT_URL
:str
- URL to Redis database for Bot cacheUSE_CELERY
:bool
- Toggle using Celery(USE_REDIS
must beTrue
)CELERY_BROKER_URL
:str
- URL to Redis database for Celery tasks
timezone
: str - select timezone where will work your Celery scheduler (ex.app.conf.timezone = "Europe/Moscow"
)