This commit is contained in:
Niko Abeler 2023-06-11 21:25:30 +02:00
parent 10d81cb447
commit 30b00b35e4
17 changed files with 330 additions and 145 deletions

7
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"python.formatting.provider": "none",
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
}

View File

@ -2,5 +2,5 @@ from django.apps import AppConfig
class GuildConfig(AppConfig): class GuildConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField' default_auto_field = "django.db.models.BigAutoField"
name = 'guild' name = "guild"

View File

@ -1,17 +1,12 @@
from django import forms from django import forms
from guild.models import PlaySession from guild.models import PlaySession
class PlaySessionForm(forms.ModelForm): class PlaySessionForm(forms.ModelForm):
class Meta: class Meta:
model = PlaySession model = PlaySession
fields = ["date", "characters", "summary"] fields = ["date", "characters", "summary"]
# set date wideget to type="date" # set date wideget to type="date"
widgets = { widgets = {
"date": forms.DateInput(attrs={"type": "date"}), "date": forms.DateInput(attrs={"type": "date"}),
} }

View File

@ -5,70 +5,124 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = []
]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Adventure', name="Adventure",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('name', models.CharField(max_length=255)), "id",
('description', models.TextField()), models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
("description", models.TextField()),
], ],
options={ options={
'verbose_name': 'Adventure', "verbose_name": "Adventure",
'verbose_name_plural': 'Adventures', "verbose_name_plural": "Adventures",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Character', name="Character",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('name', models.CharField(max_length=255)), "id",
('description', models.TextField()), models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
("description", models.TextField()),
], ],
options={ options={
'verbose_name': 'character', "verbose_name": "character",
'verbose_name_plural': 'characters', "verbose_name_plural": "characters",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Player', name="Player",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('name', models.CharField(max_length=255)), "id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
], ],
options={ options={
'verbose_name': 'player', "verbose_name": "player",
'verbose_name_plural': 'players', "verbose_name_plural": "players",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='PlaySession', name="PlaySession",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('date', models.DateField()), "id",
('summary', models.TextField()), models.BigAutoField(
('adventure', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='guild.adventure', verbose_name='adventure')), auto_created=True,
('characters', models.ManyToManyField(to='guild.character', verbose_name='characters')), primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("date", models.DateField()),
("summary", models.TextField()),
(
"adventure",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="guild.adventure",
verbose_name="adventure",
),
),
(
"characters",
models.ManyToManyField(
to="guild.character", verbose_name="characters"
),
),
], ],
options={ options={
'verbose_name': 'playsession', "verbose_name": "playsession",
'verbose_name_plural': 'playsessions', "verbose_name_plural": "playsessions",
}, },
), ),
migrations.AddField( migrations.AddField(
model_name='character', model_name="character",
name='player', name="player",
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='guild.player', verbose_name='player'), field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="guild.player",
verbose_name="player",
),
), ),
migrations.AddField( migrations.AddField(
model_name='adventure', model_name="adventure",
name='master', name="master",
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='guild.player', verbose_name='master'), field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="guild.player",
verbose_name="master",
),
), ),
] ]

View File

@ -5,40 +5,71 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('guild', '0001_initial'), ("guild", "0001_initial"),
] ]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Resource', name="Resource",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('name', models.CharField(max_length=255)), "id",
('description', models.TextField()), models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
("description", models.TextField()),
], ],
options={ options={
'verbose_name': 'resource', "verbose_name": "resource",
'verbose_name_plural': 'resources', "verbose_name_plural": "resources",
}, },
), ),
migrations.AlterField( migrations.AlterField(
model_name='player', model_name="player",
name='name', name="name",
field=models.CharField(max_length=255, unique=True), field=models.CharField(max_length=255, unique=True),
), ),
migrations.CreateModel( migrations.CreateModel(
name='ResourceEarned', name="ResourceEarned",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('amount', models.IntegerField()), "id",
('character', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='guild.character', verbose_name='character')), models.BigAutoField(
('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='guild.resource', verbose_name='resource')), auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("amount", models.IntegerField()),
(
"character",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="guild.character",
verbose_name="character",
),
),
(
"resource",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="guild.resource",
verbose_name="resource",
),
),
], ],
options={ options={
'verbose_name': 'resourceearned', "verbose_name": "resourceearned",
'verbose_name_plural': 'resourceearneds', "verbose_name_plural": "resourceearneds",
}, },
), ),
] ]

View File

@ -2,8 +2,8 @@ from django.db import models
from django.urls import reverse from django.urls import reverse
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
class Player(models.Model):
class Player(models.Model):
name = models.CharField(max_length=255, unique=True) name = models.CharField(max_length=255, unique=True)
class Meta: class Meta:
@ -16,8 +16,8 @@ class Player(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse("guild:player_detail", kwargs={"pk": self.pk}) return reverse("guild:player_detail", kwargs={"pk": self.pk})
class Resource(models.Model):
class Resource(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
description = models.TextField() description = models.TextField()
@ -33,11 +33,16 @@ class Resource(models.Model):
class Adventure(models.Model): class Adventure(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
description = models.TextField() description = models.TextField()
master = models.ForeignKey("Player", verbose_name=_("master"), on_delete=models.SET_NULL, null=True, blank=True) master = models.ForeignKey(
"Player",
verbose_name=_("master"),
on_delete=models.SET_NULL,
null=True,
blank=True,
)
class Meta: class Meta:
verbose_name = _("Adventure") verbose_name = _("Adventure")
@ -52,9 +57,15 @@ class Adventure(models.Model):
class Character(models.Model): class Character(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
description = models.TextField() description = models.TextField()
player = models.ForeignKey("Player", verbose_name=_("player"), on_delete=models.SET_NULL, null=True, blank=True) player = models.ForeignKey(
"Player",
verbose_name=_("player"),
on_delete=models.SET_NULL,
null=True,
blank=True,
)
class Meta: class Meta:
verbose_name = _("character") verbose_name = _("character")
@ -66,13 +77,15 @@ class Character(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse("guild:character_detail", kwargs={"pk": self.pk}) return reverse("guild:character_detail", kwargs={"pk": self.pk})
class PlaySession(models.Model):
class PlaySession(models.Model):
date = models.DateField() date = models.DateField()
adventure = models.ForeignKey("Adventure", verbose_name=_("adventure"), on_delete=models.CASCADE) adventure = models.ForeignKey(
"Adventure", verbose_name=_("adventure"), on_delete=models.CASCADE
)
characters = models.ManyToManyField("Character", verbose_name=_("characters")) characters = models.ManyToManyField("Character", verbose_name=_("characters"))
summary = models.TextField() summary = models.TextField()
class Meta: class Meta:
verbose_name = _("playsession") verbose_name = _("playsession")
@ -82,16 +95,24 @@ class PlaySession(models.Model):
return self.name return self.name
def get_absolute_url(self): def get_absolute_url(self):
return reverse( return (
"guild:adventure_detail", reverse("guild:adventure_detail", kwargs={"pk": self.adventure.pk})
kwargs={"pk": self.adventure.pk} + "#playsession"
) + "#playsession" + str(self.pk) + str(self.pk)
)
class ResourceEarned(models.Model): class ResourceEarned(models.Model):
resource = models.ForeignKey(
resource = models.ForeignKey("Resource", verbose_name=_("resource"), on_delete=models.CASCADE) "Resource", verbose_name=_("resource"), on_delete=models.CASCADE
character = models.ForeignKey("Character", verbose_name=_("character"), on_delete=models.CASCADE, null=True, blank=True) )
character = models.ForeignKey(
"Character",
verbose_name=_("character"),
on_delete=models.CASCADE,
null=True,
blank=True,
)
amount = models.IntegerField() amount = models.IntegerField()
class Meta: class Meta:

View File

@ -4,7 +4,8 @@ from django.template.defaultfilters import stringfilter
register = template.Library() register = template.Library()
@register.filter(name='md')
@register.filter(name="md")
@stringfilter @stringfilter
def md(value): def md(value):
return markdown.markdown(value) return markdown.markdown(value)

View File

@ -7,21 +7,87 @@ import guild.views.adventure as adventure_views
urlpatterns = [ urlpatterns = [
path("", views.HomeView.as_view(), name="home"), path("", views.HomeView.as_view(), name="home"),
# path("players/", views.PlayerListView.as_view(), name="player_list"), # path("players/", views.PlayerListView.as_view(), name="player_list"),
path("players/create/", player_views.CreatePlayerView.as_view(), name="create_player"), path(
path("players/<int:pk>/", player_views.PlayerDetailView.as_view(), name="player_detail"), "players/create/", player_views.CreatePlayerView.as_view(), name="create_player"
path("players/<int:pk>/update/", player_views.PlayerUpdateView.as_view(), name="player_update"), ),
path("players/<int:pk>/delete/", player_views.PlayerDeleteView.as_view(), name="player_delete"), path(
path("characters/", character_views.CharacterListView.as_view(), name="character_list"), "players/<int:pk>/",
path("characters/create/", character_views.CreateCharacterView.as_view(), name="create_character"), player_views.PlayerDetailView.as_view(),
path("characters/<int:pk>/", character_views.CharacterDetailView.as_view(), name="character_detail"), name="player_detail",
path("characters/<int:pk>/update/", character_views.CharacterUpdateView.as_view(), name="character_update"), ),
path("characters/<int:pk>/delete/", character_views.CharacterDeleteView.as_view(), name="character_delete"), path(
path("adventures/", adventure_views.AdventureListView.as_view(), name="adventure_list"), "players/<int:pk>/update/",
path("adventures/create/", adventure_views.CreateAdventureView.as_view(), name="create_adventure"), player_views.PlayerUpdateView.as_view(),
path("adventures/<int:pk>/", adventure_views.AdventureDetailView.as_view(), name="adventure_detail"), name="player_update",
path("adventures/<int:pk>/update/", adventure_views.AdventureUpdateView.as_view(), name="adventure_update"), ),
path("adventures/<int:pk>/delete/", adventure_views.AdventureDeleteView.as_view(), name="adventure_delete"), path(
path("adventures/<int:pk>/playsession/create/", adventure_views.PlaySessionCreateView.as_view(), name="create_playsession"), "players/<int:pk>/delete/",
path("adventures/<int:pk>/playsession/<int:playsession_pk>/update/", adventure_views.PlaySessionUpdateView.as_view(), name="playsession_update"), player_views.PlayerDeleteView.as_view(),
path("adventures/<int:pk>/playsession/<int:playsession_pk>/delete/", adventure_views.PlaySessionDeleteView.as_view(), name="playsession_delete"), name="player_delete",
),
path(
"characters/",
character_views.CharacterListView.as_view(),
name="character_list",
),
path(
"characters/create/",
character_views.CreateCharacterView.as_view(),
name="create_character",
),
path(
"characters/<int:pk>/",
character_views.CharacterDetailView.as_view(),
name="character_detail",
),
path(
"characters/<int:pk>/update/",
character_views.CharacterUpdateView.as_view(),
name="character_update",
),
path(
"characters/<int:pk>/delete/",
character_views.CharacterDeleteView.as_view(),
name="character_delete",
),
path(
"adventures/",
adventure_views.AdventureListView.as_view(),
name="adventure_list",
),
path(
"adventures/create/",
adventure_views.CreateAdventureView.as_view(),
name="create_adventure",
),
path(
"adventures/<int:pk>/",
adventure_views.AdventureDetailView.as_view(),
name="adventure_detail",
),
path(
"adventures/<int:pk>/update/",
adventure_views.AdventureUpdateView.as_view(),
name="adventure_update",
),
path(
"adventures/<int:pk>/delete/",
adventure_views.AdventureDeleteView.as_view(),
name="adventure_delete",
),
path(
"adventures/<int:pk>/playsession/create/",
adventure_views.PlaySessionCreateView.as_view(),
name="create_playsession",
),
path(
"adventures/<int:pk>/playsession/<int:playsession_pk>/update/",
adventure_views.PlaySessionUpdateView.as_view(),
name="playsession_update",
),
path(
"adventures/<int:pk>/playsession/<int:playsession_pk>/delete/",
adventure_views.PlaySessionDeleteView.as_view(),
name="playsession_delete",
),
] ]

View File

@ -4,6 +4,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from guild.models import Adventure, Character, Player from guild.models import Adventure, Character, Player
# Create your views here. # Create your views here.
class HomeView(LoginRequiredMixin, TemplateView): class HomeView(LoginRequiredMixin, TemplateView):
template_name = "guild/home.html" template_name = "guild/home.html"
@ -14,5 +15,3 @@ class HomeView(LoginRequiredMixin, TemplateView):
context["players"] = Player.objects.all() context["players"] = Player.objects.all()
context["characters"] = Character.objects.all() context["characters"] = Character.objects.all()
return context return context

View File

@ -1,4 +1,3 @@
from typing import Any, Dict, Optional, Type from typing import Any, Dict, Optional, Type
from django.forms.models import BaseModelForm from django.forms.models import BaseModelForm
from django.http import HttpResponse from django.http import HttpResponse
@ -15,21 +14,26 @@ class AdventureListView(LoginRequiredMixin, ListView):
model = Adventure model = Adventure
context_object_name = "adventures" context_object_name = "adventures"
class CreateAdventureView(LoginRequiredMixin, CreateView): class CreateAdventureView(LoginRequiredMixin, CreateView):
model = Adventure model = Adventure
fields = ["name", "description", "master"] fields = ["name", "description", "master"]
class AdventureDetailView(LoginRequiredMixin, DetailView): class AdventureDetailView(LoginRequiredMixin, DetailView):
model = Adventure model = Adventure
class AdventureUpdateView(LoginRequiredMixin, UpdateView): class AdventureUpdateView(LoginRequiredMixin, UpdateView):
model = Adventure model = Adventure
fields = ["name", "description", "master"] fields = ["name", "description", "master"]
class AdventureDeleteView(LoginRequiredMixin, DeleteView): class AdventureDeleteView(LoginRequiredMixin, DeleteView):
model = Adventure model = Adventure
success_url = "/" success_url = "/"
class PlaySessionCreateView(LoginRequiredMixin, CreateView): class PlaySessionCreateView(LoginRequiredMixin, CreateView):
model = PlaySession model = PlaySession
form_class = PlaySessionForm form_class = PlaySessionForm
@ -37,11 +41,12 @@ class PlaySessionCreateView(LoginRequiredMixin, CreateView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.adventure = get_object_or_404(Adventure, pk=kwargs["pk"]) self.adventure = get_object_or_404(Adventure, pk=kwargs["pk"])
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def form_valid(self, form: BaseModelForm) -> HttpResponse: def form_valid(self, form: BaseModelForm) -> HttpResponse:
form.instance.adventure = self.adventure form.instance.adventure = self.adventure
return super().form_valid(form) return super().form_valid(form)
class PlaySessionUpdateView(LoginRequiredMixin, UpdateView): class PlaySessionUpdateView(LoginRequiredMixin, UpdateView):
model = PlaySession model = PlaySession
form_class = PlaySessionForm form_class = PlaySessionForm
@ -50,6 +55,7 @@ class PlaySessionUpdateView(LoginRequiredMixin, UpdateView):
self.adventure = get_object_or_404(Adventure, pk=kwargs["pk"]) self.adventure = get_object_or_404(Adventure, pk=kwargs["pk"])
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
class PlaySessionDeleteView(LoginRequiredMixin, DeleteView): class PlaySessionDeleteView(LoginRequiredMixin, DeleteView):
model = PlaySession model = PlaySession
pk_url_kwarg = "playsession_pk" pk_url_kwarg = "playsession_pk"
@ -59,4 +65,4 @@ class PlaySessionDeleteView(LoginRequiredMixin, DeleteView):
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_success_url(self) -> str: def get_success_url(self) -> str:
return self.adventure.get_absolute_url() return self.adventure.get_absolute_url()

View File

@ -1,4 +1,3 @@
from django.views.generic import TemplateView, ListView, DetailView from django.views.generic import TemplateView, ListView, DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
@ -10,17 +9,21 @@ class CharacterListView(LoginRequiredMixin, ListView):
model = Character model = Character
context_object_name = "characters" context_object_name = "characters"
class CreateCharacterView(LoginRequiredMixin, CreateView): class CreateCharacterView(LoginRequiredMixin, CreateView):
model = Character model = Character
fields = ["name", "description", "player"] fields = ["name", "description", "player"]
class CharacterDetailView(LoginRequiredMixin, DetailView): class CharacterDetailView(LoginRequiredMixin, DetailView):
model = Character model = Character
class CharacterUpdateView(LoginRequiredMixin, UpdateView): class CharacterUpdateView(LoginRequiredMixin, UpdateView):
model = Character model = Character
fields = ["name", "description", "player"] fields = ["name", "description", "player"]
class CharacterDeleteView(LoginRequiredMixin, DeleteView): class CharacterDeleteView(LoginRequiredMixin, DeleteView):
model = Character model = Character
success_url = "/" success_url = "/"

View File

@ -1,4 +1,3 @@
from django.views.generic import TemplateView, ListView, DetailView from django.views.generic import TemplateView, ListView, DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
@ -10,13 +9,16 @@ class CreatePlayerView(LoginRequiredMixin, CreateView):
model = Player model = Player
fields = ["name"] fields = ["name"]
class PlayerDetailView(LoginRequiredMixin, DetailView): class PlayerDetailView(LoginRequiredMixin, DetailView):
model = Player model = Player
class PlayerUpdateView(LoginRequiredMixin, UpdateView): class PlayerUpdateView(LoginRequiredMixin, UpdateView):
model = Player model = Player
fields = ["name"] fields = ["name"]
class PlayerDeleteView(LoginRequiredMixin, DeleteView): class PlayerDeleteView(LoginRequiredMixin, DeleteView):
model = Player model = Player
success_url = "/" success_url = "/"

View File

@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guild_journal.settings') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guild_journal.settings")
application = get_asgi_application() application = get_asgi_application()

View File

@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-e*p%e)pwf+-ntt4wpn-^^7-0yq)!cjo*om18vy77-=*c0jjfqa' SECRET_KEY = "django-insecure-e*p%e)pwf+-ntt4wpn-^^7-0yq)!cjo*om18vy77-=*c0jjfqa"
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
@ -31,55 +31,55 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', "django.contrib.admin",
'django.contrib.auth', "django.contrib.auth",
'django.contrib.contenttypes', "django.contrib.contenttypes",
'django.contrib.sessions', "django.contrib.sessions",
'django.contrib.messages', "django.contrib.messages",
'django.contrib.staticfiles', "django.contrib.staticfiles",
"guild" "guild",
] ]
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', "django.middleware.security.SecurityMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware', "django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.common.CommonMiddleware', "django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware', "django.middleware.csrf.CsrfViewMiddleware",
'django.contrib.auth.middleware.AuthenticationMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware",
'django.contrib.messages.middleware.MessageMiddleware', "django.contrib.messages.middleware.MessageMiddleware",
'django.middleware.clickjacking.XFrameOptionsMiddleware', "django.middleware.clickjacking.XFrameOptionsMiddleware",
] ]
ROOT_URLCONF = 'guild_journal.urls' ROOT_URLCONF = "guild_journal.urls"
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', "BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [ "DIRS": [
BASE_DIR / "templates", BASE_DIR / "templates",
], ],
'APP_DIRS': True, "APP_DIRS": True,
'OPTIONS': { "OPTIONS": {
'context_processors': [ "context_processors": [
'django.template.context_processors.debug', "django.template.context_processors.debug",
'django.template.context_processors.request', "django.template.context_processors.request",
'django.contrib.auth.context_processors.auth', "django.contrib.auth.context_processors.auth",
'django.contrib.messages.context_processors.messages', "django.contrib.messages.context_processors.messages",
], ],
}, },
}, },
] ]
WSGI_APPLICATION = 'guild_journal.wsgi.application' WSGI_APPLICATION = "guild_journal.wsgi.application"
# Database # Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.db.backends.sqlite3', "ENGINE": "django.db.backends.sqlite3",
'NAME': BASE_DIR / 'db.sqlite3', "NAME": BASE_DIR / "db.sqlite3",
} }
} }
@ -89,16 +89,16 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
}, },
] ]
@ -106,9 +106,9 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/ # https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = "en-us"
TIME_ZONE = 'UTC' TIME_ZONE = "UTC"
USE_I18N = True USE_I18N = True
@ -118,7 +118,7 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/ # https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = "static/"
STATICFILES_DIRS = [ STATICFILES_DIRS = [
BASE_DIR / "static", BASE_DIR / "static",
@ -127,4 +127,4 @@ STATICFILES_DIRS = [
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

View File

@ -18,7 +18,7 @@ from django.contrib import admin
from django.urls import include, path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path("admin/", admin.site.urls),
path("accounts/", include("django.contrib.auth.urls")), path("accounts/", include("django.contrib.auth.urls")),
path("", include(("guild.urls", "guild"), namespace="guild")), path("", include(("guild.urls", "guild"), namespace="guild")),
] ]

View File

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guild_journal.settings') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guild_journal.settings")
application = get_wsgi_application() application = get_wsgi_application()

View File

@ -6,7 +6,7 @@ import sys
def main(): def main():
"""Run administrative tasks.""" """Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guild_journal.settings') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guild_journal.settings")
try: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc:
@ -18,5 +18,5 @@ def main():
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)
if __name__ == '__main__': if __name__ == "__main__":
main() main()