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
2c0d339f
Commit
2c0d339f
authored
May 17, 2021
by
Matheus Miranda
Browse files
Add script to create Accessible areas
parent
1d89e247
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
courses/reports/management/commands/create_acessible_areas.py
...ses/reports/management/commands/create_acessible_areas.py
+29
-0
No files found.
courses/reports/management/commands/create_acessible_areas.py
0 → 100644
View file @
2c0d339f
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.contrib.auth
import
get_user_model
from
django.db
import
transaction
from
courses.stats.models
import
AccessibleArea
class
Command
(
BaseCommand
):
help
=
'Create AccessibleArea'
@
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'
}
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
))
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