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