Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
67114f51
Commit
67114f51
authored
Jul 14, 2016
by
Skia
🤘
Browse files
Fix populate to work with Postgres
parent
e29e9471
Changes
3
Hide whitespace changes
Inline
Side-by-side
club/models.py
View file @
67114f51
...
...
@@ -50,13 +50,10 @@ class Club(models.Model):
self
.
check_loop
()
def
save
(
self
):
super
(
Club
,
self
).
save
()
try
:
if
self
.
id
is
None
:
MetaGroup
(
name
=
self
.
unix_name
+
settings
.
SITH_BOARD_SUFFIX
).
save
()
MetaGroup
(
name
=
self
.
unix_name
+
settings
.
SITH_MEMBER_SUFFIX
).
save
()
except
IntegrityError
as
e
:
# Groups already exists
pass
super
(
Club
,
self
).
save
()
def
__str__
(
self
):
return
self
.
name
...
...
core/management/commands/populate.py
View file @
67114f51
import
os
from
datetime
import
date
from
io
import
StringIO
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management
import
call_command
from
django.conf
import
settings
from
django.db
import
connection
from
core.models
import
Group
,
User
,
Page
,
PageRev
...
...
@@ -19,15 +21,21 @@ class Command(BaseCommand):
parser
.
add_argument
(
'--prod'
,
action
=
"store_true"
)
def
handle
(
self
,
*
args
,
**
options
):
os
.
environ
[
'DJANGO_COLORS'
]
=
'nocolor'
root_path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))))
for
g
in
settings
.
SITH_GROUPS
.
values
():
Group
(
id
=
g
[
'id'
],
name
=
g
[
'name'
]).
save
()
sqlcmd
=
StringIO
()
call_command
(
"sqlsequencereset"
,
"core"
,
"auth"
,
stdout
=
sqlcmd
)
cursor
=
connection
.
cursor
()
print
(
sqlcmd
.
getvalue
())
cursor
.
execute
(
sqlcmd
.
getvalue
())
root
=
User
(
username
=
'root'
,
last_name
=
""
,
first_name
=
"Bibou"
,
email
=
"ae.info@utbm.fr"
,
date_of_birth
=
"1942-06-12"
,
is_superuser
=
True
,
is_staff
=
True
)
root
.
set_password
(
"plop"
)
root
.
save
()
for
g
in
settings
.
SITH_GROUPS
.
values
():
Group
(
id
=
g
[
'id'
],
name
=
g
[
'name'
]).
save
()
ae
=
Club
(
name
=
settings
.
SITH_MAIN_CLUB
[
'name'
],
unix_name
=
settings
.
SITH_MAIN_CLUB
[
'unix_name'
],
address
=
settings
.
SITH_MAIN_CLUB
[
'address'
])
ae
.
save
()
...
...
core/management/commands/setup.py
View file @
67114f51
...
...
@@ -13,10 +13,10 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
root_path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))))
try
:
os
.
unlink
(
os
.
path
.
join
(
root_path
,
'db.sqlite3'
))
os
.
mkdir
(
os
.
path
.
join
(
root_path
)
+
'/data'
)
except
Exception
as
e
:
print
(
e
)
call_command
(
'flush'
)
call_command
(
'migrate'
)
if
options
[
'prod'
]:
call_command
(
'populate'
,
'--prod'
)
...
...
Write
Preview
Supports
Markdown
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