Merge pull request 'Language for Assemblies' (#31) from assemblies-lang into main
Reviewed-on: 0x2620/aab21#31
This commit is contained in:
commit
01c247fd42
7 changed files with 68 additions and 9 deletions
|
@ -67,6 +67,7 @@ main > .film {
|
|||
max-width: 250px;
|
||||
|
||||
}
|
||||
|
||||
.texts {
|
||||
margin-top: var(--spacing-2);
|
||||
margin-bottom: var(--spacing-2);
|
||||
|
|
|
@ -102,3 +102,17 @@ main > .about {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
.assemblies {
|
||||
&.row {
|
||||
@media only screen and (max-width: 799px) {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.col {
|
||||
@media only screen and (min-width: 800px) {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
23
app/templates/texts.html
Normal file → Executable file
23
app/templates/texts.html
Normal file → Executable file
|
@ -3,10 +3,23 @@
|
|||
{% block main %}
|
||||
|
||||
<div class="texts">
|
||||
{% for text in texts %}
|
||||
<div class="text">
|
||||
<h1><a href="{{ text.get_absolute_url }}">{{ text.title | safe }}</a></h1>
|
||||
<h2>{{ text.byline|striptags }}</h2>
|
||||
<div class="assemblies">
|
||||
<div class="col">
|
||||
{% for text in en_texts %}
|
||||
<div class="text en">
|
||||
<h1><a href="{{ text.get_absolute_url }}">{{ text.title | safe }}</a></h1>
|
||||
<h2>{{ text.byline|striptags }}</h2>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="col">
|
||||
{% for text in zh_texts %}
|
||||
<div class="text zh">
|
||||
<h1><a href="{{ text.get_absolute_url }}">{{ text.title | safe }}</a></h1>
|
||||
<h2>{{ text.byline|striptags }}</h2>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,11 +9,12 @@ class TextAdmin(admin.ModelAdmin):
|
|||
'__str__',
|
||||
'item',
|
||||
'edit',
|
||||
'language',
|
||||
'slug',
|
||||
'public',
|
||||
'position',
|
||||
)
|
||||
|
||||
list_editable = ['public', 'language']
|
||||
def item(self, obj):
|
||||
return obj.data.get('item')
|
||||
def edit(self, obj):
|
||||
|
|
23
app/text/migrations/0008_auto_20211028_1007.py
Normal file
23
app/text/migrations/0008_auto_20211028_1007.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.7 on 2021-10-28 10:07
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('text', '0007_text_annotations'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='text',
|
||||
name='language',
|
||||
field=models.CharField(choices=[('en', 'EN'), ('zh', 'ZH')], default='en', max_length=8),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='text',
|
||||
name='annotations',
|
||||
field=models.JSONField(blank=True, default=dict, editable=False),
|
||||
),
|
||||
]
|
|
@ -32,10 +32,15 @@ class Page(models.Model):
|
|||
return '/' + settings.URL_PREFIX[:-1]
|
||||
|
||||
|
||||
LANGUAGE_CHOICES = (
|
||||
('en', 'EN'),
|
||||
('zh', 'ZH'),
|
||||
)
|
||||
|
||||
class Text(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
||||
language = models.CharField(choices=LANGUAGE_CHOICES, max_length=8, default='en')
|
||||
slug = models.SlugField()
|
||||
public = models.BooleanField(default=False)
|
||||
position = models.IntegerField(default=0)
|
||||
|
|
|
@ -36,7 +36,9 @@ def about(request):
|
|||
|
||||
def texts(request):
|
||||
context = {}
|
||||
context['texts'] = models.Text.objects.filter(public=True).order_by('position', 'created')
|
||||
all_texts = models.Text.objects.filter(public=True).order_by('position', 'created')
|
||||
context['en_texts'] = all_texts.filter(language='en')
|
||||
context['zh_texts'] = all_texts.filter(language='zh')
|
||||
return render(request, 'texts.html', context)
|
||||
|
||||
def text(request, slug):
|
||||
|
|
Loading…
Reference in a new issue