Skip to content

Commit

Permalink
Add prompt bypass option for bulk-add-officers command
Browse files Browse the repository at this point in the history
  • Loading branch information
AetherUnbound committed Jun 26, 2024
1 parent f67dcb6 commit b126c39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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

0 comments on commit b126c39

Please sign in to comment.