Skip to content

Commit

Permalink
Merge pull request #13 from plocket/merge_made
Browse files Browse the repository at this point in the history
Merge GBLS master
  • Loading branch information
plocket committed Jan 10, 2021
2 parents c8b8aef + 99e7be3 commit 4b35fee
Show file tree
Hide file tree
Showing 20 changed files with 1,146 additions and 768 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Request for Discovery, and accompanying forms and motions.

## Changelog

* 2020-01-05 Bug fix when using new attorney name
* 2020-01-04 Add support for attorney entering appearance
* 2020-01-03 Integrate language files
* 2020-12-10 Edit additional tenant signature
* 2020-12-02 Language tweaks, compatibility with docassemble 1.2.7
* 2020-11-18 Translate section labels
Expand Down
2 changes: 1 addition & 1 deletion docassemble/MAEvictionDefense/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.89'
__version__ = '0.1.92'
91 changes: 91 additions & 0 deletions docassemble/MAEvictionDefense/connect_gsheets_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import gspread
import json
from docassemble.base.util import get_config
from oauth2client.service_account import ServiceAccountCredentials
credential_info = json.loads(get_config('google').get('service account credentials'), strict=False)
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
import usaddress
import nameparser

__all__ = ['read_sheet','map_address','map_name','map_attorney_info']

def read_sheet(sheet_name, worksheet_title):
creds = ServiceAccountCredentials.from_json_keyfile_dict(credential_info, scope)
client = gspread.authorize(creds)
sheet = client.open(sheet_name).worksheet(worksheet_title)
return sheet.get_all_records()

def map_attorney_info(attorney_row, attorney_object):
map_name(attorney_row.get('Attorney Name'), attorney_object.name)
attorney_object.office = attorney_row.get('Office Name','')
attorney_object.email = attorney_row.get('Email Address','')
map_address(attorney_row.get('Street Address') + ', ' + attorney_row.get('City State and Zip'), attorney_object.address)
attorney_object.bbo = attorney_row.get('BBO Number','')
attorney_object.phone_number = attorney_row.get('Phone Number','')
attorney_object.fax_number = attorney_row.get('Fax Number','')

def map_address(oneline_address, address_object):
tag_mapping={
'Recipient': 'recipient',
'AddressNumber': 'address',
'AddressNumberPrefix': 'address',
'AddressNumberSuffix': 'address',
'StreetName': 'address',
'StreetNamePreDirectional': 'address',
'StreetNamePreModifier': 'address',
'StreetNamePreType': 'address',
'StreetNamePostDirectional': 'address',
'StreetNamePostModifier': 'address',
'StreetNamePostType': 'address',
'CornerOf': 'address',
'IntersectionSeparator': 'address',
'LandmarkName': 'address',
'USPSBoxGroupID': 'address',
'USPSBoxGroupType': 'address',
'USPSBoxID': 'address',
'USPSBoxType': 'address',
'BuildingName': 'unit',
'OccupancyType': 'unit',
'OccupancyIdentifier': 'unit',
'SubaddressIdentifier': 'unit',
'SubaddressType': 'unit',
'PlaceName': 'city',
'StateName': 'state',
'ZipCode': 'zip',
}


try:
address_parts = usaddress.tag(oneline_address, tag_mapping=tag_mapping)

if address_parts[1].lower() == 'street address':
address_object.address = address_parts[0].get('address')
if address_parts[0].get('unit'):
address_object.unit = address_parts[0].get('unit')
address_object.city = address_parts[0].get('city')
address_object.state = address_parts[0].get('state')
address_object.zip = address_parts[0].get('zip')
else:
address_object.address = oneline_address

except:
address_object.address = oneline_address

if not hasattr(address_object,'address'):
address_object.address = ''
if not hasattr(address_object, 'city'):
address_object.city = ''
if not hasattr(address_object, 'state'):
address_object.state = ''
if not hasattr(address_object, 'zip'):
address_object.zip = ''

def map_name(oneline_name, name_object):
name = nameparser.HumanName(str(oneline_name))
name_object.first = name['first']
if name['middle']:
name_object.middle = name['middle']
name_object.last = name['last']
if name['suffix']:
name_object.suffix = name['suffix']
25 changes: 24 additions & 1 deletion docassemble/MAEvictionDefense/data/questions/eviction.code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,31 @@ code: |
code: |
attempted_cure = attempted_full_cure or attempted_offered_cure
---
objects:
- tenants_attorney: Individual
---
modules:
- .connect_gsheets_data
---
code: |
try:
attorneys = read_sheet("GBLS Eviction Defense System", "Attorneys")
except:
attorneys = []
---
code: |
# Did someone choose an existing name from the combobox, or type something
# custom in?
if tenant_attorney_name.isnumeric() and int(tenant_attorney_name) < len(attorneys):
map_attorney_info(attorneys[int(tenant_attorney_name)], tenants_attorney)
else:
map_name(tenant_attorney_name, tenants_attorney.name)
# Make sure address was triggered
tenants_attorney.address.address
prefill_attorney_address_and_name = True
---
code: |
prepared_with_aoc = url_args.get('clinic',False) == 'GBLS' or person_answering == 'attorney'
prepared_with_aoc = url_args.get('clinic',False) == 'GBLS' or person_answering == 'attorney' and representation_type == 'ghostwriting'
---
sets:
- landlords_attorney.name.text
Expand Down
166 changes: 166 additions & 0 deletions docassemble/MAEvictionDefense/data/questions/eviction.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,75 @@ buttons:
- Tenant or helper: tenant
- Attorney: attorney
---
objects:
- tenants_attorney: Individual
---
id: ghostwriting
question: |
Should the tenant's attorney's name appear on this pleading?
fields:
- no label: representation_type
input type: radio
choices:
- Yes. I am entering an appearance.: entering_appearance
- No. I am only helping "ghostwrite" this document.: ghostwriting
- note: |
**Okay. Each form will state "Prepared with Assistance of Counsel"**
show if:
variable: representation_type
is: ghostwriting
- note: |
**Name of tenant's attorney**
show if:
variable: representation_type
is: entering_appearance
- First name: tenants_attorney.name.first
show if:
variable: representation_type
is: entering_appearance
- Middle name: tenants_attorney.name.middle
required: False
show if:
variable: representation_type
is: entering_appearance
- Last name: tenants_attorney.name.last
show if:
variable: representation_type
is: entering_appearance
- Suffix: tenants_attorney.name.suffix
code: |
name_suffix()
required: False
show if:
variable: representation_type
is: entering_appearance
- BBO Number: tenants_attorney.bbo_number
show if:
variable: representation_type
is: entering_appearance
- Email: tenants_attorney.email
required: False
show if:
variable: representation_type
is: entering_appearance
- Office name (type or select from list): tenants_attorney.office_name
input type: combobox
show if:
variable: representation_type
is: entering_appearance
choices:
- Community Legal Aid
- De Novo Center for Justice and Healing
- Disability Law Center
- Greater Boston Legal Services
- Massachusetts Law Reform Institute
- MetroWest Legal Services
- National Consumer Law Center
- Northeast Legal Aid
- South Coastal Counties Legal Services
- Volunteer Lawyers Project

