Commit 5b96df9c authored by Jeff MrBE4R's avatar Jeff MrBE4R
Browse files

second commit

parent 82f75a55
This diff is collapsed.
from config import Config
import hashlib
from sqlalchemy import Column, String, Integer, DateTime, Boolean, MetaData, Table
from sqlalchemy import Column, String, Integer, Boolean, MetaData, Table, ForeignKey
def createTables():
try:
......@@ -18,6 +18,8 @@ def createBaseUsers():
password=hashlib.sha256('admin'.encode()).hexdigest(),
fullname='Admin',
email='admin@localhost.localdomain.tld',
can_view_admin=True,
enabled=True,
)
)
except:
......@@ -27,11 +29,28 @@ def createBaseUsers():
metadata = MetaData()
### Users
users = Table('users', metadata,
Column('id', Integer, primary_key=True),
Column('login', String(), nullable=False),
Column('password', String(), nullable=False),
Column('fullname', String()),
Column('email', String()),
Column('can_view_admin', Boolean, nullable=False, default=False),
Column('enabled', Boolean, nullable=False, default=False),
)
### VMs
vms = Table('vms', metadata,
Column('id', Integer, primary_key=True),
Column('token', String(), nullable=False),
Column('ip', String(), nullable=False),
Column('enabled', Boolean, nullable=False, default=False),
)
### Associations
users_vms = Table('users_vms', metadata,
Column('id', Integer, primary_key=True),
Column('user', None, ForeignKey('users.id')),
Column('vm', None, ForeignKey('vms.id')),
)
\ No newline at end of file
File mode changed from 100644 to 100755
<div style="width: 33%; margin-left: auto; margin-right: auto;"><button class="btn btn-success" data-toggle="modal" data-target="#myModal">Ajouter un Utilisateur</button></div>
<form action="{{ url_for('admin_user') }}" method=POST>
<div style="display: none;" class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="divue">×</button>
<h4 class="modal-title" id="myModalLabel">Ajouter un utilisateur</h4>
</div>
<div class="modal-body" style="display: inline-block; width: 100%;">
<table id="userMod">
<tr>
<td style="border: none; text-align: left;">
<label for="login">Login</label>
</td>
<td>
<input type="hidden" value="newUser" name="todo">
<input name="login" type="text" maxlength="70" required size="9" id="login" class="form-control">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password">Mot de Passe</label>
</td>
<td style="border: none; text-align: left;">
<input name="password" type="password" maxlength="70" required size="9" class="form-control" id="password">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password_confirm">Confirmation du Mot de Passe</label>
</td>
<td style="border: none; text-align: left;">
<input name="password_confirm" type="password" maxlength="70" required size="9" id="cpswd_con" class="form-control" id="password_confirm">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="fullname">Nom complet</label>
</td>
<td><input name="fullname" type="text" maxlength="70" required size="9" class="form-control" id="fullname"></td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="email">Email</label>
</td>
<td><input name="email" type="email" maxlength="254" required size="9" class="form-control" id="email"></td>
</tr>
</table>
</div>
<div class="modal-footer">
<input type="submit" value="Add" name="action" class="btn btn-success">
<input type="reset" value="Cancel" name="action" class="btn btn-danger" data-dismiss="modal">
</div>
</div>
</div>
</div>
</form>
\ No newline at end of file
<div style="width: 33%; margin-left: auto; margin-right: auto;"><button class="btn btn-success" data-toggle="modal" data-target="#myModal">Ajouter un Utilisateur</button></div>
<form action="{{ url_for('admin_user') }}" method=POST>
<div style="display: none;" class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="divue">×</button>
<h4 class="modal-title" id="myModalLabel">Ajouter un utilisateur</h4>
</div>
<div class="modal-body" style="display: inline-block; width: 100%;">
<table id="userMod">
<tr>
<td style="border: none; text-align: left;">
<label for="login">Login</label>
</td>
<td>
<input type="hidden" value="newUser" name="todo">
<input name="login" type="text" maxlength="70" required size="9" id="login" class="form-control">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password">Mot de Passe</label>
</td>
<td style="border: none; text-align: left;">
<input name="password" type="password" maxlength="70" required size="9" class="form-control" id="password">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password_confirm">Confirmation du Mot de Passe</label>
</td>
<td style="border: none; text-align: left;">
<input name="password_confirm" type="password" maxlength="70" required size="9" id="cpswd_con" class="form-control" id="password_confirm">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="fullname">Nom complet</label>
</td>
<td><input name="fullname" type="text" maxlength="70" required size="9" class="form-control" id="fullname"></td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="email">Email</label>
</td>
<td><input name="email" type="email" maxlength="254" required size="9" class="form-control" id="email"></td>
</tr>
</table>
</div>
<div class="modal-footer">
<input type="submit" value="Add" name="action" class="btn btn-success">
<input type="reset" value="Cancel" name="action" class="btn btn-danger" data-dismiss="modal">
</div>
</div>
</div>
</div>
</form>
\ No newline at end of file
<div style="width: 33%; margin-left: auto; margin-right: auto;"><button class="btn btn-success" data-toggle="modal" data-target="#myModal">Ajouter un Utilisateur</button></div>
<form action="{{ url_for('admin_user') }}" method=POST>
<div style="display: none;" class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="divue">×</button>
<h4 class="modal-title" id="myModalLabel">Ajouter un utilisateur</h4>
</div>
<div class="modal-body" style="display: inline-block; width: 100%;">
<table id="userMod">
<tr>
<td style="border: none; text-align: left;">
<label for="login">Login</label>
</td>
<td>
<input type="hidden" value="newUser" name="todo">
<input name="login" type="text" maxlength="70" required size="9" id="login" class="form-control">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password">Mot de Passe</label>
</td>
<td style="border: none; text-align: left;">
<input name="password" type="password" maxlength="70" required size="9" class="form-control" id="password">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password_confirm">Confirmation du Mot de Passe</label>
</td>
<td style="border: none; text-align: left;">
<input name="password_confirm" type="password" maxlength="70" required size="9" id="cpswd_con" class="form-control" id="password_confirm">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="fullname">Nom complet</label>
</td>
<td><input name="fullname" type="text" maxlength="70" required size="9" class="form-control" id="fullname"></td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="email">Email</label>
</td>
<td><input name="email" type="email" maxlength="254" required size="9" class="form-control" id="email"></td>
</tr>
</table>
</div>
<div class="modal-footer">
<input type="submit" value="Add" name="action" class="btn btn-success">
<input type="reset" value="Cancel" name="action" class="btn btn-danger" data-dismiss="modal">
</div>
</div>
</div>
</div>
</form>
\ No newline at end of file
{% extends "base.html" %}
{% block content %}
<h1>Modifier un utilisateur</h1>
<div style="margin-left: auto; margin-right: auto; width: 60%;">
<form action="{{ url_for('admin_user') }}" method=POST>
<table id="userMod">
<tr>
<td colspan="2">
<h1>Informations</h1>
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="login">Login</label>
</td>
<td>
<input type="hidden" value="editUser" name="todo">
<input name="login" type="text" maxlength="70" size="9" id="login" class="form-control" value="{{ user.login }}">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password">Mot de Passe</label>
</td>
<td>
<input name="password" type="password" maxlength="70" size="9" class="form-control" id="password">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="password_confirm">Confirmation du Mot de Passe</label>
</td>
<td>
<input name="password_confirm" type="password" maxlength="70" size="9" id="cpswd_con" class="form-control" id="password_confirm">
</td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="fullname">Nom complet</label>
</td>
<td><input name="fullname" type="text" maxlength="70" size="9" class="form-control" id="fullname" value="{{ user.fullname }}"></td>
</tr>
<tr>
<td style="border: none; text-align: left;">
<label for="email">Email</label>
</td>
<td><input name="email" type="email" maxlength="254" size="9" class="form-control" id="email" value="{{ user.email }}"></td>
</tr>
<tr>
<td colspan="2">
<h1>Permissions :</h1>
</td>
</tr>
<tr>
<td>
<label for="can_view_admin">Administrateur ?</label>
</td>
<td>
<input type="checkbox" data-toggle="toggle" id="can_view_admin" name="can_view_admin" {% if user.can_view_admin %} checked {% endif %}>
</td>
</tr>
<tr>
<td>
<label for="enabled">Enabled ?</label>
</td>
<td>
<input type="checkbox" data-toggle="toggle" id="enabled" name="enabled" {% if user.can_use_plex %} checked {% endif %}>
</td>
</tr>
</table>
<input type="hidden" value="{{ user.id }}" name="id">
<input type="submit" value="Save" name="action" class="btn btn-success">
<input type="submit" value="Cancel" name="action" class="btn btn-danger" data-dismiss="modal">
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block content %}
{% if session['can_view_admin'] == 'True' %}
{% include 'Admin/Edit/adminAddVM.html' %}
<table class="table table-striped table-bordered table-hover" id="t_users">
<thead>
<tr>
<th>User</th>
<th>VM</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for link in links %}
<tr>
<td>
{{ link.login }}
</td>
<td>{{ link.token }}</td>
<td>
<table style="border: none;">
<tr style="border: none;">
<td style="border: none;">
<form action="{{ url_for('admin_vm') }}" method=POST>
<input type="hidden" value="edit" name="todo">
<input type="hidden" value="{{ link.id }}" name="id">
<input type="submit" value="Edit" name="action" class="btn btn-primary">
</form>
</td>
<td style="border: none;">
<form action="{{ url_for('admin_vm') }}" method=POST>
<input type="hidden" value="edit" name="todo">
<input type="hidden" value="{{ link.id }}" name="id">
<input type="submit" value="Delete" name="action" class="btn btn-danger">
</form>
</td>
</tr>
</table>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script>
$(document).ready(function() {
$('#t_users').DataTable({
responsive: true
});
});
</script>
{% endif %}
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block content %}
{% if session['can_view_admin'] == 'True' %}
{% include 'Admin/Edit/adminAddUser.html' %}
<table class="table table-striped table-bordered table-hover" id="t_users">
<thead>
<tr>
<th>Login</th>
<th>Nom complet</th>
<th>Email</th>
<th>Permissions</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users%}
<tr>
<td>
{{ user.login }}
</td>
<td>{{ user.fullname }}</td>
<td>{{ user.email }}</td>
<td>
<table style="border: none;">
<tr style="border: none;">
<td style="border: none; text-align: right;">Admin</td><td style="border: none;"> : </td>
{% if user.can_view_admin %}
<td style="border: none;"><i class="fa fa-check fa-fw"></td>
{% else %}
<td style="border: none;"><i class="fa fa-times fa-fw"></td>
{% endif %}
<td style="border: none; text-align: right;">Enabled</td><td style="border: none;"> : </td>
{% if user.enabled %}
<td style="border: none;"><i class="fa fa-check fa-fw"></td>
{% else %}
<td style="border: none;"><i class="fa fa-times fa-fw"></td>
{% endif %}
</tr>
</table>
</td>
<td>
<table style="border: none;">
<tr style="border: none;">
<td style="border: none;">
<form action="{{ url_for('admin_user') }}" method=POST>
<input type="hidden" value="editUser" name="todo">
<input type="hidden" value="{{ user.id }}" name="id">
<input type="submit" value="Edit" name="action" class="btn btn-primary">
</form>
</td>
<td style="border: none;">
<form action="{{ url_for('admin_user') }}" method=POST>
<input type="hidden" value="editUser" name="todo">
<input type="hidden" value="{{ user.id }}" name="id">
<input type="submit" value="Delete" name="action" class="btn btn-danger">
</form>
</td>
</tr>
</table>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script>
$(document).ready(function() {
$('#t_users').DataTable({
responsive: true
});
});
</script>
{% endif %}
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block content %}
{% if session['can_view_admin'] == 'True' %}
{% include 'Admin/Edit/adminAddVM.html' %}
<table class="table table-striped table-bordered table-hover" id="t_users">
<thead>
<tr>
<th>Token</th>
<th>IP</th>
<th>Enabled</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for vm in vms%}
<tr>
<td>
{{ vm.token }}
</td>
<td>{{ vm.ip }}</td>
{% if vm.enabled %}
<td><i class="fa fa-check fa-fw"></i></td>
{% else %}
<td><i class="fa fa-times fa-fw"></i></td>
{% endif %}
<td>
<table style="border: none;">
<tr style="border: none;">
<td style="border: none;">
<form action="{{ url_for('admin_vm') }}" method=POST>
<input type="hidden" value="edit" name="todo">
<input type="hidden" value="{{ vm.id }}" name="id">
<input type="submit" value="Edit" name="action" class="btn btn-primary">
</form>
</td>
<td style="border: none;">
<form action="{{ url_for('admin_vm') }}" method=POST>
<input type="hidden" value="edit" name="todo">
<input type="hidden" value="{{ vm.id }}" name="id">
<input type="submit" value="Delete" name="action" class="btn btn-danger">
</form>
</td>
</tr>
</table>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script>
$(document).ready(function() {
$('#t_users').DataTable({
responsive: true
});
});
</script>
{% endif %}
{% endblock %}
\ No newline at end of file
<li>
<a href="{{ url_for('classroom') }}">
<i class="fa fa-hdd-o fa-fw fa-2x"></i> Start
<i class="fa fa-play-circle-o fa-fw fa-2x"></i> Start
</a>
</li>
\ No newline at end of file
</li>
{% if session['can_view_admin'] == 'True' %}
<li>
<a href="{{ url_for('admin_user') }}">
<i class="fa fa-user fa-fw fa-2x"></i> Users
</a>
</li>
<li>
<a href="{{ url_for('admin_vm') }}">
<i class="fa fa-hdd-o fa-fw fa-2x"></i> Vms
</a>
</li>
<li>
<a href="{{ url_for('admin_link') }}">
<i class="fa fa-link fa-fw fa-2x"></i> Link
</a>
</li>
{% endif %}
\ No newline at end of file
Supports Markdown
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