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 = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
environment.DJANGO_SETTINGS_MODULE = "quotes.quotesapp.prod_settings";
|
||||
preStart = ''
|
||||
${pkg}/bin/quotes-manage migrate --no-input
|
||||
'';
|
||||
serviceConfig = {
|
||||
EnvironmentFile = secrets.quotesdb.environment;
|
||||
RuntimeDirectory = "quotesdb";
|
||||
|
|
|
@ -4,6 +4,7 @@ let
|
|||
python = pkgs.python3.withPackages (ps: with ps; [
|
||||
django_3
|
||||
gunicorn
|
||||
psycopg2
|
||||
(depot.pkgs.django-allauth.override {
|
||||
django = django_3;
|
||||
})
|
||||
|
@ -33,6 +34,9 @@ pkgs.stdenvNoCC.mkDerivation rec {
|
|||
makeWrapper "${python}/bin/gunicorn" "$out/bin/quotes" \
|
||||
--add-flags "quotes.quotesapp.wsgi" \
|
||||
--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"
|
||||
export STATIC_ROOT="$out/share/static"
|
||||
|
|
|
@ -16,21 +16,52 @@ class Migration(migrations.Migration):
|
|||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Person',
|
||||
name="Person",
|
||||
fields=[
|
||||
('id', 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)),
|
||||
(
|
||||
"id",
|
||||
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(
|
||||
name='Quote',
|
||||
name="Quote",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, 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')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
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):
|
||||
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):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'people'
|
||||
verbose_name_plural = "people"
|
||||
|
||||
|
||||
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.staticfiles",
|
||||
"django.contrib.sites",
|
||||
|
||||
"allauth",
|
||||
"allauth.account",
|
||||
"allauth.socialaccount",
|
||||
"allauth.socialaccount.providers.discord",
|
||||
|
||||
"quotes.quotedb",
|
||||
]
|
||||
|
||||
|
|
|
@ -21,6 +21,6 @@ import quotes.quotedb.urls
|
|||
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
path('accounts/', include(allauth.urls)),
|
||||
path("accounts/", include(allauth.urls)),
|
||||
re_path(r"", include(quotes.quotedb.urls)),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue