cleanup, better admin
This commit is contained in:
parent
d5b3076645
commit
b8f1c52613
15 changed files with 124 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ db.sqlite3
|
||||||
www/
|
www/
|
||||||
*.swp
|
*.swp
|
||||||
venv
|
venv
|
||||||
|
*.swo
|
||||||
|
|
|
@ -10,14 +10,6 @@
|
||||||
}
|
}
|
||||||
.film {
|
.film {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
.left, .right {
|
|
||||||
width: 50%;
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h1 {
|
h1 {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
@ -26,7 +18,6 @@
|
||||||
@media screen and (max-width: 799px) {
|
@media screen and (max-width: 799px) {
|
||||||
.film {
|
.film {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
flex-direction: column;
|
|
||||||
h2 {
|
h2 {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,26 @@
|
||||||
|
|
||||||
|
|
||||||
.texts {
|
.texts {
|
||||||
.text {
|
box-sizing: border-box;
|
||||||
margin: 8px;
|
|
||||||
|
a {
|
||||||
|
color: #e00;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
margin: 8px;
|
||||||
|
h1 {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 799px) {
|
||||||
|
.text {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
h2 {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="films">
|
<div class="films">
|
||||||
{% for film in films %}
|
{% for film in films %}
|
||||||
<div class="film">
|
<div class="film">
|
||||||
<h1><a href="{% url 'film' film.slug %}">{{ film.data.title | safe }}</a></h1>
|
<h1><a href="{{ film.get_absolute_url }}">{{ film.data.title | safe }}</a></h1>
|
||||||
<h2>{{ film.data.director|join:", "|safe }}</h2>
|
<h2>{{ film.data.director|join:", "|safe }}</h2>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
<div class="texts">
|
<div class="texts">
|
||||||
{% for text in texts %}
|
{% for text in texts %}
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<a href="{{ text.get_absolute_url }}">{{ text.title }}</a>
|
<h1><a href="{{ text.get_absolute_url }}">{{ text.title | safe }}</a></h1>
|
||||||
|
<h2>{{ text.byline|safe }}</h2>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -5,7 +5,12 @@ from . import models
|
||||||
|
|
||||||
@admin.decorators.register(models.Text)
|
@admin.decorators.register(models.Text)
|
||||||
class TextAdmin(admin.ModelAdmin):
|
class TextAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = (
|
||||||
|
'__str__',
|
||||||
|
'position',
|
||||||
|
'slug',
|
||||||
|
'public',
|
||||||
|
)
|
||||||
|
|
||||||
@admin.decorators.register(models.Page)
|
@admin.decorators.register(models.Page)
|
||||||
class PageAdmin(admin.ModelAdmin):
|
class PageAdmin(admin.ModelAdmin):
|
||||||
|
|
18
app/text/migrations/0004_rename_teaser_text_byline.py
Normal file
18
app/text/migrations/0004_rename_teaser_text_byline.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-11 12:35
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('text', '0003_auto_20211011_1222'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='text',
|
||||||
|
old_name='teaser',
|
||||||
|
new_name='byline',
|
||||||
|
),
|
||||||
|
]
|
18
app/text/migrations/0005_alter_page_slug.py
Normal file
18
app/text/migrations/0005_alter_page_slug.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-11 12:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('text', '0004_rename_teaser_text_byline'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='page',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(blank=True, unique=True),
|
||||||
|
),
|
||||||
|
]
|
18
app/text/migrations/0006_text_position.py
Normal file
18
app/text/migrations/0006_text_position.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-11 12:44
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('text', '0005_alter_page_slug'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='text',
|
||||||
|
name='position',
|
||||||
|
field=models.IntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
|
@ -12,12 +12,10 @@ class Page(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
modified = models.DateTimeField(auto_now=True)
|
modified = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
slug = models.SlugField(blank=True)
|
slug = models.SlugField(blank=True, unique=True)
|
||||||
public = models.BooleanField(default=False)
|
public = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|
||||||
title = models.TextField(blank=True)
|
title = models.TextField(blank=True)
|
||||||
#teaser = models.TextField(blank=True)
|
|
||||||
body = models.TextField(blank=True)
|
body = models.TextField(blank=True)
|
||||||
data = models.JSONField(default=dict, blank=True)
|
data = models.JSONField(default=dict, blank=True)
|
||||||
|
|
||||||
|
@ -37,9 +35,10 @@ class Text(models.Model):
|
||||||
|
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
public = models.BooleanField(default=False)
|
public = models.BooleanField(default=False)
|
||||||
|
position = models.IntegerField(default=0)
|
||||||
|
|
||||||
title = models.TextField()
|
title = models.TextField()
|
||||||
teaser = models.TextField(default="", blank=True)
|
byline = models.TextField(default="", blank=True)
|
||||||
body = models.TextField(default="", blank=True)
|
body = models.TextField(default="", blank=True)
|
||||||
|
|
||||||
data = models.JSONField(default=dict)
|
data = models.JSONField(default=dict)
|
||||||
|
|
|
@ -12,6 +12,9 @@ def index(request):
|
||||||
|
|
||||||
def page(request, slug=''):
|
def page(request, slug=''):
|
||||||
context = {}
|
context = {}
|
||||||
|
if request.user.is_staff:
|
||||||
|
page = models.Page.objects.filter(slug=slug).first()
|
||||||
|
else:
|
||||||
page = models.Page.objects.filter(slug=slug, public=True).first()
|
page = models.Page.objects.filter(slug=slug, public=True).first()
|
||||||
if page:
|
if page:
|
||||||
context['page'] = page
|
context['page'] = page
|
||||||
|
@ -24,10 +27,13 @@ def about(request):
|
||||||
|
|
||||||
def texts(request):
|
def texts(request):
|
||||||
context = {}
|
context = {}
|
||||||
context['texts'] = models.Text.objects.filter(public=True).order_by('created')
|
context['texts'] = models.Text.objects.filter(public=True).order_by('position', 'created')
|
||||||
return render(request, 'texts.html', context)
|
return render(request, 'texts.html', context)
|
||||||
|
|
||||||
def text(request, slug):
|
def text(request, slug):
|
||||||
context = {}
|
context = {}
|
||||||
|
if request.user.is_staff:
|
||||||
context['text'] = get_object_or_404(models.Text, slug=slug)
|
context['text'] = get_object_or_404(models.Text, slug=slug)
|
||||||
|
else:
|
||||||
|
context['text'] = get_object_or_404(models.Text, slug=slug, public=True)
|
||||||
return render(request, 'text.html', context)
|
return render(request, 'text.html', context)
|
||||||
|
|
|
@ -5,7 +5,12 @@ from . import models
|
||||||
|
|
||||||
@admin.decorators.register(models.Film)
|
@admin.decorators.register(models.Film)
|
||||||
class FilmAdmin(admin.ModelAdmin):
|
class FilmAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = (
|
||||||
|
'__str__',
|
||||||
|
'position',
|
||||||
|
'slug',
|
||||||
|
'public',
|
||||||
|
)
|
||||||
|
|
||||||
@admin.decorators.register(models.Edit)
|
@admin.decorators.register(models.Edit)
|
||||||
class EditAdmin(admin.ModelAdmin):
|
class EditAdmin(admin.ModelAdmin):
|
||||||
|
|
18
app/video/migrations/0003_film_position.py
Normal file
18
app/video/migrations/0003_film_position.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-11 12:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('video', '0002_auto_20210930_1527'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='film',
|
||||||
|
name='position',
|
||||||
|
field=models.IntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
@ -13,9 +14,10 @@ class Film(models.Model):
|
||||||
|
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
public = models.BooleanField(default=False)
|
public = models.BooleanField(default=False)
|
||||||
|
position = models.IntegerField(default=0)
|
||||||
|
|
||||||
padma_id = models.CharField(max_length=255)
|
padma_id = models.CharField(max_length=255)
|
||||||
vimeo_id = models.CharField(max_length=255, default=None, null=True)
|
vimeo_id = models.CharField(max_length=255, default=None, blank=True)
|
||||||
|
|
||||||
data = models.JSONField(default=dict, blank=True)
|
data = models.JSONField(default=dict, blank=True)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from . import models
|
||||||
|
|
||||||
def films(request):
|
def films(request):
|
||||||
context = {}
|
context = {}
|
||||||
context['films'] = models.Film.objects.filter(public=True).order_by('data__title')
|
context['films'] = models.Film.objects.filter(public=True).order_by('position', 'data__title')
|
||||||
context['settings'] = settings
|
context['settings'] = settings
|
||||||
return render(request, 'films.html', context)
|
return render(request, 'films.html', context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue