Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace operation rep #2679

Merged
merged 13 commits into from
Jan 23, 2025
7 changes: 4 additions & 3 deletions bc_obps/registration/api/v2/_contacts/contact_id.py
Original file line number Diff line number Diff line change
@@ -4,17 +4,18 @@
from registration.constants import CONTACT_TAGS
from registration.models.contact import Contact
from registration.schema.v1.contact import ContactIn, ContactOut
from service.contact_service import ContactService, ContactWithPlacesAssigned
from common.api.utils import get_current_user_guid
from registration.decorators import handle_http_errors
from registration.api.router import router
from registration.schema.generic import Message
from service.contact_service_v2 import ContactServiceV2, ContactWithPlacesAssigned
from service.contact_service import ContactService
from service.error_service.custom_codes_4xx import custom_codes_4xx


@router.get(
"/contacts/{contact_id}",
response={200: ContactOut, custom_codes_4xx: Message},
response={200: ContactWithPlacesAssigned, custom_codes_4xx: Message},
tags=CONTACT_TAGS,
description="""Retrieves the details of a specific contact by its ID. The endpoint checks if the current user is authorized to access the contact.
Industry users can only access contacts that are associated with their own operator. If an unauthorized user attempts to access the contact, an error is raised.""",
@@ -23,7 +24,7 @@
)
@handle_http_errors()
def get_contact(request: HttpRequest, contact_id: int) -> Tuple[Literal[200], Optional[ContactWithPlacesAssigned]]:
return 200, ContactService.get_with_places_assigned(get_current_user_guid(request), contact_id)
return 200, ContactServiceV2.get_with_places_assigned_v2(contact_id)


