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 officer creation with notes and descriptions #1053

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

sea-kelp
Copy link
Collaborator

@sea-kelp sea-kelp commented Sep 5, 2023

Fixes issue

Fixes #1052

Description of Changes

Creating an officer with notes and descriptions was failing since it was using the wrong constructor parameter to create Notes and Descriptions (note and description instead of text_contents). This change fixes this bug.

web_1       | 192.168.48.1 - - [05/Sep/2023 07:19:08] "POST /officers/new HTTP/1.1" 500 -                                                                                      [3/9884]
web_1       | Traceback (most recent call last):                                                                                                                                       
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2213, in __call__                                                                                    
web_1       |     return self.wsgi_app(environ, start_response)                                                                                                                        
web_1       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                        
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2193, in wsgi_app                                                                                    
web_1       |     response = self.handle_exception(e)                                                                                                                                  
web_1       |                ^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                  
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app                                                                                    
web_1       |     response = self.full_dispatch_request()                                                                                                                              
web_1       |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                              
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request                                                                       
web_1       |     rv = self.handle_user_exception(e)                                                                                                                                   
web_1       |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                   
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request                                                                       
web_1       |     rv = self.dispatch_request()                                                                                                                                         
web_1       |          ^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                         
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request                                                                            
web_1       |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)                                                                                             
web_1       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                             
web_1       |   File "/usr/local/lib/python3.11/site-packages/flask_login/utils.py", line 290, in decorated_view                                                                       
web_1       |     return current_app.ensure_sync(func)(*args, **kwargs)                                                                                                                
web_1       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                
web_1       |   File "/usr/src/app/OpenOversight/app/utils/auth.py", line 27, in decorated_function                                                                                    
web_1       |     return f(*args, **kwargs)                                                                                                                                            
web_1       |            ^^^^^^^^^^^^^^^^^^
web_1       |   File "/usr/src/app/OpenOversight/app/main/views.py", line 1165, in add_officer
web_1       |     officer = add_officer_profile(form, current_user)
web_1       |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web_1       |   File "/usr/src/app/OpenOversight/app/utils/forms.py", line 93, in add_officer_profile
web_1       |     new_note = Note(
web_1       |                ^^^^^
web_1       |   File "<string>", line 4, in __init__
web_1       |   File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state.py", line 481, in _initialize_instance
web_1       |     with util.safe_reraise():
web_1       |   File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
web_1       |     compat.raise_(
web_1       |   File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
web_1       |     raise exception
web_1       |   File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state.py", line 479, in _initialize_instance
web_1       |     return manager.original_init(*mixed[1:], **kwargs)
web_1       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web_1       |   File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/decl_base.py", line 1197, in _declarative_constructor
web_1       |     raise TypeError(
web_1       | TypeError: 'note' is an invalid keyword argument for Note

Notes for Deployment

None!

Screenshots (if appropriate)

Tests and linting

  • This branch is up-to-date with the develop branch.
  • pytest passes on my local development environment.
  • pre-commit passes on my local development environment.

@sea-kelp sea-kelp marked this pull request as ready for review September 5, 2023 07:43
OpenOversight/tests/routes/test_officer_and_department.py Outdated Show resolved Hide resolved
OpenOversight/app/utils/forms.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@michplunkett michplunkett left a comment

Choose a reason for hiding this comment

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

🥳🥳🥳

@michplunkett michplunkett merged commit 334cf40 into develop Sep 5, 2023
2 checks passed
@michplunkett michplunkett deleted the 1052/fix-adding-officers branch September 5, 2023 19:22
@michplunkett michplunkett linked an issue Jan 3, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants