-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from SEL-Columbia/user-and-minigrid-list
Version 0.1.1
- Loading branch information
Showing
21 changed files
with
410 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
codecov | ||
fakeredis==0.8.1 | ||
flake8==3.2.1 | ||
pydocstyle==1.1.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block body %} | ||
{% if reason is not None %} | ||
<p><strong>Login unsuccessful: {{ reason }}</strong></p> | ||
{% end %} | ||
<form action="/" method="POST"> | ||
{% module xsrf_form_html() %} | ||
E-mail: <input type="email" name="email" /> | ||
<input type="submit" value="Log In" /> | ||
</form> | ||
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block body %} | ||
<p><a href="/users">Manage users »</a></p> | ||
<p>Minigrids:</p> | ||
<ul> | ||
{% for grid in minigrids %} | ||
<li> | ||
<p><a href="/minigrid/{{ grid.minigrid_id }}">{{ grid.name }} »</a></p> | ||
<p>Status: {{ grid.status }}</p> | ||
</li> | ||
{% end %} | ||
</ul> | ||
{% end %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block body %} | ||
<h1>Minigrid Name: {{ minigrid.name }}</h1> | ||
<p>ID: {{ minigrid.minigrid_id }}</p> | ||
<p>Day tariff: {{ minigrid.day_tariff }}</p> | ||
<p>Last update of day tariff: {{ minigrid.day_tariff_update_time }}</p> | ||
<p>Night tariff: {{ minigrid.night_tariff }}</p> | ||
<p>Last update of night tariff: {{ minigrid.night_tariff_update_time }}</p> | ||
<p>Error code: {{ minigrid.error_code }}</p> | ||
<p>Status: {{ minigrid.status }}</p> | ||
<footer><a href="/">« Return to minigrid index</a></footer> | ||
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block body %} | ||
<p>Users:</p> | ||
<ul> | ||
{% for user in users %} | ||
<li> | ||
<p><a href="mailto:{{ user.email }}">{{ user.email }}</a></p> | ||
</li> | ||
{% end %} | ||
</ul> | ||
<p>Add user account:</p> | ||
<form action="{{ request.uri }}" method="POST"> | ||
{% module xsrf_form_html() %} | ||
E-mail: <input type="email" name="email" /> | ||
<input type="submit" value="Add User" /> | ||
</form> | ||
{% if reason is not None %} | ||
<p><strong>Could not create user account: {{ reason }}</strong></p> | ||
{% end %} | ||
<footer><a href="/">« Return to minigrid index</a></footer> | ||
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
"""Create the initial administrator for the application.""" | ||
import argparse | ||
import os | ||
import sys | ||
from time import sleep | ||
|
||
from sqlalchemy import func | ||
from sqlalchemy.exc import OperationalError | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
sys.path.insert(1, os.path.join(sys.path[0], '..')) | ||
|
||
|
||
def main(): | ||
"""Supply the administrator's e-mail""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('email') | ||
args, others = parser.parse_known_args() | ||
from minigrid.options import parse_command_line | ||
parse_command_line([None] + others) | ||
from minigrid.options import options | ||
if not any(other.startswith('--db_schema=') for other in others): | ||
options.db_schema = 'minigrid' | ||
from minigrid import models | ||
engine = models.create_engine() | ||
session = sessionmaker(bind=engine)() | ||
try: | ||
users = session.query(func.count(models.User.user_id)).scalar() | ||
except OperationalError: | ||
print('Database connection failed... trying again in 5 seconds.') | ||
sleep(5) | ||
users = session.query(func.count(models.User.user_id)).scalar() | ||
if users: | ||
print('At least one user already exists. Log in as that user.') | ||
sys.exit(1) | ||
with session.begin_nested(): | ||
session.add(models.User(email=args.email)) | ||
print('Created initial user with e-mail', args.email) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.