Web library on django. You can upload and download media files (videos, books, webinars...), rate them and much more!
- Support for Docker compose deployment.
- Automatic creation of SSL certificates.
- Automatic renewal of SSL certificates.
- Automatic rejection of unknown domains (using nginx).
- Static and media files support (media files are stored in s3 storage (yandex cloud by default)).
- Automatic launch of django inside entrypoint. Executed commands:
- collectstatic
- migrate
- createcachetable
- clear_cache (custom command, removing all cache)
- compilemessages
- test
- sendtestemail
- gunicorn
- Full translation into 2 languages.
- Autotest system (by github actions).
- Big amount of tests (121+).
- Caching using redis.
- Registration with confirmation by email.
- User roles system (4 roles with different permissions).
- Moderation system.
- Configured administration system.
- Configured logs system.
- Django email reports support.
- Error codes system.
- Star rating.
- Django Debug Toolbar.
git clone https://github.com/LaGGgggg/SkyLibrary.git
cd SkyLibrary
With pipenv:
pip install --user pipenv
pipenv shell # create and activate
python -m venv .venv # create
.venv\Scripts\activate.bat # activate
With pip:
pip install -r requirements.txt
cd SkyLibrary
To create your postgresql database you need:
- Install this
- Open pgadmin
- Create a new one or use the default database
Create file .env
in SkyLibrary/app_main
, such it SkyLibrary/app_main/.env
. Next, paste it in .env
(this is a configuration for development, not for production!):
SECRET_KEY=<your secret key>
DEBUG=True
DB_URL=postgres://<username>:<password>@localhost:5432/<database_name>
ALLOWED_HOSTS=* # In case of 2 or more, divide with ", "
INTERNAL_IPS=127.0.0.1 # In case of 2 or more, divide with ", "
CSRF_TRUSTED_ORIGINS=http://* # In case of 2 or more, divide with ", "
ADMINS=Name:[email protected] # In case of 2 or more, divide with ", "
USE_CACHE=False
CACHE_LOCAL=True
CACHE_LOCATION_DB_TABLE_NAME=cache
CACHE_REDIS_LOCATIONS=
EMAIL_HOST_USER=<your email adress>
EMAIL_HOST_PASSWORD=<your email password>
MEDIA_STORAGE_BUCKET_NAME=<your media storage bucket name>
AWS_ACCESS_KEY_ID=<your bucket access key id>
AWS_SECRET_ACCESS_KEY=<your bucket secret access key>
FILE_UPLOAD_MAX_SIZE=3221225472 # 3221225472 = 1024 * 1024 * 1024 * 3 = 3 * 1024Mb = 3072Mb (Mb value must be integer, not 7.5Mb)
COVER_UPLOAD_MAX_SIZE=7340032 # 7340032 = 1024 * 1024 * 7 = 7Mb (Mb value must be integer, not 7.5Mb)
FILE_UPLOAD_CHUNK_SIZE=1073741824 # 1073741824 = 1024 * 1024 * 1024 = 1024Mb = 1Gb (value in bytes must be integer)
LANGUAGE_CODE=en-us
Do not forget to set the DB_URL variable!
SECRET_KEY - standard django secret key.
DEBUG - standard django debug.
DB_URL - argument for dj_database_url.config(default=).
ALLOWED_HOSTS - standard django allowed hosts.
INTERNAL_IPS - standard django internal ips.
CSRF_TRUSTED_ORIGINS - standard django csrf trusted origins.
ADMINS - standard django admins.
USE_CACHE - if False, set django DummyCache = no caching.
CACHE_LOCAL - if True, set django DatabaseCache, else django RedisCache.
CACHE_LOCATION_DB_TABLE_NAME - standard django DatabaseCache location.
CACHE_REDIS_LOCATIONS - standard django RedisCache location,
can be empty if you are not using Redis caching, can take more than one location, separated by " ,"
(for example: "first_location, second_location, third_location").
Warning! The project uses yandex smtp as email host variable.
EMAIL_HOST_USER - standard django email host user.
EMAIL_HOST_PASSWORD - standard django email host password.
Warning! The project uses yandexcloud for s3 storage (implemented using django-storages and boto3).
MEDIA_STORAGE_BUCKET_NAME - standard S3Boto3Storage bucket_name.
AWS_ACCESS_KEY_ID - standard AWS_ACCESS_KEY_ID.
AWS_SECRET_ACCESS_KEY - standard AWS_SECRET_ACCESS_KEY.
Warning! If you want to change the values of the maximum upload size, change it also in nginx configuration file (change the value of client_max_body_size).
FILE_UPLOAD_MAX_SIZE - a maximum size of an upload file in megabytes converted to bytes (the megabytes value must be an integer).
COVER_UPLOAD_MAX_SIZE - a maximum size of an upload file in megabytes converted to bytes (the megabytes value must be an integer).
FILE_UPLOAD_CHUNK_SIZE - part size for uploading a file on the s3 server using multipart upload (the bytes value must be an integer).
LANGUAGE_CODE - standard django language code.
python manage.py migrate
python manage.py createcachetable
python manage.py collectstatic
python manage.py runserver
1. Install git
2. Install docker
3. Install docker compose plugin
git clone https://github.com/LaGGgggg/SkyLibrary.git
cd SkyLibrary
Create file .env
in SkyLibrary/app_main
, such it SkyLibrary/app_main/.env
. Next, paste it in .env
(this is a configuration for development, not for production!):
# django section
SECRET_KEY=<your secret key>
DEBUG=True
DB_URL=postgres://<username>:<password>@postgres:5432/<database_name>
ALLOWED_HOSTS=* # In case of 2 or more, divide with ", "
INTERNAL_IPS=127.0.0.1 # In case of 2 or more, divide with ", "
CSRF_TRUSTED_ORIGINS=<your csrf trusted origins> # In case of 2 or more, divide with ", "
ADMINS=Name:[email protected] # In case of 2 or more, divide with ", "
USE_CACHE=False
CACHE_LOCAL=True
CACHE_LOCATION_DB_TABLE_NAME=cache
CACHE_REDIS_LOCATIONS=
EMAIL_HOST_USER=<your email adress>
EMAIL_HOST_PASSWORD=<your email password>
MEDIA_STORAGE_BUCKET_NAME=<your media storage bucket name>
AWS_ACCESS_KEY_ID=<your bucket access key id>
AWS_SECRET_ACCESS_KEY=<your bucket secret access key>
FILE_UPLOAD_MAX_SIZE=3221225472 # 3221225472 = 1024 * 1024 * 1024 * 3 = 3 * 1024Mb = 3072Mb (Mb value must be integer, not 7.5Mb)
COVER_UPLOAD_MAX_SIZE=7340032 # 7340032 = 1024 * 1024 * 7 = 7Mb (Mb value must be integer, not 7.5Mb)
FILE_UPLOAD_CHUNK_SIZE=1073741824 # 1073741824 = 1024 * 1024 * 1024 = 1024Mb = 1Gb (value in bytes must be integer)
LANGUAGE_CODE=en-us
# docker-compose section
POSTGRES_USER=<username>
POSTGRES_PASSWORD=<password>
POSTGRES_DB=<database_name>
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
PGDATA=/var/lib/postgresql/data/pgdata
Do not forget to set the DB_URL variable! (For use with docker-compose host must be the name of the service!)
SECRET_KEY - standard django secret key.
DEBUG - standard django debug.
DB_URL - argument for dj_database_url.config(default=).
ALLOWED_HOSTS - standard django allowed hosts.
INTERNAL_IPS - standard django internal ips.
CSRF_TRUSTED_ORIGINS - standard django csrf trusted origins.
ADMINS - standard django admins.
USE_CACHE - if False, set django DummyCache = no caching.
CACHE_LOCAL - if True, set django DatabaseCache, else django RedisCache.
CACHE_LOCATION_DB_TABLE_NAME - standard django DatabaseCache location.
CACHE_REDIS_LOCATIONS - standard django RedisCache location,
can be empty if you are not using Redis caching, can take more than one location, separated by " ,"
(for example: "first_location, second_location, third_location").
Warning! The project uses yandex smtp as email host variable.
EMAIL_HOST_USER - standard django email host user.
EMAIL_HOST_PASSWORD - standard django email host password.
Warning! The project uses yandexcloud for s3 storage (implemented using django-storages and boto3).
MEDIA_STORAGE_BUCKET_NAME - standard S3Boto3Storage bucket_name.
AWS_ACCESS_KEY_ID - standard AWS_ACCESS_KEY_ID.
AWS_SECRET_ACCESS_KEY - standard AWS_SECRET_ACCESS_KEY.
Warning! If you want to change the values of the maximum upload size, change it also in nginx configuration file (change the value of client_max_body_size).
FILE_UPLOAD_MAX_SIZE - a maximum size of an upload file in megabytes converted to bytes (the megabytes value must be an integer).
COVER_UPLOAD_MAX_SIZE - a maximum size of an upload file in megabytes converted to bytes (the megabytes value must be an integer).
FILE_UPLOAD_CHUNK_SIZE - part size for uploading a file on the s3 server using multipart upload (the bytes value must be an integer).
LANGUAGE_CODE - standard django language code.
POSTGRES_USER - standard POSTGRES_USER environment variable.
POSTGRES_PASSWORD - standard POSTGRES_PASSWORD environment variable.
POSTGRES_DB - standard POSTGRES_DB environment variable.
POSTGRES_HOST - standard POSTGRES_HOST environment variable.
POSTGRES_PORT - standard POSTGRES_PORT environment variable.
PGDATA - standard PGDATA environment variable.
Configure it (nginx/nginx.conf):
ssl_certificate /etc/letsencrypt/live/<domain.site>/fullchain.pem; # 11 line
ssl_certificate_key /etc/letsencrypt/live/<domain.site>/privkey.pem; # 12 line
server_name www.<domain.site> <domain.site>; # 23 line
server_name www.<domain.site> <domain.site>; # 39 line
ssl_certificate /etc/letsencrypt/live/<domain.site>/fullchain.pem; # 44 line
ssl_certificate_key /etc/letsencrypt/live/<domain.site>/privkey.pem; # 45 line
Configure it (3-5 lines in docker-compose-init.sh file):
domains=() # example: (domain.site www.domain.site)
email="" # example: "[email protected]"
staging=0 # 1 - staging on, 0 - off
chmod +x docker-compose-init.sh
sudo ./docker-compose-init.sh
docker compose logs -f
- visitor (default user role, site visitor)
- moderator (has access to the moderator page)
- tasks
- Moderate new inactive media (on the "moderator" page)
- tasks
- administrator (has access to the administration panel (not all permissions))
- tasks
- Report processing (ban comment or media if necessary)
- Managing moderator accounts (create, edit, block)
- Managing media tags (create, edit, delete)
- Managing report types (create, edit, delete)
- permissions (set manual by a superuser)
- accounts_app | user | Can add a new moderator
- accounts_app | user | Can add user
- accounts_app | user | Can change a moderator data
- accounts_app | user | Can change user
- accounts_app | user | Can change the user active field
- media_app | comment | Can change comment
- media_app | comment | Can change the content of the comment to "This comment was banned"
- media_app | media | Can change media
- media_app | media | Can change the value of the media active field
- media_app | media tag | Can add media tags
- media_app | media tag | Can change media tags
- media_app | media tag | Can delete media tags
- media_app | media tag | Can view media tags
- media_app | report | Can delete report
- media_app | report | Can view report
- media_app | report type | Can add report type
- media_app | report type | Can change report type
- media_app | report type | Can delete report type
- media_app | report type | Can view report type
- staff_app | moderator task | Can delete moderator task
- staff_app | moderator task | Can view moderator task
- tasks
- superuser (django vanilla superuser)
- Home page
- Navigation bar
- User is authenticated
- Link to the "profile" page
- Link to the "add new media" page
- User is moderator
- Link to the "moderator" page
- User is not authenticated
- Link to the "login" page
- Link to the "registration" page
- User is authenticated
- Media filters (you can filter media by title, author, user who added, tags, rating issue procedure, rating maximum and minimum values. Returns links to media with star ratings and tags)
- Navigation bar
- Login page
- Navigation bar
- Link to the "home" page
- Login form (with support for field errors)
- username field
- password field
- Link to the "password reset" page
- Navigation bar
- Password reset page
- Navigation bar
- Link to the "home" page
- Password reset form (with support for field errors)
- email field
- Navigation bar
- Register page
- Navigation bar
- Link to the "home" page
- Registration form (with support for field errors. Registration created partially with django-registration)
- username field
- email field
- password field
- confirm password field
- Navigation bar
- View media page
- Navigation bar
- Link to the "home" page
- User is authenticated
- Link to the "profile" page
- Link to the "add new media" page
- User is moderator
- Link to the "moderator" page
- Media title
- Media star rating
- Media tags
- Media description
- Media cover (if exists)
- Download media file button (with a download counter. The user must be authenticated)
- Report media button (receives report media form (with support for field errors), after confirming create media report. The user must be authenticated)
- Media author
- Media user who added username
- Media publication date
- Create media comment form (with support for field errors. The user must be authenticated)
- Media comments
- Comment data
- user who added username
- publication date
- comment content
- comment rating
- comment upvote and downvote buttons (the user must be authenticated)
- reply button (receives create comment reply form (with support for field errors), after confirming create comment reply. The user must be authenticated)
- report button (receives report comment form (with support for field errors), after confirming create comment report. The user must be authenticated)
- pin button (adds a link to the comment (by url fragment))
- Comment data
- The user is the moderator and the media is the moderator's task (in this case, the user cannot add comments, reports and comment ratings)
- Validate media form
- Approve/disapprove radio buttons
- Auto new task/no auto new task radio buttons (if the value is set to "auto new task", a new moderator task is automatically created after media validation)
- Validate media form
- Navigation bar
- Profile page
- Navigation bar
- Link to the "home" page
- Link to the "add new media" page
- Link to the "change password" page
- Link to the "logout" page
- User is moderator
- Link to the "moderator" page
- My medias (a list of media added by the user, with media statuses, star ratings, tags and links to the "change media" pages (for each active media))
- My downloads (a list of media downloaded by the user, with media tags and star ratings (user ratings, not average across all user ratings, the user can add a new rating to the media by clicking on the star))
- Navigation bar
- Change password page
- Navigation bar
- Link to the "home" page
- Link to the "profile" page
- Change password form (with support for field errors)
- old password field
- new password field
- confirm new password field
- Navigation bar
- Add new media page
- Navigation bar
- Link to the "home" page
- Link to the "profile" page
- Add new media form (with support for field errors)
- title field
- description field
- author field
- tags field (checkboxes)
- file field
- cover field (optional)
- Navigation bar
- Change media page
- Navigation bar
- Link to the "home" page
- Link to the "profile" page
- Change media form (with support for field errors)
- title field
- description field
- author field
- tags field (checkboxes)
- file field
- cover field (optional)
- Navigation bar
- Logout page
- Error pages
- 400 (with the link to the "home" page)
- 403 (with the link to the "home" page)
- 404 (with the link to the "home" page)
- 500 (with the link to the "home" page)
- Moderator page
- Navigation bar
- Link to the "home" page
- Link to the "profile" page
- Get task button or link to the moderator task
- Navigation bar
For any questions:
[email protected]