Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invoke script using dev DB in non-dev #142

Merged
merged 39 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
53a5c2f
Update script to remove old container
rmarow Sep 14, 2023
9cfae4a
Comment out where environment variables were being set unintentionally
rmarow Sep 15, 2023
ecaa06c
Linting
rmarow Sep 15, 2023
da5d4a7
Add envs to mypy function
rmarow Sep 15, 2023
0e8fc1b
Update envarrs to not be hacky
rmarow Sep 15, 2023
fc8e0d5
part 1 setting up blueprint
rmarow Sep 18, 2023
d018d8e
WIP #2 adding application factory
rmarow Sep 18, 2023
c017dbe
Fix circular import issue
rmarow Sep 18, 2023
ce8dbf6
fix blueprint
rmarow Sep 18, 2023
f29779e
remove unused import
rmarow Sep 18, 2023
3b20204
TEMPORARY resolve `app` errors - need to figure out true solution
rmarow Sep 18, 2023
cca5a3f
WIP different blueprint for responses
rmarow Sep 18, 2023
1b8deea
WIP continue `response` blueprint update
rmarow Sep 18, 2023
82a1891
WIP able to startup app, still getting a blueprint error
rmarow Sep 19, 2023
43913df
Remove prefix from route
rmarow Sep 19, 2023
af2192a
Fix import
rmarow Sep 19, 2023
97b1451
WIP - current blocker is login manager
rmarow Sep 19, 2023
724c533
LoginManager
rmarow Sep 19, 2023
90e69b4
Login manager working
rmarow Sep 19, 2023
e619c6f
Login blueprint
rmarow Sep 19, 2023
471175a
Add survey blueprint and remove `app` from user.py
rmarow Sep 19, 2023
f018cbc
Update task/db to use create_app function
rmarow Sep 19, 2023
e6304f6
Import login_bp
rmarow Sep 19, 2023
f929ee9
Attempt at getting login working - not successful
rmarow Sep 20, 2023
e9e563f
Temporarily remove ability to bypass googleSSO
rmarow Sep 20, 2023
5a7ebfc
Remove unused `app` in this file
rmarow Sep 20, 2023
92e2738
Fix login related error and call current_app as recommended by docs
rmarow Sep 21, 2023
25241bd
Add logout blueprint
rmarow Sep 21, 2023
d7c50cb
Update users template to include blueprint
rmarow Sep 21, 2023
53a5177
Add survey blueprint to redirect url
rmarow Sep 21, 2023
376c23e
Add response blueprint
rmarow Sep 21, 2023
ac3fcf0
Start adding response blueprint - response sub pages need their own bp
rmarow Sep 21, 2023
1b1e101
view surveys blueprint
rmarow Sep 21, 2023
af5ca07
remove breakpoint
rmarow Sep 25, 2023
af48db0
Add comments regarding issue #144
rmarow Sep 25, 2023
714e8bf
Merge branch 'non-dev-db-issue' of github.com:nsidc/usaon-vta-survey …
rmarow Sep 25, 2023
4a3113a
Group blueprint imports together to reduce additional spacing
rmarow Sep 25, 2023
1e52cd0
Update path
rmarow Sep 28, 2023
b9bd638
Adding blueprints
rmarow Sep 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions usaon_vta_survey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ def before_request():
if time.time() >= token['expires_at']:
del s['google_oauth_token']

