Code Monkey home page Code Monkey logo

dear-petition's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dear-petition's Issues

Dockerize our containers?

I saw a comment in our Django entrypoint script that states "If only .env files supported variable expansion..." I think this might be a use case for Dockerize? https://github.com/jwilder/dockerize

@copelco Do you think there is value in adding Dockerize to our stack at this point, or have you more or less already emulated this functionality?

UnboundLocalError: local variable 'most_recent_record' referenced before assignment

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 65, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    response = self.get_response(request)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 75, in get_response
    response = self._middleware_chain(request)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/usr/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.6/site-packages/six.py", line 695, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/app/dear_petition/petition/views.py", line 38, in create_petition
    output = form.save()
  File "/app/dear_petition/petition/forms.py", line 97, in save
    petition = Writer(form_data, self.batch, template_path, output)
  File "/app/dear_petition/petition/writer.py", line 19, in __init__
    self.data = map_data(form_data, batch)
  File "/app/dear_petition/petition/data_dict.py", line 8, in map_data
    record = batch.most_recent_record
  File "/app/dear_petition/petition/models.py", line 141, in most_recent_record
    return most_recent_record
UnboundLocalError: local variable 'most_recent_record' referenced before assignment

New 500 error

Check out petition #105 on production and figure out why it is producing a 500 error.

Try out SendGrid for email server

Currently we use Mailgun but it seems to be hard and/or impossible to configure the project to send mail using Mailgun for free. Let's try SendGrid. This will allow us to send users emails, for example for creating their accounts.

Pipfile breaks Heroku deployment

The current Pipfile breaks the Heroku deployment. It has been renamed to Pipfile.bak until it's resolved.

I'm open to the idea of moving to using Pipfile if we can:

  • Remove existing requirements files so we don't have two sets of requirements
  • Update documentation on how to use Pipfiles
  • Update Dockerfiles to use it
  • Ensure Heroku deployments still work

Travis build fails with unknown package names

sudo apt-get install -qq libtiff4-dev libjpeg8-dev libfreetype6-dev liblcms1-dev libwebp-dev
E: Package 'libtiff4-dev' has no installation candidate
E: Package 'liblcms1-dev' has no installation candidate
travis_time:end:135462cd:start=1565636043033281299,finish=1565636043537010181,duration=503728882
The command "sudo apt-get install -qq libtiff4-dev libjpeg8-dev libfreetype6-dev liblcms1-dev libwebp-dev" failed and exited with 100 during .�[0m

Your build has been stopped.

https://travis-ci.org/deardurham/dear-petition/builds/570985937

Implement permissions

Right now, technically anyone can see records used to generate petitions in the tool. This was a concern that was raised during the meeting with Gina. Either we need to partition user files/cases so each user can only see their own or only admins can see the records. We will need to discuss the approach we want to take next meeting.

Configure Heroku review apps for PRs

Ideally, we could test a PR before it's even merged. Currently, too many environment variables are required in app.json. I'm not sure how to get around this yet.

Firefox compatibility issues

We have been testing in Chrome, but Joseph uses Firefox. Some text appears too large in Firefox (dates in offense section do not fit in column). Also, saving as PDF in Firefox blanks the petition in Adobe Acrobat. Investigate these issues and determine if there is a fix.

POST requests return 403 when proxying locally to staging

When developing locally on the frontend and proxying to https://dear-petition-staging.herokuapp.com/, POST requests fail:

2020-06-11T16:41:58.400638+00:00 heroku[router]: at=info method=POST path="/petition/api/token/" host=dear-petition-staging.herokuapp.com request_id=2e5d7840-7c25-4894-a00d-d7012d9c9520 fwd="127.0.0.1,71.70.229.1" dyno=web.1 connect=0ms service=67ms status=200 bytes=1031 protocol=https
2020-06-11T16:42:03.967550+00:00 heroku[router]: at=info method=POST path="/petition/api/batch/" host=dear-petition-staging.herokuapp.com request_id=afe4aa2b-5789-4d64-b828-d3233a34754a fwd="127.0.0.1,71.70.229.1" dyno=web.1 connect=1ms service=10ms status=403 bytes=475 protocol=https

Performing the same actions directly on staging work successfully.

Display offense records on CIPRS tab

When parsed properly, record.data["Offense Record"]["Records"] will contain JSON like:

[
    {
        "Action": "CHARGED",
        "Description": "SPEEDING(80 mph in a 65 mph zone)",
        "Severity": "INFRACTION",
        "Law": "G.S. 20-141(B)",
        "Code": "4450"
    },
    {
        "Action": "ARRAIGNED",
        "Description": "SPEEDING(80 mph in a 65 mph zone)",
        "Severity": "INFRACTION",
        "Law": "G.S. 20-141(B)",
        "Code": "4450"
    },
    {
        "Action": "CONVICTED",
        "Description": "IMPROPER EQUIP - SPEEDOMETER",
        "Severity": "INFRACTION",
        "Law": "G.S. 20-123.2",
        "Code": "4418"
    }
]

Ideally, these would be displayed on the CIPRS tab in a table, likely somewhere near here in the template.

Restore password reset functionality

The password reset views were not migrated to the React SPA. We can either:

  1. Restore the existing Django views
  2. Create API endpoint(s) to handle the reset and implement FE in React

Populate disposition method codes in petition Disposition column

In export app, offense dispositions need to be mapped to the following codes within the petition PDF:

  • Dismissal without Leave by DA (VD)
  • Dismissed by Court (DC)
  • Deferred Prosecution Dismissal (DPD)
  • Discharge and Dismissal (DD)
  • Conditional Discharge (DD)
  • No Probable Cause (NPC)
  • Never To Be Served (NTBS)
  • Guilty to Lesser (Glty to Lesser)

Update attorney list to reflect new users

Right now the only attorneys we have as options in the tool are Arnetta and Henry, who are no longer with DEAR. Joseph is to send us a list of attorneys that we should have as options in the tool.

Populate offense section in PDF

Each row in the Petition PDF's offense section is keyed off of an incrementing index with these field names:

  • File No.(s): Fileno:1
  • Date of Arrest: ArrestDate:1
  • Offense Description: Description:1
  • Date of Offense: DOOF:1
  • Disposition: Disposition:1
  • Date of Disposition: DispositionDate:1

For each record.data["Offense Record"]["Records"], map:

  • File No: record.file_no -> Fileno:N
  • Date of Arrest: record.offense_date -> ArrestDate:N
  • Offense Description: record.data["Offense Record"]["Records"][N]["Description"] -> Description:N
  • Date of Offense: record.offense_date -> DOOF:N
  • Disposition: record.disposition_method -> Disposition:N
  • Date of Disposition: record.disposed_on -> DispositionDate:N

AOC-CR-288: Populate not guilty charges

Not Guilty fields differ from Dismissed Charges:

  • The application will need to reference the “Verdict” field for the phrase “Not Guilty”.
  • The entry in the petition’s “Disposition” column should read “Not Guilty” spelled out.

AC:

  • dear_petition.petition.types.not_guilty module exists, modeled after dear_petition.petition.types.dismissed
  • not_guilty.get_offense_records() returns an OffenseRecord queryset where:
    • Q(action="CHARGED")
    • and Q(offense__verdict__iexact="Not Guilty")
  • dear_petition.petition.types.main.TYPE_MAP includes mapping from constants. NOT_GUILTY to get_offense_records() above
  • dear_petition.petition.etl.load.create_batch_petitions() includes a section to create distinct Petition objects

Configure (and document) how to develop React app against different backends

The React SPA is very simple to get running after cloning the repo:

npm i
npm run start

Ideally a frontend developer could point the backend API based on what was being developed:

  1. To staging (maybe the default?)
  2. To the Django docker container

This can be customized in package.json under the proxy setting:

{
  "proxy": "http://localhost:8000/"
}

AC:

  • Determine best way to override proxy
  • README is updated with how to configure

Improve Local Setup Documentation

I tried to go through the non-Docker local setup docs today, and was surprised that they stop after installing requirments, without instructions about setting up a database, running the server, etc. locally. If the project supports non-Docker setups, then we should either

  • a) give instructions on how to set up the rest of the project locally without Docker, or
  • b) remove the non-Docker section

Add petitioner name and address fields

Up to date petitioner addresses are not available on CIPRS records. Fillable address fields should be added to the generate page so that they can be included on all petitions:

  • Name (pre-filled with batch["label"])
  • Address line 1
  • Address line 2
  • City
  • State
  • Zipcode

They should be submitted alongside the other JSON to the generate API endpoint, e.g:

{
    "petition": 11,
    "ssn": "111-111-1111",
    "drivers_license": "12345678",
    "name": "",
    "address_1": "",
    "address_2": "",
    "city": "",
    "state": "",
    "zipcode": "",
}

Link to admin URL in navigation bar

/petition/api/users/ will always return a single item list based on the logged in user. If the user is is_staff, it will contain a URL path to the admin. If not, it will be blank.

AC:

  • Add admin URL to navbar if user api returns it

AOC-CR-281: Populate misdemeanor convictions

These are findings of Guilty. There are two big differences from the Dismissed Charge fields.

  • First, the application will pull the entry for the petition’s “Offense Description” column from the “Convicted” row of the CIPRS record rather than from the “Charged” row.
  • Second, the application will need to reference the “Verdict” field for the phrase “Guilty”.

AC:

  • dear_petition.petition.types.misdemeanor module exists, modeled after dear_petition.petition.types.dismissed
  • not_guilty.get_offense_records() returns an OffenseRecord queryset where:
    • Q(action="CONVICTED")
    • and Q(offense__verdict__iexact="Guilty")
  • dear_petition.petition.types.main.TYPE_MAP includes mapping from constants. MISDEMEANOR to get_offense_records() above
  • dear_petition.petition.etl.load.create_batch_petitions() includes a section to create distinct AOC-CR-281 Petition objects

Populate age at time of offense field

If there's only a single offense date, the tool should calculate the age and fill in the Age PDF field. However, if there are multiple offense dates represented on a petition, just fill the field with Varies.

AOC-CR-287: Support Guilty to Lesser

This is a trickier but common situation where the defendant is charged with a higher-classification offense (typically a felony) but pleads guilty to a lesser-included offense (such as a misdemeanor).

  • The “Charged” offense should be listed on the petition while the “Convicted” offense should not.
  • The “Guilty to Lesser” phrase is found in the “Plea” field.
  • The “Disposition Method” field lists “Disposed by Judge”.
    • Disposition Method = Disposed by Judge
    • Plea = Guilty to Lesser

Notes: DJ listed the phrase that is found on the CIPRS record. These are generally located in the “Disposition Method” field of the CIPRS record. In parenthesis, I listed the corresponding code that should be displayed in the petition’s “Disposition” column.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.