@router.put(
8 changes: 6 additions & 2 deletions bc_obps/registration/api/v2/_operations/operation_id.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from typing import Literal, Tuple
from uuid import UUID
from registration.schema.v2.operation import OperationOutV2, OperationInformationIn, OperationOutWithDocuments
from registration.schema.v2.operation import (
OperationInformationInUpdate,
OperationOutV2,
OperationOutWithDocuments,
)
from common.permissions import authorize
from django.http import HttpRequest
from registration.constants import OPERATION_TAGS
@@ -57,6 +61,6 @@ def get_operation_with_documents(request: HttpRequest, operation_id: UUID) -> Tu
)
@handle_http_errors()
def update_operation(
request: HttpRequest, operation_id: UUID, payload: OperationInformationIn
request: HttpRequest, operation_id: UUID, payload: OperationInformationInUpdate
) -> Tuple[Literal[200], Operation]:
return 200, OperationServiceV2.update_operation(get_current_user_guid(request), payload, operation_id)
8 changes: 8 additions & 0 deletions bc_obps/registration/fixtures/mock/address.json
Original file line number Diff line number Diff line change
@@ -208,5 +208,13 @@
"province": "ON",
"postal_code": "N2L 3G1"
}
},
{
"model": "registration.address",
"pk": 21,
"fields": {
"street_address": "Incomplete address",
"municipality": "Grove"
}
}
]
40 changes: 19 additions & 21 deletions bc_obps/registration/fixtures/mock/contact.json
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@
"pk": 1,
"fields": {
"business_role": "Operation Representative",
"first_name": "John",
"last_name": "Doe",
"first_name": "Alice",
"last_name": "Art",
"position_title": "Manager",
"address": 1,
"email": "john.doe@example.com",
"email": "alice.art@example.com",
"phone_number": "+16044011234"
}
},
@@ -17,11 +17,11 @@
"pk": 2,
"fields": {
"business_role": "Operation Representative",
"first_name": "Jane",
"last_name": "Smith",
"first_name": "Althea",
"last_name": "Ark",
"position_title": "Manager",
"address": 2,
"email": "jane.smith@example.com",
"email": "althea.ark@example.com",
"phone_number": "+16044011234"
}
},
@@ -30,11 +30,11 @@
"pk": 3,
"fields": {
"business_role": "Operation Representative",
"first_name": "Alice",
"last_name": "Johnson",
"first_name": "Bill",
"last_name": "Blue",
"position_title": "Manager",
"address": 3,
"email": "alice.johnson@example.com",
"email": "bill.blue@example.com",
"phone_number": "+16044011235"
}
},
@@ -56,11 +56,10 @@
"pk": 5,
"fields": {
"business_role": "Operation Representative",
"first_name": "Carol",
"last_name": "Davis",
"first_name": "Blair",
"last_name": "Balloons - no address",
"position_title": "Manager",
"address": 5,
"email": "[email protected]",
"email": "[email protected]",
"phone_number": "+16044011237"
}
},
@@ -69,11 +68,11 @@
"pk": 6,
"fields": {
"business_role": "Operation Representative",
"first_name": "Dave",
"last_name": "Evans",
"first_name": "Bart",
"last_name": "Banker - incomplete address",
"position_title": "Manager",
"address": 6,
"email": "dave.evans@example.com",
"address": 21,
"email": "bart.banker@example.com",
"phone_number": "+16044011238"
}
},
@@ -135,9 +134,8 @@
"fields": {
"business_role": "Operation Representative",
"first_name": "Ivy",
"last_name": "Jones",
"last_name": "Jones - no address",
"position_title": "Manager",
"address": 11,
"email": "[email protected]",
"phone_number": "+16044011243"
}
@@ -148,9 +146,9 @@
"fields": {
"business_role": "Operation Representative",
"first_name": "Jack",
"last_name": "King",
"last_name": "King - incomplete address",
"position_title": "Manager",
"address": 12,
"address": 21,
"email": "[email protected]",
"phone_number": "+16044011244"
}
58 changes: 36 additions & 22 deletions bc_obps/registration/fixtures/mock/operation.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@
"bc_obps_regulated_operation": "24-0014",
"created_at": "2024-2-01T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "Reporting Operation"
"registration_purpose": "Reporting Operation",
"contacts": [1, 2]
}
},
{
@@ -34,8 +35,8 @@
"bc_obps_regulated_operation": "24-0015",
"created_at": "2024-2-02T15:27:00.000Z",
"activities": [1, 5],
"contacts": [10],
"registration_purpose": "OBPS Regulated Operation"
"registration_purpose": "OBPS Regulated Operation",
"contacts": [3, 4]
}
},
{
@@ -53,7 +54,6 @@
"status": "Draft",
"created_at": "2024-2-02T15:27:00.000Z",
"activities": [1, 5],
"contacts": [10],
"registration_purpose": "OBPS Regulated Operation"
}
},
@@ -75,8 +75,8 @@
"bc_obps_regulated_operation": "23-0001",
"created_at": "2024-1-31T15:27:00.000Z",
"activities": [1, 3],
"contacts": [14, 15],
"registration_purpose": "OBPS Regulated Operation"
"registration_purpose": "OBPS Regulated Operation",
"contacts": [3, 4]
}
},
{
@@ -97,8 +97,8 @@
"bc_obps_regulated_operation": "23-0002",
"created_at": "2024-1-30T15:27:00.000Z",
"activities": [1, 5],
"contacts": [10, 11, 12],
"registration_purpose": "OBPS Regulated Operation"
"registration_purpose": "OBPS Regulated Operation",
"contacts": [1]
}
},
{
@@ -120,7 +120,8 @@
"bc_obps_regulated_operation": "24-0003",
"created_at": "2024-1-29T15:27:00.000Z",
"activities": [1, 5],
"operation_has_multiple_operators": true
"operation_has_multiple_operators": true,
"contacts": [3]
}
},
{
@@ -141,7 +142,8 @@
"bc_obps_regulated_operation": "24-0004",
"created_at": "2024-1-28T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "Opted-in Operation"
"registration_purpose": "Opted-in Operation",
"contacts": [1]
}
},
{
@@ -161,7 +163,8 @@
"bc_obps_regulated_operation": "24-0005",
"created_at": "2024-1-27T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "Potential Reporting Operation"
"registration_purpose": "Potential Reporting Operation",
"contacts": [2]
}
},
{
@@ -181,7 +184,8 @@
"bc_obps_regulated_operation": "24-0006",
"created_at": "2024-1-26T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "Electricity Import Operation"
"registration_purpose": "Electricity Import Operation",
"contacts": [1]
}
},
{
@@ -202,7 +206,8 @@
"bc_obps_regulated_operation": "24-0007",
"created_at": "2024-1-25T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "New Entrant Operation"
"registration_purpose": "New Entrant Operation",
"contacts": [1]
}
},
{
@@ -221,7 +226,8 @@
"bc_obps_regulated_operation": "24-0008",
"created_at": "2024-1-24T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "Reporting Operation"
"registration_purpose": "Reporting Operation",
"contacts": [2]
}
},
{
@@ -242,7 +248,8 @@
"bc_obps_regulated_operation": "24-0009",
"created_at": "2024-1-23T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "OBPS Regulated Operation"
"registration_purpose": "OBPS Regulated Operation",
"contacts": [1, 2]
}
},
{
@@ -262,7 +269,8 @@
"bc_obps_regulated_operation": "24-0010",
"created_at": "2024-1-22T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "Reporting Operation"
"registration_purpose": "Reporting Operation",
"contacts": [1, 2]
}
},
{
@@ -282,7 +290,8 @@
"bc_obps_regulated_operation": "24-0011",
"created_at": "2024-1-21T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "OBPS Regulated Operation"
"registration_purpose": "OBPS Regulated Operation",
"contacts": [1]
}
},
{
@@ -360,7 +369,8 @@
"bc_obps_regulated_operation": "24-0012",
"created_at": "2024-1-17T15:27:00.000Z",
"activities": [1, 5],
"registration_purpose": "OBPS Regulated Operation"
"registration_purpose": "OBPS Regulated Operation",
"contacts": [3]
}
},
{
@@ -399,7 +409,8 @@
"bc_obps_regulated_operation": "24-0013",
"registration_purpose": "New Entrant Operation",
"created_at": "2024-1-15T15:27:00.000Z",
"activities": [1, 3]
"activities": [1, 3],
"contacts": [4]
}
},
{
@@ -419,7 +430,8 @@
"bc_obps_regulated_operation": "24-0016",
"created_at": "2024-1-14T15:27:00.000Z",
"registration_purpose": "Reporting Operation",
"activities": [1, 5]
"activities": [1, 5],
"contacts": [3]
}
},
{
@@ -438,7 +450,8 @@
"bc_obps_regulated_operation": "24-0017",
"created_at": "2024-1-13T15:27:00.000Z",
"registration_purpose": "Reporting Operation",
"activities": [1, 5]
"activities": [1, 5],
"contacts": [3]
}
},
{
@@ -457,7 +470,8 @@
"bc_obps_regulated_operation": "24-0018",
"created_at": "2024-1-12T15:27:00.000Z",
"registration_purpose": "Reporting Operation",
"activities": [1, 5]
"activities": [1, 5],
"contacts": [4]
}
},
{
Loading