Commit 3f4891a3 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Improve script to create AccessibleAreas

parent 2c0d339f
...@@ -11,19 +11,16 @@ class Command(BaseCommand): ...@@ -11,19 +11,16 @@ class Command(BaseCommand):
@transaction.atomic @transaction.atomic
def handle(self, *args, **options): def handle(self, *args, **options):
areas = { areas = {
'Forums': 'forums', 'forums': {'name_en': 'Forums', 'name_pt_br': 'Fóruns', 'name_es': 'Foros'},
'Messages': 'messages', 'messages': {'name_en': 'Messages', 'name_pt_br': 'Avisos', 'name_es': 'Notificaciones'},
'Courses': 'courses', 'courses': {'name_en': 'Courses', 'name_pt_br': 'Cursos', 'name_es': 'Cursos'},
'Classrooms': 'classrooms', 'classrooms': {'name_en': 'Classrooms', 'name_pt_br': 'Salas', 'name_es': 'Aulas'},
'Notes': 'notes', 'notes': {'name_en': 'Notes', 'name_pt_br': 'Notas', 'name_es': 'Notas'},
'Profile Page': 'profile-page', 'profile-page': {'name_en': 'Profile Page', 'name_pt_br': 'Página de perfil', 'name_es': 'Página de perfil'},
'Chat Main Page': 'chat-main-page', 'chat-main-page': {'name_en': 'Chats page', 'name_pt_br': 'Página de chats', 'name_es': 'Página de chats'},
'Dashboard': 'dashboard' 'dashboard': {'name_en': 'Dashboard', 'name_pt_br': 'Painel', 'name_es': 'Panel'}
} }
for name, slug in areas.items(): for slug, attrs in areas.items():
a, created = AccessibleArea.objects.get_or_create(name=name, slug=slug) a, created = AccessibleArea.objects.get_or_create(slug=slug)
if created: AccessibleArea.objects.filter(id=a.id).update(**attrs)
print('Created area {}'.format(name))
else:
print('Area {} already exists. Skipping creation...'.format(name))
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