Skip to content

Commit

Permalink
Merge pull request #310 from lucyparsons/add-officers-units-multi-city
Browse files Browse the repository at this point in the history
Enable admin to add new officers and units for any department
  • Loading branch information
redshiftzero authored Dec 10, 2017
2 parents 329bfbb + 5d9e569 commit 76ffaad
Show file tree
Hide file tree
Showing 30 changed files with 489 additions and 333 deletions.
24 changes: 13 additions & 11 deletions CONTRIB.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,25 @@ In addition to running the development server, `manage.py` (OpenOversight's mana

```
(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py
--------------------------------------------------------------------------------
INFO in __init__ [/vagrant/OpenOversight/app/__init__.py:57]:
OpenOversight startup
--------------------------------------------------------------------------------
usage: manage.py [-?]
{shell,makemigrations,migrate,downgrade_db,runserver,make_admin_user}
{runserver,db,shell,make_admin_user,link_images_to_department}
...
positional arguments:
{shell,makemigrations,migrate,downgrade_db,runserver,make_admin_user}
shell Runs a Python shell inside Flask application context.
makemigrations Make database migrations
migrate Migrate/upgrade the database
downgrade_db Downgrade the database
{runserver,db,shell,make_admin_user,link_images_to_department}
runserver Runs the Flask development server i.e. app.run()
db Perform database migrations
shell Runs a Python shell inside Flask application context.
make_admin_user Add confirmed administrator account
link_images_to_department
Link existing images to first department
optional arguments:
-?, --help show this help message and exit
```

In development, you can make an administrator account without having to confirm your email:
Expand Down Expand Up @@ -109,17 +112,16 @@ If you e.g. add a new column or table, you'll need to migrate the database.
You can use the management interface to first generate migrations:

```
(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py makemigrations
New migration saved as /vagrant/OpenOversight/app/db_repository/versions/002_migration.py
(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py db migrate
```

And then you should inspect/edit the migrations. You can then apply the migrations:

```
(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py migrate
(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py db upgrade
```

You can also downgrade the database using `python manage.py downgrade_db`.
You can also downgrade the database using `python manage.py db downgrade`.

## Changing the Development Environment

Expand Down
1 change: 0 additions & 1 deletion OpenOversight/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class BaseConfig(object):
# DB SETUP
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_COMMIT_ON_TEARDOWN = True

Expand Down
4 changes: 0 additions & 4 deletions OpenOversight/app/db_repository/README

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions OpenOversight/app/db_repository/manage.py

This file was deleted.

25 changes: 0 additions & 25 deletions OpenOversight/app/db_repository/migrate.cfg

This file was deleted.

76 changes: 0 additions & 76 deletions OpenOversight/app/db_repository/versions/001_migration.py

This file was deleted.

32 changes: 0 additions & 32 deletions OpenOversight/app/db_repository/versions/002_migration.py

This file was deleted.

27 changes: 0 additions & 27 deletions OpenOversight/app/db_repository/versions/003_migration.py

This file was deleted.

35 changes: 0 additions & 35 deletions OpenOversight/app/db_repository/versions/004_migration.py

This file was deleted.

41 changes: 0 additions & 41 deletions OpenOversight/app/db_repository/versions/005_migration.py

This file was deleted.

Empty file.
35 changes: 33 additions & 2 deletions OpenOversight/app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Length, Optional)
from flask_wtf.file import FileField, FileAllowed, FileRequired

from ..utils import unit_choices
from ..utils import unit_choices, dept_choices


# Choices are a list of (value, label) tuples
Expand Down Expand Up @@ -98,7 +98,7 @@ class AssignmentForm(Form):
rank = SelectField('rank', default='COMMANDER', choices=RANK_CHOICES,
validators=[AnyOf(allowed_values(RANK_CHOICES))])
unit = QuerySelectField('unit', validators=[Optional()],
query_factory=unit_choices)
query_factory=unit_choices, get_label='descrip')
star_date = DateField('star_date', validators=[Optional()])


Expand All @@ -112,3 +112,34 @@ class DepartmentForm(Form):
default='', validators=[Regexp('\w*'), Length(max=100), DataRequired()]
)
submit = SubmitField(label='Add')


class AddOfficerForm(Form):
first_name = StringField('First name', default='', validators=[
Regexp('\w*'), Length(max=50), DataRequired()])
last_name = StringField('Last name', default='', validators=[
Regexp('\w*'), Length(max=50), DataRequired()])
middle_initial = StringField('Middle initial', default='', validators=[
Regexp('\w*'), Length(max=50), DataRequired()])
race = SelectField('Race', default='WHITE', choices=RACE_CHOICES,
validators=[AnyOf(allowed_values(RACE_CHOICES))])
gender = SelectField('Gender', default='M', choices=GENDER_CHOICES,
validators=[AnyOf(allowed_values(GENDER_CHOICES))])
star_no = IntegerField('Badge Number')
rank = SelectField('Rank', default='COMMANDER', choices=RANK_CHOICES,
validators=[AnyOf(allowed_values(RANK_CHOICES))])
unit = QuerySelectField('Unit', validators=[Optional()],
query_factory=unit_choices, get_label='descrip')
employment_date = DateField('Employment Date', validators=[Optional()])
birth_year = IntegerField('Birth Year', validators=[Optional()])
department = QuerySelectField('Department', validators=[Optional()],
query_factory=dept_choices, get_label='name')
submit = SubmitField(label='Add')


class AddUnitForm(Form):
descrip = StringField('Unit name or description', default='', validators=[
Regexp('\w*'), Length(max=120), DataRequired()])
department = QuerySelectField('Department', validators=[Optional()],
query_factory=dept_choices, get_label='name')
submit = SubmitField(label='Add')
Loading

0 comments on commit 76ffaad

Please sign in to comment.