Skip to content

Commit

Permalink
Merge pull request #508 from lucyparsons/develop
Browse files Browse the repository at this point in the history
Release 0.4.1
  • Loading branch information
redshiftzero authored Jul 15, 2018
2 parents bdb91aa + 34d5f5b commit 1b01476
Show file tree
Hide file tree
Showing 58 changed files with 1,419 additions and 239 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
backup/**
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ before_script:
- cd OpenOversight
script:
- py.test -v --cov=app
- flake8 --ignore=E501,E722
- cd .. && flake8 --ignore=E501,E722
after_success:
- coveralls
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
31 changes: 29 additions & 2 deletions CONTRIB.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
# Contributing Guide

First, thanks for being interested in helping us out! If you find an issue you're interested in, feel free to make a comment about how you're thinking of approaching implementing it in the issue and we can give you feedback.
First, thanks for being interested in helping us out! If you find an issue you're interested in, feel free to make a comment about how you're thinking of approaching implementing it in the issue and we can give you feedback. Please also read our [code of conduct](/CODE_OF_CONDUCT.md) before getting started.

## Submitting a PR

When you come to implement your new feature, you should branch off `develop` and add commits to implement your feature. If your git history is not so clean, please do rewrite before you submit your PR - if you're not sure if you need to do this, go ahead and submit and we can let you know when you submit.

Use `PULL_REQUEST_TEMPLATE.md` to create the description for your PR!
Use [PULL_REQUEST_TEMPLATE.md](/PULL_REQUEST_TEMPLATE.md) to create the description for your PR! (The template should populate automatically when you go to open the pull request.)

### Linting / Style Checks

`flake8` is a tool for automated linting and style checks. Be sure to run `flake8` and fix any errors before submitting a PR.

## Development Environment

You can use our Docker or Vagrant/VirtualBox development environments.

### Docker

You will need to have Docker installed in order to use the Docker development environment.

To build and run the development environment, simply `make dev`. Whenever you want to rebuild the containers, `make build` (you should need to do this rarely).

Tests are executed via `make test`. If you're switching between the Docker and Vagrant/VirtualBox environments and having trouble getting tests running, make sure to delete any remaining `.pyc` files and `__pycache__` directories.

To hop into the postgres container, you can do the following:

```
$ docker exec -it openoversight_postgres_1 /bin/bash
# psql -d openoversight-dev -U openoversight
```

Similarly to hop into the web container:

```
$ docker exec -it openoversight_web_1 /bin/bash
```

Once you're done, `make stop` and `make clean` to stop and remove the containers respectively.

### VirtualBox + Vagrant

Our standard development environment is an Ubuntu 14 VM. We manage it with Vagrant, which means you'll need Vagrant and VirtualBox installed to start out.

* Install Vagrant: https://www.vagrantup.com/downloads.html
Expand Down
4 changes: 2 additions & 2 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deployment

When this application is deployed you will need to do some setup. These instructions are for an Ubuntu server running an `nginx` reverse proxy and `gunicorn`.
When this application is deployed you will need to do some setup. These instructions are for an Ubuntu server running an `nginx` reverse proxy and `gunicorn`.

# Dependencies

Expand Down Expand Up @@ -109,7 +109,7 @@ For more details about the S3 and AWS settings, see above. Please raise an issue

# Systemd

You can write a simple systemd unit file to launch OpenOversight on boot. We defined ours in `/etc/systemd/system/openoversight.service`. You should create the proper usernames and groups that are defined in the unit file since this allows you to drop privileges on boot. This unit file was adopted from this [DigitalOcean guide](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7). More details can be found in `CONTRIB.md`.
You can write a simple systemd unit file to launch OpenOversight on boot. We defined ours in `/etc/systemd/system/openoversight.service`. You should create the proper usernames and groups that are defined in the unit file since this allows you to drop privileges on boot. This unit file was adopted from this [DigitalOcean guide](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7). More details can be found in [CONTRIB.md](/CONTRIB.md).

```
[Unit]
Expand Down
18 changes: 0 additions & 18 deletions Dockerfile

This file was deleted.

28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: default build run

default: dev build start test stop clean

dev:
make build
make start

build:
docker-compose build postgres
docker-compose up -d postgres
docker-compose build web
docker-compose up -d web
docker-compose run --rm web /usr/local/bin/python ../create_db.py
docker-compose run --rm web /usr/local/bin/python ../test_data.py -p

start:
docker-compose up -d

clean:
docker rm openoversight_web_1
docker rm openoversight_postgres_1

test:
docker-compose run --rm web /usr/local/bin/pytest -v tests/

stop:
docker-compose stop
4 changes: 2 additions & 2 deletions OpenOversight/app/formfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _value(self):
return self.data and self.data.strftime(self.format) or ''

def process_formdata(self, valuelist):
if valuelist:
if valuelist and valuelist != [u'']:
time_str = ' '.join(valuelist)
try:
components = time_str.split(':')
Expand All @@ -36,4 +36,4 @@ def process_formdata(self, valuelist):
self.data = datetime.time(hour, minutes, seconds)
except ValueError:
self.data = None
raise ValueError(self.gettext('Not a valid time string'))
raise ValueError(self.gettext('Not a valid time'))
54 changes: 41 additions & 13 deletions OpenOversight/app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class AssignmentForm(Form):

class DepartmentForm(Form):
name = StringField(
'Full name of police department, e.g. Chicago Police Department',
'Full name of law enforcement agency, e.g. Chicago Police Department',
default='', validators=[Regexp('\w*'), Length(max=255), DataRequired()]
)
short_name = StringField(
'Shortened acronym for police department, e.g. CPD',
'Shortened acronym for law enforcement agency, e.g. CPD',
default='', validators=[Regexp('\w*'), Length(max=100), DataRequired()]
)
submit = SubmitField(label='Add')
Expand Down Expand Up @@ -130,6 +130,19 @@ def validate(self):
return success


class BaseNoteForm(Form):
note = TextAreaField()


class EditNoteForm(BaseNoteForm):
submit = SubmitField(label='Submit')


class NoteForm(EditNoteForm):
officer_id = HiddenField(validators=[Required(message='Not a valid officer ID')])
creator_id = HiddenField(validators=[Required(message='Not a valid user ID')])


class AddOfficerForm(Form):
first_name = StringField('First name', default='', validators=[
Regexp('\w*'), Length(max=50), Optional()])
Expand Down Expand Up @@ -158,6 +171,13 @@ class AddOfficerForm(Form):
description='Links to articles about or videos of the incident.',
min_entries=1,
widget=BootstrapListWidget())
notes = FieldList(FormField(
BaseNoteForm,
widget=FormFieldWidget()),
description='This note about the officer will be attributed to your username.',
min_entries=1,
widget=BootstrapListWidget())

submit = SubmitField(label='Add')


Expand Down Expand Up @@ -185,7 +205,7 @@ class EditOfficerForm(Form):
links = FieldList(FormField(
LinkForm,
widget=FormFieldWidget()),
description='Links to articles about or videos of the incident.',
description='Links to articles about or videos of the officer.',
min_entries=1,
widget=BootstrapListWidget())
submit = SubmitField(label='Update')
Expand All @@ -203,12 +223,18 @@ class AddUnitForm(Form):


class DateFieldForm(Form):
date_field = DateField('Date', validators=[Required()])
time_field = TimeField('Time')
date_field = DateField('Date <span class="text-danger">*</span>', validators=[Required()])
time_field = TimeField('Time', validators=[Optional()])

@property
def datetime(self):
return datetime.datetime.combine(self.date_field.data, self.time_field.data)
if self.time_field.data:
return datetime.datetime.combine(self.date_field.data,
self.time_field.data)
else: # Code these events at a precise time so we can find them later
coded_no_time = datetime.time(1, 2, 3, 45678)
return datetime.datetime.combine(self.date_field.data,
coded_no_time)

@datetime.setter
def datetime(self, value):
Expand All @@ -225,13 +251,15 @@ def validate_date_field(self, field):


class LocationForm(Form):
street_name = StringField(validators=[Required()], description='Street on which incident occurred. For privacy reasons, please DO NOT INCLUDE street number.')
cross_street1 = StringField(validators=[Required()], description="Closest cross street to where incident occurred.")
street_name = StringField(validators=[Optional()], description='Street on which incident occurred. For privacy reasons, please DO NOT INCLUDE street number.')
cross_street1 = StringField(validators=[Optional()], description="Closest cross street to where incident occurred.")
cross_street2 = StringField(validators=[Optional()])
city = StringField(validators=[Required()])
state = SelectField('State', choices=STATE_CHOICES,
city = StringField('City <span class="text-danger">*</span>', validators=[Required()])
state = SelectField('State <span class="text-danger">*</span>', choices=STATE_CHOICES,
validators=[AnyOf(allowed_values(STATE_CHOICES))])
zip_code = StringField('Zip Code', validators=[Regexp('^\d{5}$', message='Zip codes must have 5 digits')])
zip_code = StringField('Zip Code',
validators=[Optional(),
Regexp('^\d{5}$', message='Zip codes must have 5 digits')])


class LicensePlateForm(Form):
Expand All @@ -256,11 +284,11 @@ def pre_validate(self, form):

class IncidentForm(DateFieldForm):
report_number = StringField(
validators=[Required(), Regexp(r'^[a-zA-Z0-9-]*$', message="Report numbers can contain letters, numbers, and dashes")],
validators=[Regexp(r'^[a-zA-Z0-9-]*$', message="Report numbers can contain letters, numbers, and dashes")],
description='Incident number for the organization tracking incidents')
description = TextAreaField(validators=[Optional()])
department = QuerySelectField(
'Department',
'Department <span class="text-danger">*</span>',
validators=[Required()],
query_factory=dept_choices,
get_label='name')
Expand Down
Loading

0 comments on commit 1b01476

Please sign in to comment.