Commit 1d89e247 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add translation for Accessible area

parent fa1f3e97
# Generated by Django 2.2.22 on 2021-05-17 15:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stats', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='accessiblearea',
name='name_en',
field=models.CharField(max_length=255, null=True, verbose_name='Name'),
),
migrations.AddField(
model_name='accessiblearea',
name='name_es',
field=models.CharField(max_length=255, null=True, verbose_name='Name'),
),
migrations.AddField(
model_name='accessiblearea',
name='name_pt_br',
field=models.CharField(max_length=255, null=True, verbose_name='Name'),
),
migrations.AddField(
model_name='accessiblearea',
name='slug_en',
field=models.SlugField(max_length=255, null=True, unique=True, verbose_name='Slug'),
),
migrations.AddField(
model_name='accessiblearea',
name='slug_es',
field=models.SlugField(max_length=255, null=True, unique=True, verbose_name='Slug'),
),
migrations.AddField(
model_name='accessiblearea',
name='slug_pt_br',
field=models.SlugField(max_length=255, null=True, unique=True, verbose_name='Slug'),
),
]
...@@ -60,7 +60,7 @@ class ActionSerializer(serializers.ModelSerializer): ...@@ -60,7 +60,7 @@ class ActionSerializer(serializers.ModelSerializer):
if isinstance(obj.target, LearningObject): if isinstance(obj.target, LearningObject):
if not obj.target.unit: if not obj.target.unit:
return '' return ''
return obj.target.unit.lesson.course.name return obj.target.unit.lesson.course.name
if isinstance(obj.target, Forum): if isinstance(obj.target, Forum):
return obj.target.title return obj.target.title
if isinstance(obj.target, Classroom): if isinstance(obj.target, Classroom):
...@@ -70,12 +70,12 @@ class ActionSerializer(serializers.ModelSerializer): ...@@ -70,12 +70,12 @@ class ActionSerializer(serializers.ModelSerializer):
return obj.target return obj.target
return obj.target return obj.target
def get_timestamp(self, obj): def get_timestamp(self, obj):
from django.utils import timezone from django.utils import timezone
tz_str = timezone.localtime(obj.timestamp) tz_str = timezone.localtime(obj.timestamp)
date, hour = tz_str.strftime('%d-%m-%Y %H:%M:%S').split() date, hour = tz_str.strftime('%d-%m-%Y %H:%M:%S').split()
return '{} às {}'.format(date, hour) return '{} / {}'.format(date, hour)
def get_accessible_area_name(self, name): def get_accessible_area_name(self, name):
accessible_areas = { accessible_areas = {
......
from modeltranslation.translator import register, TranslationOptions from modeltranslation.translator import register, TranslationOptions
from .models import Course, Lesson, Unit, ProfessorMessage from .models import Course, Lesson, Unit, ProfessorMessage
from .course_material.models import CourseMaterial, File from .course_material.models import CourseMaterial, File
from .stats.models import AccessibleArea
@register(Course) @register(Course)
...@@ -34,3 +35,8 @@ class CourseMaterialTranslationOptions(TranslationOptions): ...@@ -34,3 +35,8 @@ class CourseMaterialTranslationOptions(TranslationOptions):
@register(File) @register(File)
class FileTranslationOptions(TranslationOptions): class FileTranslationOptions(TranslationOptions):
fields = ('title', 'file') fields = ('title', 'file')
@register(AccessibleArea)
class AccessibleAreaTranslationOptions(TranslationOptions):
fields = ('name', 'slug')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment