Skip to content

Commit

Permalink
Merge pull request #6047 from fecgov/feature/get_mur_adr_disposition_…
Browse files Browse the repository at this point in the history
…category_from_table

Remove undisplay MUR disposition category
  • Loading branch information
cnlucas authored Nov 12, 2024
2 parents 4c17d47 + aefd985 commit c04fc41
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 117 deletions.
22 changes: 22 additions & 0 deletions data/migrations/V0305__add_ref_case_disposition_category.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
This is for issue #6041, Add a new table to ref case(MUR, ADR, AF) disposition category.
*/

CREATE TABLE IF NOT EXISTS fecmur.ref_case_disposition_category
(
category_id integer NOT NULL,
category_name varchar(200) NOT NULL,
display_category_name varchar(200) NOT NULL,
doc_type varchar(8) NOT NULL,
published_flg boolean DEFAULT true,
upload_date timestamp without time zone DEFAULT now(),
CONSTRAINT ref_category_pkey PRIMARY KEY (category_id)
);

ALTER TABLE IF EXISTS fecmur.ref_case_disposition_category OWNER to fec;

GRANT SELECT ON TABLE fecmur.ref_case_disposition_category TO aomur_usr;

GRANT ALL ON TABLE fecmur.ref_case_disposition_category TO fec;

GRANT SELECT ON TABLE fecmur.ref_case_disposition_category TO fec_read;
35 changes: 34 additions & 1 deletion tests/integration/test_current_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,20 @@ def test_mur_with_disposition(self, get_bucket, get_credential):
commission_id, agenda_date, vote_date, action, case_id, pg_date
)

category_id = 1
category_name = "Conciliation-PPC"
display_category_name = "Conciliation-PPC"
published_flg = True
doc_type = "MUR"

self.create_disposition_category(
category_id,
category_name,
display_category_name,
published_flg,
doc_type
)

load_mur_citations()

actual_mur = next(get_cases('MUR'))
Expand All @@ -444,7 +458,7 @@ def test_mur_with_disposition(self, get_bucket, get_credential):
'dispositions': [
{
'disposition': 'Conciliation-PPC',
'mur_disposition_category_id': '7',
'mur_disposition_category_id': 1,
'respondent': 'Open Elections LLC',
'penalty': Decimal('50000.00'),
'citations': [
Expand Down Expand Up @@ -800,6 +814,25 @@ def create_event(
pg_date,
)

def create_disposition_category(
self,
category_id,
category_name,
display_category_name,
published_flg,
doc_type,
):
self.connection.execute(
"INSERT INTO fecmur.ref_case_disposition_category (category_id, category_name, "
"display_category_name, published_flg, doc_type) "
"VALUES (%s, %s, %s, %s, %s)",
category_id,
category_name,
display_category_name,
published_flg,
doc_type,
)

def create_relatedobjects(self, master_key, detail_key, relation_id):
self.connection.execute(
"INSERT INTO fecmur.relatedobjects (master_key, detail_key, relation_id) "
Expand Down
7 changes: 2 additions & 5 deletions webservices/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,8 @@ def make_seek_args(field=fields.Int, description=None):
'mur_disposition_category_id': fields.List(IStr(
validate=validate.OneOf([
'', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
'11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
'21', '22', '23', '24', '25', '26', '27', '28', '29', '30',
'31', '32', '33', '34', '35', '36', '37', '38', '39', '40',
'41', '42', '43', '44', '45', '46', '47', '48'])),
description=docs.MUR_DISPOSITION_CATEGORY_DISCRIPTION
'11', '12', '13', '14', '15', '16', '17', '18'])),
description=docs.MUR_DISPOSITION_CATEGORY_DESCRIPTION
),

'af_name': fields.List(IStr, required=False, description=docs.AF_NAME),
Expand Down
69 changes: 20 additions & 49 deletions webservices/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2246,56 +2246,27 @@ def add_ytd(var):
- 2001 - Administrative Fine Case\n\
'''

MUR_DISPOSITION_CATEGORY_DISCRIPTION = '''

MUR_DISPOSITION_CATEGORY_DESCRIPTION = '''
Select one or more MUR disposition category id to filter by corresponding MUR disposition category:\n\
- 1 - Approved by Commission\n\
- 2 - Approved In Part Recs.\n\
- 3 - Approved Recs.\n\
- 4 - Case Activated\n\
- 5 - Case Activation\n\
- 6 - Conciliation-PC\n\
- 7 - Conciliation-PPC\n\
- 8 - Dismiss and Remind\n\
- 9 - Dismissed\n\
- 10 - Dismissed - Agreement Rejected\n\
- 11 - Dismissed-Low Rated\n\
- 12 - Dismissed-Other\n\
- 13 - Dismissed-Stale\n\
- 14 - Dismiss pursuant to prosecutorial discretion\n\
- 15 - Dismiss pursuant to prosecutorial discretion, and caution\n\
- 16 - Enforcement - Disposition - Dismissed "Dismiss" - Dismiss and Caution\n\
- 17 - Failed to Approve Recs.\n\
- 18 - First General Counsel Report\n\
- 19 - Formal Discovery Authorized\n\
- 20 - Investigative Activity\n\
- 21 - Mailed to Respondent\n\
- 22 - Merged\n\
- 23 - No PCTB\n\
- 24 - No RTB\n\
- 25 - Offer from Respondent Received\n\
- 26 - Other\n\
- 27 - PC Brief\n\
- 28 - PC Conciliation Approved\n\
- 29 - PC/NFA\n\
- 30 - PCTB Finding\n\
- 31 - Pre-PCC Commenced\n\
- 32 - Received\n\
- 33 - Received from Audit Division\n\
- 34 - Received from Commission\n\
- 35 - Received from OGC\n\
- 36 - Received from RAD\n\
- 37 - Request for Extension of Time Approved\n\
- 38 - Request for Extension of Time Approved/Denied\n\
- 39 - Request for Extension of Time Received\n\
- 40 - Response Received\n\
- 41 - RTB Finding\n\
- 42 - RTB/NFA\n\
- 43 - Settlement Agreement\n\
- 44 - Suit Authorization\n\
- 45 - Take no action\n\
- 46 - Take No Further Action\n\
- 47 - To Respondent\n\
- 48 - Transferred to ADR\n\
- 1 - Conciliation-PPC\n\
- 2 - Conciliation-PC\n\
- 3 - Dismiss and Remind\n\
- 4 - Dismissed\n\
- 5 - Dismissed-Low Rated\n\
- 6 - Dismissed-Other\n\
- 7 - Dismissed-Stale\n\
- 8 - Dismiss pursuant to prosecutorial discretion\n\
- 9 - Dismiss pursuant to prosecutorial discretion, and caution\n\
- 10 - Enforcement - Disposition - Dismissed Dismiss - Dismiss and Caution\n\
- 11 - No PCTB\n\
- 12 - No RTB\n\
- 13 - PCTB Finding\n\
- 14 - PC/NFA\n\
- 15 - RTB Finding\n\
- 16 - RTB/NFA\n\
- 17 - Take no action\n\
- 18 - Take No Further Action\n\
'''

MUR_TYPE = '''
Expand Down
96 changes: 34 additions & 62 deletions webservices/legal_docs/current_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,56 +274,15 @@
"Dismissed - Failed to Approve": "Case Dismissed"
}

MUR_ADR_DISPOSITION_CATEGORY_MAP = {
'Approved by Commission': '1',
'Approved In Part Recs.': '2',
'Approved Recs.': '3',
'Case Activated': '4',
'Case Activation': '5',
'Conciliation-PC': '6',
'Conciliation-PPC': '7',
'Dismiss and Remind': '8',
'Dismissed': '9',
'Dismissed - Agreement Rejected': '10',
'Dismissed-Low Rated': '11',
'Dismissed-Other': '12',
'Dismissed-Stale': '13',
'Dismiss pursuant to prosecutorial discretion': '14',
'Dismiss pursuant to prosecutorial discretion, and caution': '15',
'Enforcement - Disposition - Dismissed "Dismiss" - Dismiss and Caution': '16',
'Failed to Approve Recs.': '17',
'First General Counsel Report': '18',
'Formal Discovery Authorized': '19',
'Investigative Activity': '20',
'Mailed to Respondent': '21',
'Merged': '22',
'No PCTB': '23',
'No RTB': '24',
'Offer from Respondent Received': '25',
'Other': '26',
'PC Brief': '27',
'PC Conciliation Approved': '28',
'PC/NFA': '29',
'PCTB Finding': '30',
'Pre-PCC Commenced': '31',
'Received': '32',
'Received from Audit Division': '33',
'Received from Commission': '34',
'Received from OGC': '35',
'Received from RAD': '36',
'Request for Extension of Time Approved': '37',
'Request for Extension of Time Approved/Denied': '38',
'Request for Extension of Time Received': '39',
'Response Received': '40',
'RTB Finding': '41',
'RTB/NFA': '42',
'Settlement Agreement': '43',
'Suit Authorization': '44',
'Take no action': '45',
'Take No Further Action': '46',
'To Respondent': '47',
'Transferred to ADR': '48',
}
CASE_DISPOSITION_CATEGORY = """
SELECT category_name,
category_id,
doc_type
from fecmur.ref_case_disposition_category
WHERE published_flg = true
AND doc_type = %s
"""


STATUTE_REGEX = re.compile(r"(?<!\(|\d)(?P<section>\d+([a-z](-1)?)?)")
REGULATION_REGEX = re.compile(r"(?<!\()(?P<part>\d+)(\.(?P<section>\d+))?")
Expand Down Expand Up @@ -661,23 +620,36 @@ def get_adr_case_status(case_id):
def get_mur_dispositions(case_id):
with db.engine.connect() as conn:
rs = conn.execute(MUR_ADR_DISPOSITION_DATA.format(case_id))

# Get the allowed displayed MUR disposition category list from table fecmur.ref_case_disposition_category
category_list = [dict(row) for row in conn.execute(CASE_DISPOSITION_CATEGORY, "MUR")]
logger.debug("category_list =" + json.dumps(category_list, indent=3, cls=DateTimeEncoder))
disposition_data = []
for row in rs:
citations = []
if ALL_STATUTORY_CITATIONS.get(str(case_id) + row["name"]):
citations += ALL_STATUTORY_CITATIONS.get(str(case_id) + row["name"])
if ALL_REGULATORY_CITATIONS.get(str(case_id) + row["name"]):
citations += ALL_REGULATORY_CITATIONS.get(str(case_id) + row["name"])
disposition_data.append({
"citations": citations,
"disposition": row["event_name"],
"mur_disposition_category_id": MUR_ADR_DISPOSITION_CATEGORY_MAP[row["event_name"]],
"penalty": row["final_amount"],
"respondent": row["name"], },
)
category_id = get_display_case_disposition_category_id(category_list, row["event_name"], "MUR")
if category_id:
citations = []
if ALL_STATUTORY_CITATIONS.get(str(case_id) + row["name"]):
citations += ALL_STATUTORY_CITATIONS.get(str(case_id) + row["name"])
if ALL_REGULATORY_CITATIONS.get(str(case_id) + row["name"]):
citations += ALL_REGULATORY_CITATIONS.get(str(case_id) + row["name"])

disposition_data.append({
"citations": citations,
"disposition": row["event_name"],
"mur_disposition_category_id": category_id,
"penalty": row["final_amount"],
"respondent": row["name"], },
)
return disposition_data


def get_display_case_disposition_category_id(category_list, category_name, doc_type):
for one_row in category_list:
if one_row["category_name"] == category_name and one_row["doc_type"] == doc_type:
return one_row["category_id"]


def parse_statutory_citations(statutory_citation, case_id, entity_id, doc_type=None):
citations = []
if statutory_citation:
Expand Down

0 comments on commit c04fc41

Please sign in to comment.