feat(i18n): add possibility to set english description for services

This commit is contained in:
Romain J 2020-05-16 14:40:22 +02:00
parent 20e623ea39
commit d52eccd795
6 changed files with 25 additions and 4 deletions

View file

@ -14,7 +14,8 @@ class ServicesAdmin(admin.ModelAdmin):
"hidden", "hidden",
) )
fieldsets = [ fieldsets = [
("Global", {"fields": ["name", "domain", "photo", "description"]}), ("Global", {"fields": ["name", "domain", "photo"]}),
("Descriptions", {"fields": ["description", "description_en"]}),
("Types", {"fields": ["sources", "hosted"]}), ("Types", {"fields": ["sources", "hosted"]}),
("Misc", {"fields": ["hidden"]}), ("Misc", {"fields": ["hidden"]}),
] ]

View file

@ -0,0 +1,18 @@
# Generated by Django 3.0.2 on 2020-05-16 12:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('gnous_eu', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='service',
name='description_en',
field=models.TextField(null=True),
),
]

View file

@ -18,6 +18,7 @@ class Service(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
name = models.CharField(max_length=150) name = models.CharField(max_length=150)
description = models.TextField() description = models.TextField()
description_en = models.TextField(null=True)
photo = models.ImageField(upload_to="services") photo = models.ImageField(upload_to="services")
sources = models.CharField( sources = models.CharField(

View file

@ -39,7 +39,7 @@
{{ service.name }} {{ service.name }}
<code>{{ service.domain }}</code> <code>{{ service.domain }}</code>
</h3> </h3>
<p>{{ service.description }}</p> <p>{% get_current_language as LANGUAGE_CODE %}{% if LANGUAGE_CODE == 'en' and service.description_en != None %}{{ service.description_en }}{% else %}{{ service.description }}{% endif %}</p>
<a href="https://{{ service.domain }}" class="uk-text-large">{% trans "Rejoindre !" %}</a> <a href="https://{{ service.domain }}" class="uk-text-large">{% trans "Rejoindre !" %}</a>
</div> </div>
<div class="uk-card-footer uk-card-media"> <div class="uk-card-footer uk-card-media">

View file

@ -1,7 +1,8 @@
from django.http import HttpResponse, HttpResponseNotFound, HttpRequest from django.http import HttpResponse, HttpRequest
from django.shortcuts import render from django.shortcuts import render
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.db.models import Q from django.db.models import Q
from django.utils import translation
from apps.gnous_eu.models import Service from apps.gnous_eu.models import Service

View file

@ -19,7 +19,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "*0q64%2cb!f@w(o@b74yyi2#x1d2r#%uul+hc1=gne^8u+*3)k" SECRET_KEY = "*0q64%2cb!f@w(o@b74yyi2#xr1d2r#%uul+hc1=gne^8u+*3)k"
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True