Juni Kim
2 years ago
6 changed files with 238 additions and 32 deletions
-
105app.py
-
51migrations/versions/282564545160_changed_user_schema.py
-
51templates/account_edit.html
-
34templates/account_view.html
-
4templates/base.html
-
21templates/register.html
@ -0,0 +1,51 @@ |
|||
"""changed user schema |
|||
|
|||
Revision ID: 282564545160 |
|||
Revises: 1a0a82192181 |
|||
Create Date: 2023-05-20 16:07:52.967576 |
|||
|
|||
""" |
|||
from alembic import op |
|||
import sqlalchemy as sa |
|||
|
|||
|
|||
# revision identifiers, used by Alembic. |
|||
revision = '282564545160' |
|||
down_revision = '1a0a82192181' |
|||
branch_labels = None |
|||
depends_on = None |
|||
|
|||
|
|||
def upgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.create_table('user', |
|||
sa.Column('id', sa.Integer(), nullable=False), |
|||
sa.Column('username', sa.String(), nullable=False), |
|||
sa.Column('email', sa.String(), nullable=False), |
|||
sa.Column('name', sa.String(), nullable=False), |
|||
sa.Column('password', sa.String(), nullable=False), |
|||
sa.Column('institution', sa.String(), nullable=False), |
|||
sa.Column('position', sa.String(), nullable=False), |
|||
sa.Column('admin', sa.Boolean(), nullable=True), |
|||
sa.PrimaryKeyConstraint('id'), |
|||
sa.UniqueConstraint('email'), |
|||
sa.UniqueConstraint('institution'), |
|||
sa.UniqueConstraint('name'), |
|||
sa.UniqueConstraint('position'), |
|||
sa.UniqueConstraint('username') |
|||
) |
|||
op.drop_table('admin') |
|||
# ### end Alembic commands ### |
|||
|
|||
|
|||
def downgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.create_table('admin', |
|||
sa.Column('id', sa.INTEGER(), nullable=False), |
|||
sa.Column('username', sa.VARCHAR(), nullable=False), |
|||
sa.Column('password', sa.VARCHAR(), nullable=False), |
|||
sa.PrimaryKeyConstraint('id'), |
|||
sa.UniqueConstraint('username') |
|||
) |
|||
op.drop_table('user') |
|||
# ### end Alembic commands ### |
@ -0,0 +1,51 @@ |
|||
{% extends "base.html" %} |
|||
{% block content %} |
|||
<h1>Edit Account Profile</h1> |
|||
<table> |
|||
<tr> |
|||
<td>Id</td> |
|||
<td>{{user.id}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Username</td> |
|||
<td>{{user.username}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Admin</td> |
|||
<td>{% if user.admin %} Yes {% else %} False {% endif %}</td> |
|||
</tr> |
|||
</table> |
|||
<form method="post"> |
|||
|
|||
<label for="name">Name:</label> |
|||
<input id="name" name="name" type="text" required="required" |
|||
value="{{user.name | safe}}"> |
|||
<br> |
|||
|
|||
<label for="email">Email:</label> |
|||
<input id="email" name="email" type="text" required="required" |
|||
value="{{user.email | safe}}"> |
|||
<br> |
|||
|
|||
<label for="institution">Institution:</label> |
|||
<input id="institution" name="institution" type="text" |
|||
required="required" |
|||
value="{{user.institution | |
|||
safe}}"> |
|||
<br> |
|||
|
|||
<label for="position">Position:</label> |
|||
<input id="position" name="position" type="text" required="required" |
|||
value="{{user.position |
|||
| safe}}"> |
|||
<br> |
|||
|
|||
<br> |
|||
<input type="submit" value="Submit" id="submit"> |
|||
</form> |
|||
{% if success %} |
|||
<p style="color:darkgreen">Edits Successful!</p> |
|||
{% elif fail %} |
|||
<p style="color:darkred">Edits Failed. Please try again. {{fail}}</p> |
|||
{% endif %} |
|||
{% endblock %} |
@ -0,0 +1,34 @@ |
|||
{% extends "base.html" %} |
|||
{% block content %} |
|||
<h1>View User</h1> |
|||
<table> |
|||
<tr> |
|||
<td>Id</td> |
|||
<td>{{user.id}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Username</td> |
|||
<td>{{user.username | safe}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Admin</td> |
|||
<td>{% if user.admin %} Yes {% else %} False {% endif %}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Name</td> |
|||
<td>{{user.name | safe}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Email</td> |
|||
<td>{{user.email | safe}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Institution</td> |
|||
<td>{{user.institution | safe}}</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Position</td> |
|||
<td>{{user.position | safe}}</td> |
|||
</tr> |
|||
</table> |
|||
{% endblock %} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue