Skip to content

Commit

Permalink
Merge pull request #319 from lucyparsons/multi-dept-volunteer-classif…
Browse files Browse the repository at this point in the history
…ication

Add multi department volunteer image classification support
  • Loading branch information
redshiftzero authored Dec 9, 2017
2 parents 9b48359 + b1db04f commit 329bfbb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
13 changes: 8 additions & 5 deletions OpenOversight/app/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,24 @@ def get_ooid():

@main.route('/label', methods=['GET', 'POST'])
def get_started_labeling():
return render_template('label_data.html')
departments = Department.query.all()
return render_template('label_data.html', departments=departments)


@main.route('/sort', methods=['GET', 'POST'])
@main.route('/sort/department/<int:department_id>', methods=['GET', 'POST'])
@login_required
def sort_images():
def sort_images(department_id):
# Select a random unsorted image from the database
image_query = Image.query.filter_by(contains_cops=None)
image_query = Image.query.filter_by(contains_cops=None) \
.filter_by(department_id=department_id)
image = get_random_image(image_query)

if image:
proper_path = serve_image(image.filepath)
else:
proper_path = None
return render_template('sort.html', image=image, path=proper_path)
return render_template('sort.html', image=image, path=proper_path,
department_id=department_id)


@main.route('/tutorial')
Expand Down
13 changes: 8 additions & 5 deletions OpenOversight/app/templates/label_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ <h1><small>Volunteer</small></h1>
</div>

<div class="text-center frontpage-leads">
<h2><small>Image classification</small></h2>
<p>
<a class="btn btn-lg btn-primary" href="{{ url_for('main.sort_images') }}">
<span class="glyphicon glyphicon-duplicate" aria-hidden="true"></span>
Image classification
</a>
Sort submitted images into those with and without officers.
</p>
{% for department in departments %}
<p>
Sort submitted images into those with and without officers.
<a class="btn btn-lg btn-primary" href="{{ url_for('main.sort_images', department_id=department.id) }}">
<span class="glyphicon glyphicon-duplicate" aria-hidden="true"></span>
{{ department.name }}
</a>
</p>
{% endfor %}
</div>

<div class="text-center frontpage-leads">
Expand Down
2 changes: 1 addition & 1 deletion OpenOversight/app/templates/sort.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1><small>Do you see police officers in the photo?</small></h1>
</form>
</div>
<div class="col-sm-4 text-center">
<a href="{{ url_for('main.sort_images') }}" id="answer-skip" class="btn btn-lg btn-primary" role="button">
<a href="{{ url_for('main.sort_images', department_id=department_id) }}" id="answer-skip" class="btn btn-lg btn-primary" role="button">
<span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> <u>S</u>kip</a>
</div>
<div class="col-sm-4 text-center">
Expand Down
4 changes: 2 additions & 2 deletions OpenOversight/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_routes_ok(route, client, mockdata):
# All login_required views should redirect if there is no user logged in
@pytest.mark.parametrize("route", [
('/auth/unconfirmed'),
('/sort'),
('/sort/department/1'),
('/cop_face'),
('/image/1'),
('/image/tagged/1'),
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_logged_in_user_can_access_sort_form(mockdata, client, session):
login_user(client)

rv = client.get(
url_for('main.sort_images'),
url_for('main.sort_images', department_id=1),
follow_redirects=True
)
assert 'Do you see police officers in the photo' in rv.data
Expand Down

0 comments on commit 329bfbb

Please sign in to comment.