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

Add prompt bypass option for bulk-add-officers command #468

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 14 additions & 3 deletions OpenOversight/app/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,17 @@ def process_salary(row, officer, compare=False):
is_flag=True,
help="allow updating normally-static fields like race, birth year, etc.",
)
@click.option(
"--yes",
"-y",
"bypass_prompt",
is_flag=True,
help="bypass the user prompt and immediately add the officers to the database",
)
@with_appcontext
def bulk_add_officers(filename, no_create, update_by_name, update_static_fields):
def bulk_add_officers(
filename, no_create, update_by_name, update_static_fields, bypass_prompt
):
"""Add or update officers from a CSV file."""

encoding = ENCODING_UTF_8
Expand Down Expand Up @@ -551,8 +560,10 @@ def bulk_add_officers(filename, no_create, update_by_name, update_static_fields)
create_officer_from_row(row, department_id)

ImportLog.print_logs()
if current_app.config["ENV"] == "testing" or prompt_yes_no(
"Do you want to commit the above changes?"
if (
current_app.config["ENV"] == "testing"
or bypass_prompt
or prompt_yes_no("Do you want to commit the above changes?")
):
print("Commiting changes.")
db.session.commit()
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fresh-start: dotenv
{{ RUN_WEB }} python create_db.py
{{ RUN_WEB }} flask make-admin-user
{{ RUN_WEB }} flask add-department "Seattle Police Department" "SPD" "WA"
{{ RUN_WEB }} flask bulk-add-officers /data/init_data.csv
{{ RUN_WEB }} flask bulk-add-officers -y /data/init_data.csv

# Start containers
@just up
Expand Down