Compare commits

...

2 Commits

Author SHA1 Message Date
Niko Abeler 14bbd86391 release/deploy setup 2023-06-13 20:35:41 +02:00
Niko Abeler f91165d7b9 more cleanup 2023-06-13 20:24:54 +02:00
15 changed files with 138 additions and 40 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM python:3.11-alpine
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["gunicorn", "-b", "0.0.0.0:8000", "guild_journal.wsgi"]

View File

@ -3,19 +3,15 @@
{% block content %}
<h1>Home</h1>
<ul>
<li>
<a href="{% url 'guild:create_player' %}">Create New Player</a>
</li>
<li>
<a href="{% url 'guild:create_character' %}">Create New Character</a>
</li>
<li>
<a href="{% url 'guild:create_adventure' %}">Create New Adventure</a>
</li>
</ul>
<div class="row">
<div class="column column-75">
<h2>Adventures</h2>
</div>
<div class="column column-25">
<a class="button button-outline" href="{% url 'guild:create_adventure' %}">Create New Adventure</a>
</div>
</div>
<h2>Adventures</h2>
<ul>
{% for adventure in adventures %}
@ -25,7 +21,14 @@
{% endfor %}
</ul>
<h2>Characters</h2>
<div class="row">
<div class="column column-75">
<h2>Characters</h2>
</div>
<div class="column column-25">
<a class="button button-outline" href="{% url 'guild:create_character' %}">Create New Character</a>
</div>
</div>
<ul>
{% for character in characters %}
@ -35,7 +38,14 @@
{% endfor %}
</ul>
<h2>Players</h2>
<div class="row">
<div class="column column-75">
<h2>Players</h2>
</div>
<div class="column column-25">
<a class="button button-outline" href="{% url 'guild:create_player' %}">Create New Player</a>
</div>
</div>
<ul>
{% for player in players %}

View File

@ -3,9 +3,18 @@ import guild.views as views
import guild.views.player as player_views
import guild.views.character as character_views
import guild.views.adventure as adventure_views
from django.contrib.auth import views as auth_views
urlpatterns = [
path("", views.HomeView.as_view(), name="home"),
path("acounnt/login/", auth_views.LoginView.as_view(next_page="/"), name="login"),
path(
"account/logout/",
auth_views.LogoutView.as_view(
template_name="registration/logout.html",
),
name="logout",
),
# path("players/", views.PlayerListView.as_view(), name="player_list"),
path(
"players/create/", player_views.CreatePlayerView.as_view(), name="create_player"

0
guild/views/account.py Normal file
View File

View File

@ -50,6 +50,7 @@ class PlaySessionCreateView(LoginRequiredMixin, CreateView):
class PlaySessionUpdateView(LoginRequiredMixin, UpdateView):
model = PlaySession
form_class = PlaySessionForm
pk_url_kwarg = "playsession_pk"
def dispatch(self, request, *args, **kwargs):
self.adventure = get_object_or_404(Adventure, pk=kwargs["pk"])

View File

@ -0,0 +1,8 @@
import os
from .default import *
if os.environ.get("GUILD_JOURNAL_ENV") == "production":
from .production import *
else:
from .development import *

View File

@ -13,20 +13,12 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
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!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
@ -42,6 +34,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
@ -72,18 +65,6 @@ TEMPLATES = [
WSGI_APPLICATION = "guild_journal.wsgi.application"
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
@ -118,11 +99,13 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATIC_URL = "static/"
STATICFILES_DIRS = [
BASE_DIR / "static",
]
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_DIRS = []
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

View File

@ -0,0 +1,22 @@
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent.parent
# SECURITY WARNING: keep the secret key used in production secret!
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!
DEBUG = True
ALLOWED_HOSTS = []
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}

View File

@ -0,0 +1,22 @@
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent.parent
# SECURITY WARNING: keep the secret key used in production secret!
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!
DEBUG = False
ALLOWED_HOSTS = ["*"]
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "/data/db.sqlite3",
}
}

View File

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

2
release.sh Normal file
View File

@ -0,0 +1,2 @@
docker build . -t git.libove.org/h4kor/guild-journal:$1
docker push git.libove.org/h4kor/guild-journal:$1

13
requirements.txt Normal file
View File

@ -0,0 +1,13 @@
asgiref==3.6.0
black==23.3.0
click==8.1.3
Django==4.2.1
gunicorn==20.1.0
Markdown==3.4.3
mypy-extensions==1.0.0
packaging==23.1
pathspec==0.11.1
platformdirs==3.5.3
ruff==0.0.272
sqlparse==0.4.4
tomli==2.0.1

View File

@ -67,6 +67,17 @@
<li class="navigation-item">
<a href="{% url 'guild:character_list' %}">Characters</a>
</li>
{% if user.is_authenticated %}
<li class="navigation-item">
<a href="{% url 'guild:logout' %}">Logout</a>
</li>
{% else %}
<li class="navigation-item">
<a href="{% url 'guild:login' %}">Login</a>
</li>
{% endif %}
</ul>
</section>
</nav>

View File

@ -15,7 +15,7 @@
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
<form method="post" action="{% url 'guild:login' %}">
{% csrf_token %}
{{form}}
<input type="submit" value="login">

View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block content %}
<h1>Logged Out</h1>
<p>You have been logged out. <a href="{% url 'guild:login' %}">Log in again</a>.</p>
{% endblock %}