---
id: tenant rights
question: Your tenant rights in Massachusetts
subquestion: |
Expand Down Expand Up @@ -2942,3 +3011,100 @@ subquestion: |
% endfor
[View all of your saved online forms](${url_of('interviews')})
---
id: explain pronouns
question: |
You said you are an attorney representing a tenant
subquestion: |
Most of the questions in this tool will use the word "you" to refer
to the **tenant**, not to you as their attorney. Answer as if you are the
tenant.
continue button field: explain_pronouns
---
id: representation type
question: |
Should the tenant's attorney's name appear on this pleading?
fields:
- no label: representation_type
input type: radio
choices:
- Yes. I am entering an appearance.: entering_appearance
- No. I am only helping "ghostwrite" this document.: ghostwriting
- note: |
**Okay. Each form will state "Prepared with Assistance of Counsel"**
show if:
variable: representation_type
is: ghostwriting
- note: |
**Name of tenant's attorney**
If you are an attorney at a Massachusetts Legal Aid agency, you can
provide your information using this [Google Form](https://forms.gle/ZR7cP4BPMiH8yzTL6).
You can provide an office address, phone number, and BBO number to be
saved for future use. Contact made@gbls.org to request corrections.
show if:
variable: representation_type
is: entering_appearance
- Attorney's Full Name (select an existing name or type a new name): tenant_attorney_name
datatype: combobox
code: |
[{index: attorney.get('Attorney Name')} for index, attorney in enumerate(attorneys)]
show if:
variable: representation_type
is: entering_appearance
---
id: verify attorney information
question: |
Contact information for attorney ${ tenants_attorney }
fields:
- First name: tenants_attorney.name.first
- Middle name: tenants_attorney.name.middle
required: False
- Last name: tenants_attorney.name.last
- Suffix: tenants_attorney.name.suffix
required: False
- BBO Number: tenants_attorney.bbo
required: False
- Email: tenants_attorney.email
required: False
- Phone number: tenants_attorney.phone_number
- Fax number: tenants_attorney.fax_number
required: False
- Office name (type or select from list): tenants_attorney.office
input type: combobox
choices:
- Community Legal Aid
- De Novo Center for Justice and Healing
- Disability Law Center
- Greater Boston Legal Services
- Massachusetts Law Reform Institute
- MetroWest Legal Services
- National Consumer Law Center
- Northeast Legal Aid
- South Coastal Counties Legal Services
- Volunteer Lawyers Project
- Street address: tenants_attorney.address.address
address autocomplete: True
- Unit: tenants_attorney.address.unit
required: False
- City: tenants_attorney.address.city
- State: tenants_attorney.address.state
code: |
states_list()
- Zip: tenants_attorney.address.zip
---
id: confirm contact information
continue button field: confirm_attorney_contact_information
question: |
Confirm your contact information
subquestion: |
${ tenants_attorney }
BBO # ${ tenants_attorney.bbo }
${ tenants_attorney.office }
${ tenants_attorney.address.block() }
${ tenants_attorney.email }
${ tenants_attorney.phone_number }
${ tenants_attorney.fax_number }
[Edit contact information](${ url_action('tenants_attorney.office')})
51 changes: 36 additions & 15 deletions docassemble/MAEvictionDefense/data/questions/eviction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metadata:
Please download the [Answer](https://www.masslegalhelp.org/housing/lt1-booklet-3-answer.pdf)
and the [Request for Discovery](https://www.masslegalhelp.org/housing/lt1-booklet-4-discovery.pdf).
You can follow the [instructions](https://www.masslegalhelp.org/housing/lt1-booklet-1-representing-yourself.pdf) here.
revision_date: 2020-11-13
revision_date: 2021-01-04
---
code: |
revisit_sharing_url = url_ask(['share_fields', 'share_success', {'recompute': ['share_email','sent_sharing_email','share_cell','sent_sharing_text']} ])
Expand Down Expand Up @@ -207,17 +207,23 @@ code: |
nav.set_section('review_signature')
if started_on_phone:
saw_signature_choice = True
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
else:
saw_signature_choice
if defined('signature_choice') and signature_choice =='this device':
if person_answering == 'attorney' and representation_type == 'entering_appearance':
tenants_attorney.signature
else:
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
t.signature
else:
saw_signature_choice
if defined('signature_choice') and signature_choice =='this device':
if person_answering == 'attorney' and representation_type == 'entering_appearance':
tenants_attorney.signature
else:
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
elif defined('signature_choice') and signature_choice == 'phone':
saw_signature_qrcode
if defined('link_cell') or defined('link_email'):
Expand All @@ -226,17 +232,32 @@ code: |
if defined('link_email') and link_email:
send_email(task='send signature link', to=link_email, template=interview_link)
signature_wait_screen
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
if person_answering == 'attorney' and representation_type == 'entering_appearance':
tenants_attorney.signature
else:
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
if device() and device().is_mobile:
signature_phone_followup
else:
tenant.signature
if person_answering == 'attorney' and representation_type == 'entering_appearance':
tenants_attorney.signature
else:
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
# Handle situation where someone uses the QR code
if saw_signature_choice and not defined('signature_choice'):
tenant.signature
if person_answering == 'attorney' and representation_type == 'entering_appearance':
tenants_attorney.signature
else:
tenant.signature
if additional_tenants.there_are_any:
for t in additional_tenants:
t.signature
signature_phone_followup
signature_choice = 'phone'
Expand Down
Loading

0 comments on commit 4b35fee

Please sign in to comment.