from usaon_vta_survey.routes import response
from usaon_vta_survey.routes.google import blueprint
from usaon_vta_survey.routes.login import login_bp
from usaon_vta_survey.routes.logout import logout_bp
from usaon_vta_survey.routes.response import bp
from usaon_vta_survey.routes.response.applications import application_bp
from usaon_vta_survey.routes.response.data_products import dp_bp
from usaon_vta_survey.routes.response.observing_systems import obs_bp
from usaon_vta_survey.routes.response.sbas import sba_bp
from usaon_vta_survey.routes.root import root_bp
from usaon_vta_survey.routes.survey import survey_bp
from usaon_vta_survey.routes.surveys import surveys_bp
Expand All @@ -81,7 +85,11 @@ def before_request():
app.register_blueprint(login_bp)
app.register_blueprint(logout_bp)
app.register_blueprint(blueprint, url_prefix="/google_oauth")
app.register_blueprint(response.bp)
app.register_blueprint(bp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmarow bp here is hard to read. What about response_bp?

I feel obs_bp and dp_bp would also be more readable spelling out the words.

app.register_blueprint(obs_bp)
app.register_blueprint(sba_bp)
app.register_blueprint(application_bp)
app.register_blueprint(dp_bp)

app.jinja_env.globals.update(sqla_inspect=sqla_inspect, __version__=__version__)

Expand Down
9 changes: 6 additions & 3 deletions usaon_vta_survey/routes/response/applications.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from flask import redirect, render_template, request, url_for
from flask import Blueprint, redirect, render_template, request, url_for

from usaon_vta_survey import db
from usaon_vta_survey.forms import FORMS_BY_MODEL
from usaon_vta_survey.models.tables import ResponseApplication, Survey
from usaon_vta_survey.routes.response import bp
from usaon_vta_survey.util.authorization import limit_response_editors
from usaon_vta_survey.util.sankey import applications_sankey

application_bp = Blueprint(
'application', __name__, url_prefix='/response/<string:survey_id>/applications'
)

@bp.route('/<string:survey_id>/applications', methods=['GET', 'POST'])

@application_bp.route('', methods=['GET', 'POST'])
def view_response_applications(survey_id: str):
"""View and add to applications associated with a response."""
Form = FORMS_BY_MODEL[ResponseApplication]
Expand Down
9 changes: 6 additions & 3 deletions usaon_vta_survey/routes/response/data_products.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from flask import redirect, render_template, request, url_for
from flask import Blueprint, redirect, render_template, request, url_for

from usaon_vta_survey import db
from usaon_vta_survey.forms import FORMS_BY_MODEL
from usaon_vta_survey.models.tables import ResponseDataProduct, Survey
from usaon_vta_survey.routes.response import bp
from usaon_vta_survey.util.authorization import limit_response_editors

dp_bp = Blueprint(
'data_product', __name__, url_prefix='/response/<string:survey_id>/data_products'
)

@bp.route('/<string:survey_id>/data_products', methods=['GET', 'POST'])

@dp_bp.route('', methods=['GET', 'POST'])
def view_response_data_products(survey_id: str):
"""View and add to data products associated with a response."""
Form = FORMS_BY_MODEL[ResponseDataProduct]
Expand Down
9 changes: 6 additions & 3 deletions usaon_vta_survey/routes/response/observing_systems.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from flask import redirect, render_template, request, url_for
from flask import Blueprint, redirect, render_template, request, url_for

from usaon_vta_survey import db
from usaon_vta_survey._types import ObservingSystemType
from usaon_vta_survey.forms import FORMS_BY_MODEL
from usaon_vta_survey.models.tables import ResponseObservingSystem, Survey
from usaon_vta_survey.routes.response import bp
from usaon_vta_survey.util.authorization import limit_response_editors

obs_bp = Blueprint(
'obs', __name__, url_prefix='/response/<string:survey_id>/observing_systems'
)

@bp.route('/<string:survey_id>/observing_systems', methods=['GET', 'POST'])

@obs_bp.route('', methods=['GET', 'POST'])
def view_response_observing_systems(survey_id: str):
"""View and add to observing systems associated with a response."""
Form = FORMS_BY_MODEL[ResponseObservingSystem]
Expand Down
9 changes: 6 additions & 3 deletions usaon_vta_survey/routes/response/sbas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import redirect, render_template, request, url_for
from flask import Blueprint, redirect, render_template, request, url_for

from usaon_vta_survey import db
from usaon_vta_survey.forms import FORMS_BY_MODEL
Expand All @@ -7,11 +7,14 @@
SocietalBenefitArea,
Survey,
)
from usaon_vta_survey.routes.response import bp
from usaon_vta_survey.util.authorization import limit_response_editors

sba_bp = Blueprint(
'sba', __name__, url_prefix='/response/<string:survey_id>/societal_benefit_areas'
)


@bp.route('/<string:survey_id>/societal_benefit_areas', methods=['GET', 'POST'])
@sba_bp.route('', methods=['GET', 'POST'])
def view_response_sbas(survey_id: str):
"""View and add to observing systems associated with a response."""
sbas = SocietalBenefitArea.query.all()
Expand Down
8 changes: 4 additions & 4 deletions usaon_vta_survey/templates/response/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ <h2>{% block title %}Response to: {{survey.title}}{% endblock %}</h1>
</li>

<li>
<a href="{{url_for('view_response_observing_systems', survey_id=survey.id)}}">
<a href="{{url_for('obs.view_response_observing_systems', survey_id=survey.id)}}">
Observing systems ({{survey.response.observing_systems | length}})
</a>
</li>

<li>
<a href="{{url_for('view_response_data_products', survey_id=survey.id)}}">
<a href="{{url_for('data_product.view_response_data_products', survey_id=survey.id)}}">
Data products ({{survey.response.data_products | length}})
</a>
</li>

<li>
<a href="{{url_for('view_response_applications', survey_id=survey.id)}}">
<a href="{{url_for('application.view_response_applications', survey_id=survey.id)}}">
Applications ({{survey.response.applications | length}})
</a>
</li>

<li>
<a href="{{url_for('view_response_sbas', survey_id=survey.id)}}">
<a href="{{url_for('sba.view_response_sbas', survey_id=survey.id)}}">
Societal Benefit Areas ({{survey.response.societal_benefit_areas | length}})
</a>
</li>
Expand Down