-
Notifications
You must be signed in to change notification settings - Fork 79
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 state
to departments
table
#981
Merged
Merged
Changes from all commits
Commits
Show all changes
193 commits
Select commit
Hold shift + click to select a range
1913b2e
Update database.py
michplunkett f4b47f2
Create 2023-07-18-1616_33521389a38d_rename_star_date.py
michplunkett a87425a
Update alembic.ini
michplunkett 189c2a5
Update env.py
michplunkett c6b0c9a
Delete 2023-07-18-1616_33521389a38d_rename_star_date.py
michplunkett 65c7327
Create 2023-07-18-1717_9ce70d7ebd56_rename_star_date.py
michplunkett 80b2094
Update 2023-07-18-1717_9ce70d7ebd56_rename_star_date.py
michplunkett 15c837c
Update conftest.py
michplunkett 8dce36a
Update bulk_upload.rst
michplunkett bd994ff
Update downloads.py
michplunkett e7b0de0
Update forms.py
michplunkett b0edeab
Update officer_assignment_history.html
michplunkett a99e4d9
Update forms.py
michplunkett bc4a323
Update test_commands.py
michplunkett 7fc0486
Update commands.py
michplunkett b035d47
Update test_officer_and_department.py
michplunkett f7210a3
Update edit_assignment.html
michplunkett 4abffbd
Update csv_imports.py
michplunkett c2704df
Update database.py
michplunkett 86636a0
Update database_imports.py
michplunkett 7507f55
Update database.py
michplunkett 9aecce6
Create 2023-07-18-1921_eb0266dc8588_rename_descrip_to_description.py
michplunkett 1e3c0f2
Update 2023-07-18-1921_eb0266dc8588_rename_descrip_to_description.py
michplunkett e217271
Update test_utils.py
michplunkett 08fc13a
Update test_models.py
michplunkett 358e512
Update test_functional.py
michplunkett a5d3d9e
Update test_officer_and_department.py
michplunkett 94aa26f
Update conftest.py
michplunkett 9ff47ce
Update officer_assignment_history.html
michplunkett 86680d6
Update add_unit.html
michplunkett ec80755
Update views.py
michplunkett 2d0df19
Update forms.py
michplunkett d65077f
Update downloads.py
michplunkett d5dbc4f
Update csv_imports.py
michplunkett 374d47b
Update views.py
michplunkett eee34cc
Update test_functional.py
michplunkett e394434
Update forms.py
michplunkett 19496b9
Update db.py
michplunkett e6ea9fb
Update views.py
michplunkett afd7560
Update forms.py
michplunkett 9584bc1
Update list_officer.html
michplunkett 44cbfb6
Merge branch 'develop' into timestamp_to_timestamptz
michplunkett 1d0e5e3
Update database.py
michplunkett 648174a
Create 2023-07-18-2027_07ace5f956ca_standardize_datetime_field_names.py
michplunkett 27aa07d
Update 2023-07-18-2027_07ace5f956ca_standardize_datetime_field_names.py
michplunkett 901e5e9
Update test_notes.py
michplunkett d62d18d
Update test_descriptions.py
michplunkett 2cdaaa9
Update conftest.py
michplunkett cd18f92
Update forms.py
michplunkett 46a5501
Update test_notes.py
michplunkett 25a8021
Update test_descriptions.py
michplunkett 0baae9a
Update views.py
michplunkett 8913692
Update downloads.py
michplunkett 63c17d0
Update test_models.py
michplunkett 43964aa
Update cloud.py
michplunkett e4662d0
Update image.html
michplunkett 60ce77f
Update officer_notes.html
michplunkett 536044e
Update officer_descriptions.html
michplunkett c2bd06d
Update model_view.py
michplunkett de4bc5f
Merge branch 'develop' into timestamp_to_timestamptz
michplunkett a6f8cc5
Merge branch 'develop' into timestamp_to_timestamptz
michplunkett f2aa4ae
Update 2023-07-18-2027_07ace5f956ca_standardize_datetime_field_names.py
michplunkett df3097f
Update database.py
michplunkett 46f1d9f
Update downloads.py
michplunkett 0c61ec3
Update model_view.py
michplunkett de3416f
Update views.py
michplunkett 60bee9c
Update image.html
michplunkett cf2bdb5
Update forms.py
michplunkett 2071b1f
Update cloud.py
michplunkett 9b0053d
Update officer_notes.html
michplunkett 8725e99
Update officer_descriptions.html
michplunkett fa07a0d
Update conftest.py
michplunkett c96a376
Update test_descriptions.py
michplunkett 3fcc7cb
Update test_notes.py
michplunkett 636d45e
Update test_models.py
michplunkett 254cf2d
Update database.py
michplunkett af6233e
Update test_notes.py
michplunkett b6bebd4
Update test_descriptions.py
michplunkett eedc11b
Update CONTRIB.md
michplunkett b64f5e2
Update config.py
michplunkett d25a24e
Update docker-compose.yml
michplunkett 5dd16a4
Update docker-compose.yml
michplunkett d6927b6
Update database.py
michplunkett 1638cce
Create 2023-07-19-1638_1931b987ce0d_convert_timestamp_to_timestamptz.py
michplunkett 322f841
Update 2023-07-19-1638_1931b987ce0d_convert_timestamp_to_timestamptz.py
michplunkett f93c665
Update 2023-07-19-1638_1931b987ce0d_convert_timestamp_to_timestamptz.py
michplunkett 82ded97
use snake case
michplunkett ef4e718
Update requirements.txt
michplunkett 8bbcbba
Update database.py
michplunkett af0de50
Update 2023-07-19-1638_1931b987ce0d_convert_timestamp_to_timestamptz.py
michplunkett 2fc9168
Update 2023-07-19-1638_1931b987ce0d_convert_timestamp_to_timestamptz.py
michplunkett 7a1263b
Update config.py
michplunkett a0c0c4b
Update config.py
michplunkett 11dac91
Update general.py
michplunkett 3be0fed
Update views.py
michplunkett c0c690f
Update constants.py
michplunkett 156f2b4
Update config.py
michplunkett ca8fbe7
Update views.py
michplunkett 85f8919
Update base.html
michplunkett 6856a10
Update database.py
michplunkett 378a898
Update base.html
michplunkett 7e62358
Update general.py
michplunkett 5b18029
Update __init__.py
michplunkett f486f07
Update __init__.py
michplunkett ea73c91
Update general.py
michplunkett 451d131
Update views.py
michplunkett 1b69413
Create filters.py
michplunkett 1359a58
Update __init__.py
michplunkett 5d0fe5c
Update __init__.py
michplunkett 895de26
Revert "Update __init__.py"
michplunkett b64b94e
Update __init__.py
michplunkett 34ffc00
Update filters.py
michplunkett 13b9263
Update views.py
michplunkett 0731ffa
Update base.html
michplunkett ebac61d
Update filters.py
michplunkett 641749b
Update __init__.py
michplunkett befc4d6
Update filters.py
michplunkett 3b828c6
Update officer_notes.html
michplunkett ee380d5
Update officer_descriptions.html
michplunkett 946485b
Update image.html
michplunkett 42285fe
Update base.html
michplunkett 7ec6375
Update __init__.py
michplunkett f9f02b9
Update views.py
michplunkett c3130d9
Update filters.py
michplunkett 6d5f74d
Update filters.py
michplunkett a70dae1
Update filters.py
michplunkett f68e252
Update views.py
michplunkett 4c99ce6
Update base.html
michplunkett 5d8577e
Update test_other.py
michplunkett bb76e20
Update views.py
michplunkett 07f3c98
Update database.py
michplunkett b7a02ef
Create 2023-07-21-2058_eb854f312a3a_add_state_to_department.py
michplunkett 385dd76
Update constants.py
michplunkett 0d1f037
Update test_incidents.py
michplunkett 7677d03
Update database.py
michplunkett 318a553
Update 2023-07-21-2058_eb854f312a3a_add_state_to_department.py
michplunkett 27686b4
Update test_models.py
michplunkett 1d496c2
Update test_commands.py
michplunkett 5b64a06
Update conftest.py
michplunkett 12f6001
Update conftest.py
michplunkett 4dc5810
Update test_commands.py
michplunkett f7a5684
Update test_commands.py
michplunkett 84396d6
Update test_commands.py
michplunkett 87f277a
Update conftest.py
michplunkett ed27f8e
Update constants.py
michplunkett 6478ebf
Merge branch 'develop' into add_state_filtering
michplunkett 06bcff1
Update route_helpers.py
michplunkett e69522d
Update test_incidents.py
michplunkett fc96ebc
Merge branch 'develop' into add_state_filtering
michplunkett 0aade93
Update database.py
michplunkett 3d023fd
Take care of other .format strings
michplunkett a3d54a6
Merge branch 'develop' into add_state_filtering
michplunkett 34fc413
Update test_models.py
michplunkett 6848ce0
Update test_models.py
michplunkett c3a958d
Update test_models.py
michplunkett aae3f36
Update database.py
michplunkett 25f02fd
Update test_models.py
michplunkett 053bf5c
Update commands.py
michplunkett e59aa0d
Update test_commands.py
michplunkett 48b2be4
Update test_commands.py
michplunkett a3727de
Delete 2023-07-21-2058_eb854f312a3a_add_state_to_department.py
michplunkett 8aa3250
Update database.py
michplunkett abc0a2e
Update database.py
michplunkett 55daad4
Create 2023-07-25-2122_bce7c55b6d90_add_state_column_to_departments.py
michplunkett 1a3945f
Update 2023-07-25-2122_bce7c55b6d90_add_state_column_to_departments.py
michplunkett 2f1f01e
Update test_commands.py
michplunkett 69f19be
Update test_commands.py
michplunkett c58c224
Update conftest.py
michplunkett d95049c
Update test_commands.py
michplunkett 97c5416
Update commands.py
michplunkett f06a042
Update test_officer_and_department.py
michplunkett 060613a
csvs
michplunkett c0f22f0
Update commands.py
michplunkett 3d2403b
Update conftest.py
michplunkett 430899c
Update csv_imports.py
michplunkett cf734f0
Update test_commands.py
michplunkett 5d6f10e
Update test_commands.py
michplunkett 99b1c53
Update test_commands.py
michplunkett 7213477
PoliceDepartment class
michplunkett 3219610
Update test_utils.py
michplunkett 1c93ee4
Update test_commands.py
michplunkett 5a907b7
Update commands.py
michplunkett 3c2065f
Update test_commands.py
michplunkett ecfe526
Update test_utils.py
michplunkett 704fbf5
Update database.py
michplunkett 0f87cbb
Update test_models.py
michplunkett 93af8a7
Use fixture instance of faker
michplunkett 22dc467
Delete 2023-07-25-2122_bce7c55b6d90_add_state_column_to_departments.py
michplunkett 9a4cdef
Update database.py
michplunkett 9a32f0f
Create 2023-07-26-1551_18f43ac4622f_add_state_column_to_departments.py
michplunkett 1e53471
Update 2023-07-26-1551_18f43ac4622f_add_state_column_to_departments.py
michplunkett 9117aa4
Update commands.py
michplunkett b5a120c
Update advanced_csv_import.rst
michplunkett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -39,22 +39,26 @@ | |
class Department(BaseModel): | ||
__tablename__ = "departments" | ||
id = db.Column(db.Integer, primary_key=True) | ||
name = db.Column(db.String(255), index=True, unique=True, nullable=False) | ||
name = db.Column(db.String(255), index=False, unique=False, nullable=False) | ||
short_name = db.Column(db.String(100), unique=False, nullable=False) | ||
state = db.Column(db.String(2), server_default="", nullable=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's been set to |
||
|
||
# See https://github.com/lucyparsons/OpenOversight/issues/462 | ||
unique_internal_identifier_label = db.Column( | ||
db.String(100), unique=False, nullable=True | ||
) | ||
|
||
__table_args__ = (UniqueConstraint("name", "state", name="departments_name_state"),) | ||
|
||
def __repr__(self): | ||
return "<Department ID {}: {}>".format(self.id, self.name) | ||
return f"<Department ID {self.id}: {self.name} {self.state}>" | ||
|
||
def to_custom_dict(self): | ||
return { | ||
"id": self.id, | ||
"name": self.name, | ||
"short_name": self.short_name, | ||
"state": self.state, | ||
"unique_internal_identifier_label": self.unique_internal_identifier_label, | ||
} | ||
|
||
|
@@ -76,7 +80,7 @@ class Job(BaseModel): | |
) | ||
|
||
def __repr__(self): | ||
return "<Job ID {}: {}>".format(self.id, self.job_title) | ||
return f"<Job ID {self.id,}: {self.job_title}>" | ||
|
||
def __str__(self): | ||
return self.job_title | ||
|
@@ -164,16 +168,14 @@ def full_name(self): | |
else self.middle_initial | ||
) | ||
if self.suffix: | ||
return "{} {} {} {}".format( | ||
self.first_name, middle_initial, self.last_name, self.suffix | ||
return ( | ||
f"{self.first_name} {middle_initial} {self.last_name} {self.suffix}" | ||
) | ||
else: | ||
return "{} {} {}".format( | ||
self.first_name, middle_initial, self.last_name | ||
) | ||
return f"{self.first_name} {middle_initial} {self.last_name}" | ||
if self.suffix: | ||
return "{} {} {}".format(self.first_name, self.last_name, self.suffix) | ||
return "{} {}".format(self.first_name, self.last_name) | ||
return f"{self.first_name} {self.last_name} {self.suffix}" | ||
return f"{self.first_name} {self.last_name}" | ||
|
||
def race_label(self): | ||
if self.race is None: | ||
|
@@ -222,16 +224,13 @@ def currently_on_force(self): | |
|
||
def __repr__(self): | ||
if self.unique_internal_identifier: | ||
return "<Officer ID {}: {} {} {} {} ({})>".format( | ||
self.id, | ||
self.first_name, | ||
self.middle_initial, | ||
self.last_name, | ||
self.suffix, | ||
self.unique_internal_identifier, | ||
return ( | ||
f"<Officer ID {self.id}: {self.first_name} {self.middle_initial} " | ||
+ f"{self.last_name} {self.suffix} ({self.unique_internal_identifier})>" | ||
) | ||
return "<Officer ID {}: {} {} {} {}>".format( | ||
self.id, self.first_name, self.middle_initial, self.last_name, self.suffix | ||
return ( | ||
f"<Officer ID {self.id}: {self.first_name} {self.middle_initial} " | ||
+ f"{self.last_name} {self.suffix}>" | ||
) | ||
|
||
|
||
|
@@ -247,7 +246,7 @@ class Salary(BaseModel): | |
is_fiscal_year = db.Column(db.Boolean, index=False, unique=False, nullable=False) | ||
|
||
def __repr__(self): | ||
return "<Salary: ID {} : {}".format(self.officer_id, self.salary) | ||
return f"<Salary: ID {self.officer_id} : {self.salary}" | ||
|
||
|
||
class Assignment(BaseModel): | ||
|
@@ -265,7 +264,7 @@ class Assignment(BaseModel): | |
resign_date = db.Column(db.Date, index=True, unique=False, nullable=True) | ||
|
||
def __repr__(self): | ||
return "<Assignment: ID {} : {}>".format(self.officer_id, self.star_no) | ||
return f"<Assignment: ID {self.officer_id} : {self.star_no}>" | ||
|
||
|
||
class Unit(BaseModel): | ||
|
@@ -279,7 +278,7 @@ class Unit(BaseModel): | |
) | ||
|
||
def __repr__(self): | ||
return "Unit: {}".format(self.description) | ||
return f"Unit: {self.description}" | ||
|
||
|
||
class Face(BaseModel): | ||
|
@@ -324,7 +323,7 @@ class Face(BaseModel): | |
__table_args__ = (UniqueConstraint("officer_id", "img_id", name="unique_faces"),) | ||
|
||
def __repr__(self): | ||
return "<Tag ID {}: {} - {}>".format(self.id, self.officer_id, self.img_id) | ||
return f"<Tag ID {self.id}: {self.officer_id} - {self.img_id}>" | ||
|
||
|
||
class Image(BaseModel): | ||
|
@@ -356,7 +355,7 @@ class Image(BaseModel): | |
department = db.relationship("Department", backref="raw_images") | ||
|
||
def __repr__(self): | ||
return "<Image ID {}: {}>".format(self.id, self.filepath) | ||
return f"<Image ID {self.id}: {self.filepath}>" | ||
|
||
|
||
incident_links = db.Table( | ||
|
@@ -416,23 +415,22 @@ def validate_state(self, key, state): | |
|
||
def __repr__(self): | ||
if self.street_name and self.cross_street2: | ||
return "Intersection of {} and {}, {} {}".format( | ||
self.street_name, self.cross_street2, self.city, self.state | ||
return ( | ||
f"Intersection of {self.street_name} and {self.cross_street2}, " | ||
+ f"{self.city} {self.state}" | ||
) | ||
elif self.street_name and self.cross_street1: | ||
return "Intersection of {} and {}, {} {}".format( | ||
self.street_name, self.cross_street1, self.city, self.state | ||
return ( | ||
f"Intersection of {self.street_name} and {self.cross_street1}, " | ||
+ f"{self.city} {self.state}" | ||
) | ||
elif self.street_name and self.cross_street1 and self.cross_street2: | ||
return "Intersection of {} between {} and {}, {} {}".format( | ||
self.street_name, | ||
self.cross_street1, | ||
self.cross_street2, | ||
self.city, | ||
self.state, | ||
return ( | ||
f"Intersection of {self.street_name} between {self.cross_street1} " | ||
f"and {self.cross_street2}, {self.city} {self.state}" | ||
) | ||
else: | ||
return "{} {}".format(self.city, self.state) | ||
return f"{self.city} {self.state}" | ||
|
||
|
||
class LicensePlate(BaseModel): | ||
|
38 changes: 38 additions & 0 deletions
38
...sight/migrations/versions/2023-07-26-1551_18f43ac4622f_add_state_column_to_departments.py
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,38 @@ | ||
"""add state column to departments | ||
|
||
Revision ID: 18f43ac4622f | ||
Revises: 1931b987ce0d | ||
Create Date: 2023-07-26 15:51:05.329701 | ||
|
||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "18f43ac4622f" | ||
down_revision = "1931b987ce0d" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table("departments", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column("state", sa.String(length=2), server_default="", nullable=False) | ||
) | ||
batch_op.drop_index("ix_departments_name") | ||
batch_op.create_unique_constraint("departments_name_state", ["name", "state"]) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table("departments", schema=None) as batch_op: | ||
batch_op.drop_constraint("departments_name_state", type_="unique") | ||
batch_op.create_index("ix_departments_name", ["name"], unique=False) | ||
batch_op.drop_column("state") | ||
|
||
# ### end Alembic commands ### |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next PR, once we can create and edit Departments from the front-end, we can make this required.