From 361d012d34d1b89f3eef57957494932fe153fcca Mon Sep 17 00:00:00 2001 From: tanshu Date: Mon, 18 Jan 2021 10:56:51 +0530 Subject: [PATCH] Added Compliance date. Showing the next hearing date in the case list Showing cases on home --- .../versions/74058d75b7a0_initial_commit.py | 1 + luthor/luthor/models/hearing.py | 3 ++ luthor/luthor/routers/case.py | 6 ++- luthor/luthor/schemas/hearing.py | 9 +++++ otis/src/app/app-routing.module.ts | 3 +- otis/src/app/app.module.ts | 3 +- .../case-detail/case-detail.component.html | 37 ++++++++++++++++--- .../case-detail/case-detail.component.ts | 14 +++++-- .../case-detail/hearing-dialog.component.html | 26 +++++++++---- .../case-detail/hearing-dialog.component.ts | 16 +++++--- .../cases/case-list/case-list.component.html | 2 +- .../cases/case-list/case-list.component.ts | 7 +++- otis/src/app/core/hearing.ts | 4 +- otis/src/app/home/home.component.css | 16 -------- otis/src/app/home/home.component.html | 3 -- otis/src/app/home/home.component.spec.ts | 26 ------------- otis/src/app/home/home.component.ts | 17 --------- 17 files changed, 101 insertions(+), 92 deletions(-) delete mode 100644 otis/src/app/home/home.component.css delete mode 100644 otis/src/app/home/home.component.html delete mode 100644 otis/src/app/home/home.component.spec.ts delete mode 100644 otis/src/app/home/home.component.ts diff --git a/luthor/alembic/versions/74058d75b7a0_initial_commit.py b/luthor/alembic/versions/74058d75b7a0_initial_commit.py index 83850fb..ae035bb 100644 --- a/luthor/alembic/versions/74058d75b7a0_initial_commit.py +++ b/luthor/alembic/versions/74058d75b7a0_initial_commit.py @@ -255,6 +255,7 @@ def upgrade(): sa.Column("item_number", sa.Unicode(length=255), nullable=True), sa.Column("bench", sa.Unicode(length=255), nullable=True), sa.Column("proceedings", sa.Unicode(length=2000), nullable=True), + sa.Column("compliance_date", sa.DateTime(), nullable=True), sa.Column("next_hearing_date", sa.DateTime(), nullable=True), sa.Column("court_status_id", postgresql.UUID(as_uuid=True), nullable=True), sa.Column("old_court_status_id", sa.Integer(), nullable=True), diff --git a/luthor/luthor/models/hearing.py b/luthor/luthor/models/hearing.py index b62d30e..059f9fe 100644 --- a/luthor/luthor/models/hearing.py +++ b/luthor/luthor/models/hearing.py @@ -25,6 +25,7 @@ class Hearing(Base): bench = Column("bench", Unicode(255), nullable=False, unique=True) proceedings = Column("proceedings", Unicode(255), nullable=False, unique=True) next_hearing_date = Column("next_hearing_date", DateTime, nullable=False, index=True) + compliance_date = Column("compliance_date", DateTime, nullable=False, index=True) court_status_id = Column("court_status_id", UUID(as_uuid=True), ForeignKey("court_statuses.id"), nullable=True) court_status = relationship("CourtStatus", back_populates="hearings") @@ -37,6 +38,7 @@ class Hearing(Base): item_number=None, bench=None, proceedings=None, + compliance_date=None, next_hearing_date=None, court_status_id=None, id_=None, @@ -47,5 +49,6 @@ class Hearing(Base): self.item_number = item_number self.bench = bench self.proceedings = proceedings + self.compliance_date = compliance_date self.next_hearing_date = next_hearing_date self.court_status_id = court_status_id diff --git a/luthor/luthor/routers/case.py b/luthor/luthor/routers/case.py index 9837cd2..4f72f70 100644 --- a/luthor/luthor/routers/case.py +++ b/luthor/luthor/routers/case.py @@ -74,6 +74,7 @@ def save( item_number=h.item_number, bench=h.bench, proceedings=h.proceedings, + compliance_date=h.compliance_date, next_hearing_date=h.next_hearing_date, court_status_id=h.court_status.id_ if h.court_status is not None else None, ) @@ -103,7 +104,7 @@ def update( ) -> schemas.Case: try: item: Case = db.query(Case).filter(Case.id == id_).first() - item.case_source_id = data.case_source.id_, + item.case_source_id = data.case_source.id_ item.office_file_number = data.office_file_number item.court_case_number = data.court_case_number item.year = data.year @@ -150,6 +151,7 @@ def update( h.item_number = d.item_number h.bench = d.bench h.proceedings = d.proceedings + h.compliance_date = d.compliance_date h.next_hearing_date = d.next_hearing_date h.court_status_id = d.court_status.id_ if d.court_status is not None else None for d in [d for d in data.hearings if d.id_ is None]: @@ -158,6 +160,7 @@ def update( item_number=d.item_number, bench=d.bench, proceedings=d.proceedings, + compliance_date=d.compliance_date, next_hearing_date=d.next_hearing_date, court_status_id=d.court_status.id_ if d.court_status is not None else None, ) @@ -294,6 +297,7 @@ def case_info(item: Case) -> schemas.Case: itemNumber=h.item_number if h.item_number is not None else "", bench=h.bench if h.bench is not None else "", proceedings=h.proceedings if h.proceedings is not None else "", + complianceDate=h.compliance_date, nextHearingDate=h.next_hearing_date, courtStatus=schemas.CourtStatusLink(id=h.court_status.id, name=h.court_status.name) if h.court_status is not None diff --git a/luthor/luthor/schemas/hearing.py b/luthor/luthor/schemas/hearing.py index e52a2cf..3d2cba6 100644 --- a/luthor/luthor/schemas/hearing.py +++ b/luthor/luthor/schemas/hearing.py @@ -14,6 +14,7 @@ class HearingIn(BaseModel): item_number: str bench: str proceedings: str + compliance_date: Optional[date] next_hearing_date: Optional[date] court_status: Optional[CourtStatusLink] @@ -22,6 +23,14 @@ class HearingIn(BaseModel): alias_generator = to_camel json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")} + @validator("compliance_date", pre=True) + def parse_compliance_date(cls, value): + if isinstance(value, date): + return value + if value is None: + return None + return datetime.strptime(value, "%d-%b-%Y").date() + @validator("next_hearing_date", pre=True) def parse_next_hearing_date(cls, value): if isinstance(value, date): diff --git a/otis/src/app/app-routing.module.ts b/otis/src/app/app-routing.module.ts index 9d72e7c..f5878e4 100644 --- a/otis/src/app/app-routing.module.ts +++ b/otis/src/app/app-routing.module.ts @@ -3,7 +3,6 @@ import { Routes, RouterModule } from '@angular/router'; import { LoginComponent } from './auth/login/login.component'; import { LogoutComponent } from './auth/logout/logout.component'; -import { HomeComponent } from './home/home.component'; const routes: Routes = [ { @@ -72,7 +71,7 @@ const routes: Routes = [ }, { path: 'login', component: LoginComponent }, { path: 'logout', component: LogoutComponent }, - { path: '', component: HomeComponent }, + { path: '', redirectTo: '/cases', pathMatch: 'full' }, ]; @NgModule({ imports: [ diff --git a/otis/src/app/app.module.ts b/otis/src/app/app.module.ts index 6983993..34a745a 100644 --- a/otis/src/app/app.module.ts +++ b/otis/src/app/app.module.ts @@ -27,14 +27,13 @@ import { AppComponent } from './app.component'; import { LoginComponent } from './auth/login/login.component'; import { LogoutComponent } from './auth/logout/logout.component'; import { CoreModule } from './core/core.module'; -import { HomeComponent } from './home/home.component'; import { NavBarComponent } from './nav-bar/nav-bar.component'; import { SharedModule } from './shared/shared.module'; registerLocaleData(enIN); @NgModule({ - declarations: [AppComponent, LoginComponent, LogoutComponent, HomeComponent, NavBarComponent], + declarations: [AppComponent, LoginComponent, LogoutComponent, NavBarComponent], imports: [ BrowserModule, AppRoutingModule, diff --git a/otis/src/app/cases/case-detail/case-detail.component.html b/otis/src/app/cases/case-detail/case-detail.component.html index 851f0aa..9bb9048 100644 --- a/otis/src/app/cases/case-detail/case-detail.component.html +++ b/otis/src/app/cases/case-detail/case-detail.component.html @@ -52,7 +52,14 @@ > Title - +
- Proceedings + Proceedings / Action to be taken + >
- + + Compliance Date + + + + + Next Hearing Date Next Hearing Date - Not Implemented + {{ nextHearingDate(row) }} diff --git a/otis/src/app/cases/case-list/case-list.component.ts b/otis/src/app/cases/case-list/case-list.component.ts index e560f99..1696d6e 100644 --- a/otis/src/app/cases/case-list/case-list.component.ts +++ b/otis/src/app/cases/case-list/case-list.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MatPaginator } from '@angular/material/paginator'; import { ActivatedRoute } from '@angular/router'; -import { Observable, of as observableOf } from 'rxjs'; +import { Observable } from 'rxjs'; import { distinctUntilChanged, startWith, switchMap, tap } from 'rxjs/operators'; import { Case } from '../../core/case'; @@ -61,4 +61,9 @@ export class CaseListComponent implements OnInit { }); this.dataSource = new CaseListDataSource(this.list, this.paginator); } + + nextHearingDate(row: Case): string { + const date = row.hearings.map((x) => x.nextHearingDate).find((x) => !!x); + return date ? date : ''; + } } diff --git a/otis/src/app/core/hearing.ts b/otis/src/app/core/hearing.ts index 1447137..222e8a0 100644 --- a/otis/src/app/core/hearing.ts +++ b/otis/src/app/core/hearing.ts @@ -7,6 +7,7 @@ export class Hearing { bench: string; courtStatus: CourtStatus | null; proceedings: string; + complianceDate: string | null; nextHearingDate: string | null; public constructor(init?: Partial) { @@ -16,7 +17,8 @@ export class Hearing { this.bench = ''; this.courtStatus = null; this.proceedings = ''; - this.nextHearingDate = ''; + this.complianceDate = null; + this.nextHearingDate = null; Object.assign(this, init); } } diff --git a/otis/src/app/home/home.component.css b/otis/src/app/home/home.component.css deleted file mode 100644 index 50698ad..0000000 --- a/otis/src/app/home/home.component.css +++ /dev/null @@ -1,16 +0,0 @@ -.square-button { - min-width: 150px; - max-width: 150px; - min-height: 150px; - max-height: 150px; - cursor: pointer; - margin: 20px; -} -.item-name { - text-align: center; - padding: 0.5rem; -} - -.center { - text-align: center; -} diff --git a/otis/src/app/home/home.component.html b/otis/src/app/home/home.component.html deleted file mode 100644 index afddc96..0000000 --- a/otis/src/app/home/home.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
-

Backend: v{{ auth.user?.ver }} / Frontend: v{{ version }}

-
diff --git a/otis/src/app/home/home.component.spec.ts b/otis/src/app/home/home.component.spec.ts deleted file mode 100644 index 3fa303d..0000000 --- a/otis/src/app/home/home.component.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { HomeComponent } from './home.component'; - -describe('HomeComponent', () => { - let component: HomeComponent; - let fixture: ComponentFixture; - - beforeEach( - waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [HomeComponent], - }).compileComponents(); - }), - ); - - beforeEach(() => { - fixture = TestBed.createComponent(HomeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/otis/src/app/home/home.component.ts b/otis/src/app/home/home.component.ts deleted file mode 100644 index 0571be3..0000000 --- a/otis/src/app/home/home.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component } from '@angular/core'; - -import { environment } from '../../environments/environment'; -import { AuthService } from '../auth/auth.service'; - -@Component({ - selector: 'app-home', - templateUrl: './home.component.html', - styleUrls: ['./home.component.css'], -}) -export class HomeComponent { - version: string; - - constructor(public auth: AuthService) { - this.version = environment.version; - } -}