Skip to content

Commit

Permalink
Apparently, APPLICATION_ROOT does something.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlouie committed May 24, 2020
1 parent 4c88afb commit 8fa36b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_form(id, requirement_code):
app.config.root_path = app.instance_path
app.config.from_pyfile('config.py', silent=True)

conn.add_api('api.yml', base_path=app.config['BASE_HREF'] + 'pb')
conn.add_api('api.yml', base_path='/pb')
db = SQLAlchemy(app)
migrate = Migrate(app, db)
ma = Marshmallow(app)
Expand Down Expand Up @@ -83,7 +83,7 @@ def has_no_empty_params(rule):
return len(defaults) >= len(arguments)


@app.route(app.config['BASE_HREF'] + '/site_map')
@app.route('/site_map')
def site_map():
links = []
for rule in app.url_map.iter_rules():
Expand All @@ -103,15 +103,15 @@ def site_map():
StudyDetails, StudyDetailsSchema


@app.route(app.config['BASE_HREF'] + '/', methods=['GET', 'POST'])
@app.route('/', methods=['GET', 'POST'])
def index():
# display results
studies = db.session.query(Study).order_by(Study.DATE_MODIFIED.desc()).all()
table = StudyTable(studies)
return render_template('index.html', table=table, BASE_HREF=app.config['BASE_HREF'])
return render_template('index.html', table=table, APPLICATION_ROOT=app.config['APPLICATION_ROOT'])


@app.route(app.config['BASE_HREF'] + '/new_study', methods=['GET', 'POST'])
@app.route('/new_study', methods=['GET', 'POST'])
def new_study():
form = StudyForm(request.form)
action = "/new_study"
Expand All @@ -129,7 +129,7 @@ def new_study():
description_map=description_map)


@app.route(app.config['BASE_HREF'] + '/study/<study_id>', methods=['GET', 'POST'])
@app.route('/study/<study_id>', methods=['GET', 'POST'])
def edit_study(study_id):
study = db.session.query(Study).filter(Study.STUDYID == study_id).first()
form = StudyForm(request.form, obj=study)
Expand All @@ -150,7 +150,7 @@ def edit_study(study_id):
description_map={})


@app.route(app.config['BASE_HREF'] + '/investigator/<study_id>', methods=['GET', 'POST'])
@app.route('/investigator/<study_id>', methods=['GET', 'POST'])
def new_investigator(study_id):
form = InvestigatorForm(request.form)
action = "/investigator/" + study_id
Expand All @@ -170,14 +170,14 @@ def new_investigator(study_id):
description_map={})


@app.route(app.config['BASE_HREF'] + '/del_investigator/<inv_id>', methods=['GET'])
@app.route('/del_investigator/<inv_id>', methods=['GET'])
def del_investigator(inv_id):
db.session.query(Investigator).filter(Investigator.id == inv_id).delete()
db.session.commit()
return redirect('/')


@app.route(app.config['BASE_HREF'] + '/del_study/<study_id>', methods=['GET'])
@app.route('/del_study/<study_id>', methods=['GET'])
def del_study(study_id):
db.session.query(RequiredDocument).filter(RequiredDocument.STUDYID == study_id).delete()
db.session.query(Investigator).filter(Investigator.STUDYID == study_id).delete()
Expand Down Expand Up @@ -212,7 +212,7 @@ def _update_study(study, form):
db.session.commit()


@app.route(app.config['BASE_HREF'] + '/study_details/<study_id>', methods=['GET', 'POST'])
@app.route('/study_details/<study_id>', methods=['GET', 'POST'])
def study_details(study_id):
study_details = db.session.query(StudyDetails).filter(StudyDetails.STUDYID == study_id).first()
if not study_details:
Expand Down
4 changes: 2 additions & 2 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
TESTING = environ.get('TESTING', default="false") == "true"

# Add trailing slash to base path
BASE_HREF = re.sub(r'//', '/', '/%s/' % environ.get('BASE_HREF', default="/").strip('/'))
APPLICATION_ROOT = re.sub(r'//', '/', '/%s/' % environ.get('APPLICATION_ROOT', default="/").strip('/'))

DB_HOST = environ.get('DB_HOST', default="localhost")
DB_PORT = environ.get('DB_PORT', default="5432")
Expand All @@ -28,4 +28,4 @@
print('DB_HOST = ', DB_HOST)
print('DEVELOPMENT = ', DEVELOPMENT)
print('TESTING = ', TESTING)
print('BASE_HREF = ', BASE_HREF)
print('APPLICATION_ROOT = ', APPLICATION_ROOT)
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Protocol Builder Mock</title>
<base href="{{ BASE_HREF }}">
<base href="{{ APPLICATION_ROOT }}">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://use.typekit.net/kwp6dli.css">
{% assets 'app_scss' %}
Expand Down

0 comments on commit 8fa36b9

Please sign in to comment.