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 multi-department support for photo submission #303

Merged
merged 5 commits into from
Sep 19, 2017

Conversation

redshiftzero
Copy link
Member

@redshiftzero redshiftzero commented Sep 19, 2017

Status

Ready for review

Description of Changes

This PR extends initial multi-department support:

  • Links existing images to the first department (Chicago in the case of LPL's instance).
  • Adds a first step in the photo submission flow for the user to indicate which department the photos are for.

lpl_multi_submission

Testing

  1. Checkout base PR:
git checkout multi-dept-submission
  1. Provision development VM, and migrate the database:
vagrant up
vagrant ssh
source ~/oovirtenv/bin/activate
cd /vagrant/OpenOversight
python manage.py migrate

No errors should appear.

  1. Link existing images to the first department:
python manage.py link_images_to_department 

If you want to verify that images are linked to the right department, you can always do the following in python manage.py shell:

>>> from app.models import Image
>>> Image.query.first().department_id
1
  1. Now add a few departments via the "Departments" menu and then go to "Submit Photos" to select a department and submit some test photos (note this does not work in a development environment because a S3 bucket needs to be hooked up, so you'll either need to hook up S3 to test or just run this on staging). See the gif for how to do this.

  2. We do not have unit test coverage of the /upload route, so to verify the proper metadata was added in the database you can use python manage.py shell, for example:

>>> from app.models import Image
>>> Image.query.all()
[<Image ID 1: static/images/test_cop1.png>, <Image ID 2: static/images/test_cop2.png>, <Image ID 3: static/images/test_cop3.png>, <Image ID 4: static/images/test_cop4.png>, <Image ID 5: static/images/test_cop5.jpg>, <Image ID 6: https://s3-us-west-2.amazonaws.com/openoversight/c2/ff41871891265935d87fe8cf701a010a863d16244f0dc30d387300292d13a5.jpg>, <Image ID 7: https://s3-us-west-2.amazonaws.com/openoversight/1e/3b5be1c4912dcfb5e6ab47e74075e62d3187b023e54c9ba25a3ee060cdf2f2.jpg>, <Image ID 8: https://s3-us-west-2.amazonaws.com/openoversight/b7/d5d2a2cf705e664af0d08846b2de06a00a45f8e79c0686a4c192f257322848.jpg>, <Image ID 9: https://s3-us-west-2.amazonaws.com/openoversight/d9/955079ab09d4a5ad3801ab53f5d9efc36291026e0c3ba3699dc89f824f8883.png>]
>>> Image.query.all()[7].department_id
2

Since I selected Berkeley (which has department_id = 2), the result here matches my expectation.

Tests and linting

  • I have rebased my changes on current develop

  • pytests pass in the development environment on my local machine

  • flake8 checks pass

* department_id is not a foreign key (yet) as the schema migration
was tricky. I need to set the column to a NOT NULL value first
and then at a later date can add this foreign key constraint.

* Add schema migration

* Add command to link all existing images to the first department
@redshiftzero
Copy link
Member Author

Anyway the idea here is that once this is merged and deployed, I will add "Berkeley Police Department", "Oakland Police Department", and "University of California Police Department" to the departments we support, which will enable people to start submitting photos for those police departments (cc @magpiewings).

@b-meson b-meson self-requested a review September 19, 2017 17:18
@b-meson b-meson merged commit c3e06cb into develop Sep 19, 2017
@r4v5 r4v5 deleted the multi-dept-submission branch July 1, 2018 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants