parent
31ce97cb44
commit
6697c60c7f
@ -0,0 +1,66 @@
|
|||||||
|
"""Changed user<->institution<->corpus relational mapping.
|
||||||
|
|
||||||
|
Revision ID: 5ba116fc7f06
|
||||||
|
Revises: 7d6db184b8fc
|
||||||
|
Create Date: 2021-06-07 13:02:42.900168
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '5ba116fc7f06'
|
||||||
|
down_revision = '7d6db184b8fc'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('institution_contract',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('institution', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('corpus', sa.String(), nullable=False),
|
||||||
|
sa.Column('timestamp', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('file_contract', sa.String(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['institution'], ['institution.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('user_institution_mapping',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('user', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('institution', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('role', sa.String(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['institution'], ['institution.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['user'], ['registered_user.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.add_column('corpus_access', sa.Column('institution', sa.Integer(), nullable=False))
|
||||||
|
op.drop_constraint('user_id_fkey', 'corpus_access', type_='foreignkey')
|
||||||
|
op.create_foreign_key(None, 'corpus_access', 'institution', ['institution'], ['id'])
|
||||||
|
op.drop_column('corpus_access', 'user_id')
|
||||||
|
op.create_unique_constraint(None, 'institution', ['name'])
|
||||||
|
op.drop_column('institution', 'file_contract')
|
||||||
|
op.create_unique_constraint(None, 'registered_user', ['email'])
|
||||||
|
op.drop_constraint('registered_user_institution_fkey', 'registered_user', type_='foreignkey')
|
||||||
|
op.drop_column('registered_user', 'institution_moderator')
|
||||||
|
op.drop_column('registered_user', 'institution')
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('registered_user', sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||||
|
op.add_column('registered_user', sa.Column('institution_moderator', sa.BOOLEAN(), autoincrement=False, nullable=True))
|
||||||
|
op.create_foreign_key('registered_user_institution_fkey', 'registered_user', 'institution', ['institution'], ['id'])
|
||||||
|
op.drop_constraint(None, 'registered_user', type_='unique')
|
||||||
|
op.add_column('institution', sa.Column('file_contract', sa.TEXT(), autoincrement=False, nullable=True))
|
||||||
|
op.drop_constraint(None, 'institution', type_='unique')
|
||||||
|
op.add_column('corpus_access', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False))
|
||||||
|
op.drop_constraint(None, 'corpus_access', type_='foreignkey')
|
||||||
|
op.create_foreign_key('user_id_fkey', 'corpus_access', 'registered_user', ['user_id'], ['id'])
|
||||||
|
op.drop_column('corpus_access', 'institution')
|
||||||
|
op.drop_table('user_institution_mapping')
|
||||||
|
op.drop_table('institution_contract')
|
||||||
|
# ### end Alembic commands ###
|
@ -0,0 +1,110 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Admin panel - Šolar</title>
|
||||||
|
<style>
|
||||||
|
.tableFixHead {
|
||||||
|
overflow-y: auto;
|
||||||
|
height: 106px;
|
||||||
|
}
|
||||||
|
.tableFixHead thead th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Uporabniki</h2>
|
||||||
|
<h3>Dodaj uporabnika</h3>
|
||||||
|
<form action="/solar/adduser" method="post">
|
||||||
|
<label for="name">Ime in priimek:</label><br>
|
||||||
|
<input type="text" id="name" name="name"><br>
|
||||||
|
<label for="email">Email:</label><br>
|
||||||
|
<input type="text" id="email" name="email"><br>
|
||||||
|
<label for="password">Geslo:</label><br>
|
||||||
|
<input type="text" id="password" name="password"><br>
|
||||||
|
<input type="submit" value="Dodaj">
|
||||||
|
</form>
|
||||||
|
<!--<h3>Odstrani uporabnika</h3>
|
||||||
|
<form action="/solar/deluser" method="post">
|
||||||
|
<label for="user_id">ID uporabnika:</label><br>
|
||||||
|
<input type="text" id="user_id" name="user_id"><br>
|
||||||
|
<input type="submit" value="Odstrani">
|
||||||
|
</form>-->
|
||||||
|
<h3>Seznam vseh aktivnih uporabnikov</h3>
|
||||||
|
<div class="tableFixHead">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Ime in priimek</th>
|
||||||
|
<th>Email</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in users %}
|
||||||
|
<tr>
|
||||||
|
<td>{{item.id}}</td>
|
||||||
|
<td>{{item.name}}</td>
|
||||||
|
<td>{{item.email}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<h3>Dodeli uporabnika instituciji</h3>
|
||||||
|
<form action="/solar/addusertoinstitution" method="post">
|
||||||
|
<label for="user_id">ID uporabnika:</label>
|
||||||
|
<input type="text" id="user_id" name="user_id"><br>
|
||||||
|
<label for="institution_id">ID institucije:</label>
|
||||||
|
<input type="text" id="institution_id" name="institution_id"><br>
|
||||||
|
<label for="role">Vloga v instituciji:</label>
|
||||||
|
<select name="role" id="role">
|
||||||
|
<option value="moderator">Moderator</option>
|
||||||
|
<option value="user">Uporabnik</option>
|
||||||
|
</select>
|
||||||
|
<input type="submit" value="Dodeli">
|
||||||
|
</form>
|
||||||
|
<div> </div>
|
||||||
|
<h2>Institucije</h2>
|
||||||
|
<h3>Dodaj institucijo</h3>
|
||||||
|
<form action="/solar/addinstitution" method="post">
|
||||||
|
<label for="name">Naziv:</label>
|
||||||
|
<input type="text" id="name" name="name"><br>
|
||||||
|
<label for="region">Regija:</label>
|
||||||
|
<input type="text" id="region" name="region"><br>
|
||||||
|
<input type="submit" value="Dodaj">
|
||||||
|
</form>
|
||||||
|
<h3>Seznam vseh instituticij</h3>
|
||||||
|
<div class="tableFixHead">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Naziv</th>
|
||||||
|
<th>Regija</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in institutions %}
|
||||||
|
<tr>
|
||||||
|
<td>{{item.id}}</td>
|
||||||
|
<td>{{item.name}}</td>
|
||||||
|
<td>{{item.region}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Admin panel - Šolar</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>Uporabniki</h3>
|
||||||
|
TODO: odobri registracije
|
||||||
|
<form> </form>
|
||||||
|
<div> </div>
|
||||||
|
|
||||||
|
</body>
|
Loading…
Reference in new issue