Skip to content

Commit

Permalink
Merge pull request #26 from zhabinka/patch-07-19
Browse files Browse the repository at this point in the history
update
  • Loading branch information
astynax authored Jul 23, 2022
2 parents 2ada9f2 + 7bd2ab6 commit 55f112b
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 369 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ __pycache__/
/db.sqlite3
media/
*.egg-info/
.env
.DS_Store
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This project is a software that I'am developing during [this series of YouTube s
1. Clone.
1. `poetry install`.
1. `poetry run python manage.py migrate`.
1. `poetry run python manage.py createsuperuser --name=admin` and set password to `admin` (TODO: make the password optional).
1. `poetry run python manage.py createsuperuser --username=admin` and set password to `admin` (TODO: make the password optional).
1. `poetry run python manage.py runserver`.

### DB Example

You can copy `example/db.sqlite3` file to the project's root and possibly run some migrations (`manage.py mugrate`). Then you'll be able to play example game. It is pretty incomplete but it shows most of engine features.
You can copy `example/db.sqlite3` file to the project's root and possibly run some migrations (`manage.py migrate`). Then you'll be able to play example game. It is pretty incomplete but it shows most of engine features.
3 changes: 2 additions & 1 deletion djaif/middleware.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from django.contrib.auth import authenticate, login
from djaif.settings import SUPERUSER, PASSWORD


def auto_login(get_response):
def middleware(request): # noqa: WPS430

if not request.user.is_authenticated:
user = authenticate( # noqa: S106
username='admin', password='admin',
username=SUPERUSER, password=PASSWORD,
)
login(request, user)

Expand Down
23 changes: 8 additions & 15 deletions djaif/settings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
"""
Django settings for djaif project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
import os
from dotenv import load_dotenv

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os
load_dotenv()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -19,11 +11,12 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'wpw=^28n)_)+ho#&z$5u12z50ny$3f%+8ld#)q2^a+87e_$o1o'
DJANGO_SETTINGS_MODULE = 'djaif.settings'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
SECRET_KEY = os.getenv('SECRET_KEY')
DEBUG = bool(os.getenv('DEBUG'))
SUPERUSER = os.getenv('SUPERUSER', 'admin')
PASSWORD = os.getenv('PASSWORD', 'admin')

ALLOWED_HOSTS = []

Expand Down
Binary file modified example/db.sqlite3
Binary file not shown.
Loading

0 comments on commit 55f112b

Please sign in to comment.