Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
1d89e247
Commit
1d89e247
authored
May 17, 2021
by
Matheus Miranda
Browse files
Add translation for Accessible area
parent
fa1f3e97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
courses/stats/migrations/0002_auto_20210517_1242.py
courses/stats/migrations/0002_auto_20210517_1242.py
+43
-0
courses/stats/serializers.py
courses/stats/serializers.py
+3
-3
courses/translation.py
courses/translation.py
+6
-0
No files found.
courses/stats/migrations/0002_auto_20210517_1242.py
0 → 100644
View file @
1d89e247
# 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'
),
),
]
courses/stats/serializers.py
View file @
1d89e247
...
...
@@ -60,7 +60,7 @@ class ActionSerializer(serializers.ModelSerializer):
if
isinstance
(
obj
.
target
,
LearningObject
):
if
not
obj
.
target
.
unit
:
return
''
return
obj
.
target
.
unit
.
lesson
.
course
.
name
return
obj
.
target
.
unit
.
lesson
.
course
.
name
if
isinstance
(
obj
.
target
,
Forum
):
return
obj
.
target
.
title
if
isinstance
(
obj
.
target
,
Classroom
):
...
...
@@ -70,12 +70,12 @@ class ActionSerializer(serializers.ModelSerializer):
return
obj
.
target
return
obj
.
target
def
get_timestamp
(
self
,
obj
):
from
django.utils
import
timezone
tz_str
=
timezone
.
localtime
(
obj
.
timestamp
)
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
):
accessible_areas
=
{
...
...
courses/translation.py
View file @
1d89e247
from
modeltranslation.translator
import
register
,
TranslationOptions
from
.models
import
Course
,
Lesson
,
Unit
,
ProfessorMessage
from
.course_material.models
import
CourseMaterial
,
File
from
.stats.models
import
AccessibleArea
@
register
(
Course
)
...
...
@@ -34,3 +35,8 @@ class CourseMaterialTranslationOptions(TranslationOptions):
@
register
(
File
)
class
FileTranslationOptions
(
TranslationOptions
):
fields
=
(
'title'
,
'file'
)
@
register
(
AccessibleArea
)
class
AccessibleAreaTranslationOptions
(
TranslationOptions
):
fields
=
(
'name'
,
'slug'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment