web/quotes: prodify
This commit is contained in:
parent
ef81a0c080
commit
b7574660de
7 changed files with 69 additions and 15 deletions
|
@ -51,6 +51,10 @@ in
|
||||||
systemd.services.quotesdb = {
|
systemd.services.quotesdb = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
|
environment.DJANGO_SETTINGS_MODULE = "quotes.quotesapp.prod_settings";
|
||||||
|
preStart = ''
|
||||||
|
${pkg}/bin/quotes-manage migrate --no-input
|
||||||
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
EnvironmentFile = secrets.quotesdb.environment;
|
EnvironmentFile = secrets.quotesdb.environment;
|
||||||
RuntimeDirectory = "quotesdb";
|
RuntimeDirectory = "quotesdb";
|
||||||
|
|
|
@ -4,6 +4,7 @@ let
|
||||||
python = pkgs.python3.withPackages (ps: with ps; [
|
python = pkgs.python3.withPackages (ps: with ps; [
|
||||||
django_3
|
django_3
|
||||||
gunicorn
|
gunicorn
|
||||||
|
psycopg2
|
||||||
(depot.pkgs.django-allauth.override {
|
(depot.pkgs.django-allauth.override {
|
||||||
django = django_3;
|
django = django_3;
|
||||||
})
|
})
|
||||||
|
@ -33,6 +34,9 @@ pkgs.stdenvNoCC.mkDerivation rec {
|
||||||
makeWrapper "${python}/bin/gunicorn" "$out/bin/quotes" \
|
makeWrapper "${python}/bin/gunicorn" "$out/bin/quotes" \
|
||||||
--add-flags "quotes.quotesapp.wsgi" \
|
--add-flags "quotes.quotesapp.wsgi" \
|
||||||
--suffix PYTHONPATH : "$sitepkgdir"
|
--suffix PYTHONPATH : "$sitepkgdir"
|
||||||
|
makeWrapper "${python}/bin/django-admin" "$out/bin/quotes-manage" \
|
||||||
|
--set DJANGO_SETTINGS_MODULE "quotes.quotesapp.prod_settings" \
|
||||||
|
--suffix PYTHONPATH : "$sitepkgdir"
|
||||||
|
|
||||||
mkdir -p "$out/share/static"
|
mkdir -p "$out/share/static"
|
||||||
export STATIC_ROOT="$out/share/static"
|
export STATIC_ROOT="$out/share/static"
|
||||||
|
|
|
@ -16,21 +16,52 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Person',
|
name="Person",
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
(
|
||||||
('name', models.CharField(max_length=120, unique=True)),
|
"id",
|
||||||
('user', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=120, unique=True)),
|
||||||
|
(
|
||||||
|
"user",
|
||||||
|
models.ForeignKey(
|
||||||
|
default=None,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Quote',
|
name="Quote",
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
(
|
||||||
('quote', models.TextField()),
|
"id",
|
||||||
('added_at', models.DateTimeField(default=datetime.datetime.now)),
|
models.AutoField(
|
||||||
('added_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
auto_created=True,
|
||||||
('references', models.ManyToManyField(to='quotedb.Person')),
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("quote", models.TextField()),
|
||||||
|
("added_at", models.DateTimeField(default=datetime.datetime.now)),
|
||||||
|
(
|
||||||
|
"added_by",
|
||||||
|
models.ForeignKey(
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("references", models.ManyToManyField(to="quotedb.Person")),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,13 +6,15 @@ from django.contrib.auth import models as auth_models
|
||||||
|
|
||||||
class Person(models.Model):
|
class Person(models.Model):
|
||||||
name = models.CharField(null=False, unique=True, blank=False, max_length=120)
|
name = models.CharField(null=False, unique=True, blank=False, max_length=120)
|
||||||
user = models.ForeignKey(auth_models.User, null=True, default=None, on_delete=models.SET_NULL)
|
user = models.ForeignKey(
|
||||||
|
auth_models.User, null=True, default=None, on_delete=models.SET_NULL
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = 'people'
|
verbose_name_plural = "people"
|
||||||
|
|
||||||
|
|
||||||
class Quote(models.Model):
|
class Quote(models.Model):
|
||||||
|
|
15
web/quotes/quotesapp/prod_settings.py
Normal file
15
web/quotes/quotesapp/prod_settings.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from quotes.quotesapp.settings import *
|
||||||
|
|
||||||
|
SECRET_KEY = os.environ["SECRET_KEY"]
|
||||||
|
DEBUG = False
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = [
|
||||||
|
"quotes.bfob.gg",
|
||||||
|
]
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
"default": {
|
||||||
|
"ENGINE": "django.db.backends.postgresql",
|
||||||
|
"NAME": "quotesdb",
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,12 +41,10 @@ INSTALLED_APPS = [
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
"django.contrib.sites",
|
"django.contrib.sites",
|
||||||
|
|
||||||
"allauth",
|
"allauth",
|
||||||
"allauth.account",
|
"allauth.account",
|
||||||
"allauth.socialaccount",
|
"allauth.socialaccount",
|
||||||
"allauth.socialaccount.providers.discord",
|
"allauth.socialaccount.providers.discord",
|
||||||
|
|
||||||
"quotes.quotedb",
|
"quotes.quotedb",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,6 @@ import quotes.quotedb.urls
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path('accounts/', include(allauth.urls)),
|
path("accounts/", include(allauth.urls)),
|
||||||
re_path(r"", include(quotes.quotedb.urls)),
|
re_path(r"", include(quotes.quotedb.urls)),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue