Commit b173bbfe authored by RyanHerb's avatar RyanHerb

Merge branch 'feature/docker_compose' into dev

parents c85f24ce fd262489
......@@ -9,6 +9,7 @@
## - call exposes all registered services (none by default)
#########################################################################
from gluon.main import save_password
import defs
import vidjil_utils
import StringIO
......@@ -53,9 +54,33 @@ def logger():
log.log(lvl, res)
def init_db():
init_db_helper()
if (db(db.auth_user.id > 0).count() == 0) :
return dict(message=T('create admin user and initialise database'))
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def init_db_form():
if (db(db.auth_user.id > 0).count() == 0) :
error = ""
if request.vars['email'] == "":
error += "You must specify an admin email address, "
if len(request.vars['password']) < 8:
error += "Password must be at least 8 characters long, "
if request.vars['confirm_password'] != request.vars['password']:
error += "Passwords didn't match"
if error == "":
init_db_helper(admin_email=request.vars['email'], admin_password=request.vars['password'])
else :
res = {"success" : "false",
"message" : error}
log.error(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def init_db_helper(force=False):
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def init_db_helper(force=False, admin_email="plop@plop.com", admin_password="1234"):
if (force) or (db(db.auth_user.id > 0).count() == 0) :
#for table in db :
#table.truncate()
......@@ -64,12 +89,15 @@ def init_db_helper(force=False):
## création du premier user
id_first_user=db.auth_user.insert(
password = db.auth_user.password.validate('1234')[0],
email = 'plop@plop.com',
password = db.auth_user.password.validate(admin_password)[0],
email = admin_email,
first_name = 'System',
last_name = 'Administrator'
)
# set web2py administration interface password to the same as vidjil admin password
save_password(admin_password, 443)
## création des groupes de base
id_admin_group=db.auth_group.insert(role='admin')
id_sa_group=db.auth_group.insert(role='user_1')
......
{{extend 'db_layout.html'}}
{{=message}}
<form id="data_form" action="DB_ADDRESS/default/init_db_form" enctype="multipart/form-data" method="post">
<table>
<tbody>
<tr>
<td><label for="email" id="email__label">Email: </label></td>
<td><input class="string" id="email" name="email" type="text" value=""><span></span></td>
<td></td>
</tr>
<tr>
<td><label for="password" id="password__label">Password: </label></td>
<td><input class="string" id="password" name="password" type="password" value=""><span></span></td>
<td></td>
</tr>
<tr>
<td><label for="confirm_password" id="confirm_password__label">Confirm Password: </label></td>
<td><input class="string" id="confirm_password" name="confirm_password" type="password" value=""><span></span></td>
<td></td>
</tr>
<tr>
<td></td>
<td ><input type="submit" value="save" class="btn"></td>
<td></td>
</tr>
</tbody>
</table>
</form>
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