aab21
This commit is contained in:
commit
0508d8cd9a
53 changed files with 765 additions and 0 deletions
0
app/text/__init__.py
Normal file
0
app/text/__init__.py
Normal file
3
app/text/admin.py
Normal file
3
app/text/admin.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
app/text/apps.py
Normal file
6
app/text/apps.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TextConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app.text'
|
||||
42
app/text/migrations/0001_initial.py
Normal file
42
app/text/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-28 12:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Essay',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('modified', models.DateTimeField(auto_now=True)),
|
||||
('slug', models.SlugField()),
|
||||
('public', models.BooleanField(default=False)),
|
||||
('data', models.JSONField(default=dict)),
|
||||
('title', models.TextField()),
|
||||
('teaser', models.TextField()),
|
||||
('body', models.TextField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Page',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('modified', models.DateTimeField(auto_now=True)),
|
||||
('slug', models.SlugField()),
|
||||
('public', models.BooleanField(default=False)),
|
||||
('data', models.JSONField(default=dict)),
|
||||
('title', models.TextField()),
|
||||
('teaser', models.TextField()),
|
||||
('body', models.TextField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
app/text/migrations/__init__.py
Normal file
0
app/text/migrations/__init__.py
Normal file
33
app/text/models.py
Normal file
33
app/text/models.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import logging
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
User = get_user_model()
|
||||
|
||||
class Page(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
||||
slug = models.SlugField()
|
||||
public = models.BooleanField(default=False)
|
||||
|
||||
data = models.JSONField(default=dict)
|
||||
|
||||
title = models.TextField()
|
||||
teaser = models.TextField()
|
||||
body = models.TextField()
|
||||
|
||||
class Essay(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
||||
slug = models.SlugField()
|
||||
public = models.BooleanField(default=False)
|
||||
|
||||
data = models.JSONField(default=dict)
|
||||
|
||||
title = models.TextField()
|
||||
teaser = models.TextField()
|
||||
body = models.TextField()
|
||||
3
app/text/tests.py
Normal file
3
app/text/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
21
app/text/views.py
Normal file
21
app/text/views.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
|
||||
from . import models
|
||||
|
||||
def index(request):
|
||||
context = {}
|
||||
return render(request, 'index.html', context)
|
||||
|
||||
def about(request):
|
||||
context = {}
|
||||
return render(request, 'about.html', context)
|
||||
|
||||
def essays(request):
|
||||
context = {}
|
||||
context['essays'] = models.Essay.objects.filter(public=True).order_by('created')
|
||||
return render(request, 'essays.html', context)
|
||||
|
||||
def essay(request, slug):
|
||||
context = {}
|
||||
context['essay'] = get_object_or_404(models.Essay, slug=slug)
|
||||
return render(request, 'essay.html', context)
|
||||
Loading…
Add table
Add a link
Reference in a new issue