Skip to content

Commit 40476d7

Browse files
Merge pull request #4796 from bcgov/1456-registration-app-tables-have-meaningful-metadata
1456 Update registration tables with comments
2 parents 9730995 + 9018d46 commit 40476d7

25 files changed

Lines changed: 7057 additions & 86 deletions

bc_obps/compliance/migrations/0052_update_timestamp_metadata.py

Lines changed: 1024 additions & 0 deletions
Large diffs are not rendered by default.

bc_obps/registration/migrations/0184_update_registration_metadata.py

Lines changed: 4158 additions & 0 deletions
Large diffs are not rendered by default.

bc_obps/registration/models/bc_greenhouse_gas_id.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,34 @@ class BcGreenhouseGasId(BaseModel):
1616
id = models.CharField(
1717
primary_key=True,
1818
max_length=255,
19-
db_comment="The BCGHG ID of an operation or facility",
19+
db_comment="The BCGHG (BC Greenhouse Gas) ID assigned to an operation or facility. Primary key.",
2020
validators=[
2121
RegexValidator(regex=BCGHG_ID_REGEX, message="BCGHG ID should be 11 digits, starting with 1 or 2.")
2222
],
2323
)
2424
issued_at = models.DateTimeField(
2525
auto_now_add=True,
26-
db_comment="The time the BCGHG ID was issued by an IRC user",
26+
db_comment="The time the BCGHG (BC Greenhouse Gas) ID was issued by an IRC user",
2727
)
2828
issued_by = models.ForeignKey(
2929
User,
3030
on_delete=models.PROTECT,
31-
db_comment="The IRC user who issued the BCGHG ID",
31+
db_comment="The IRC user who issued the BCGHG (BC Greenhouse Gas) ID. Foreign key to erc.user",
3232
blank=True,
3333
null=True,
3434
related_name="bc_greenhouse_gas_id_issued_by",
3535
)
3636
comments = models.TextField(
3737
blank=True,
38-
db_comment="Comments from admins in the case that a BCGHG ID is revoked",
38+
db_comment="Comments from admins in the case that a BCGHG (BC Greenhouse Gas) ID is revoked",
3939
)
4040
history = HistoricalRecords(
4141
table_name='erc_history"."bc_greenhouse_gas_id_history',
4242
history_user_id_field=models.UUIDField(null=True, blank=True),
4343
)
4444

4545
class Meta:
46-
db_table_comment = "Table to store BCGHG ID metadata. Once an operation or facility meets the criteria for an ID, then it is issued one."
46+
db_table_comment = "Table to store BCGHG (BC Greenhouse Gas) ID metadata. Once an operation or facility meets the criteria for an ID, then it is issued one."
4747
db_table = f'{Schemas.ERC.value}"."{RegistrationTableNames.BC_GREENHOUSE_GAS_ID.value}'
4848

4949
Rls = BcGreenhouseGasIdRls

bc_obps/registration/models/bc_obps_regulated_operation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,37 @@ class Statuses(models.TextChoices):
2020
id = models.CharField(
2121
primary_key=True,
2222
max_length=255,
23-
db_comment="The BC OBPS regulated operation ID of an operation when operation is approved",
23+
db_comment="The BC OBPS (Output-Based Pricing System) regulated operation ID of an operation when operation is approved",
2424
)
2525
issued_at = models.DateTimeField(
2626
auto_now_add=True,
27-
db_comment="The time the BC OBPS Regulated Operation ID was issued by an IRC user",
27+
db_comment="The time the BC OBPS (Output-Based Pricing System) Regulated Operation ID was issued by an IRC user",
2828
)
2929
issued_by = models.ForeignKey(
3030
User,
3131
on_delete=models.PROTECT,
32-
db_comment="The IRC user who issued the BC OBPS Regulated Operation ID",
32+
db_comment="The IRC user who issued the BC OBPS (Output-Based Pricing System) Regulated Operation ID. Foreign key to erc.user",
3333
blank=True,
3434
null=True,
3535
related_name="bc_obps_regulated_operation_issued_by",
3636
)
3737
comments = models.TextField(
3838
blank=True,
39-
db_comment="Comments from admins in the case that a BC OBPS Regulated Operation ID is revoked",
39+
db_comment="Comments from admins in the case that a BC OBPS (Output-Based Pricing System) Regulated Operation ID is revoked",
4040
)
4141
status = models.CharField(
4242
max_length=1000,
4343
choices=Statuses.choices,
4444
default=Statuses.ACTIVE,
45-
db_comment="The status of an operation.",
45+
db_comment="The status of the BC OBPS (Output-Based Pricing System) Regulated Operation ID (Active or Inactive). Inactive indicates the ID has been revoked.",
4646
)
4747
history = HistoricalRecords(
4848
table_name='erc_history"."bc_obps_regulated_operation_history',
4949
history_user_id_field=models.UUIDField(null=True, blank=True),
5050
)
5151

5252
class Meta:
53-
db_table_comment = "Table to store BC OBPS Regulated Operation metadata. Once an operation has been approved as a BC OBPS Regulated Operations (IRC has determined the operation meets certain criteria and should be included in the program), then it is issued an ID."
53+
db_table_comment = "Table to store BC OBPS (Output-Based Pricing System) Regulated Operation metadata. Once an operation has been approved as a BC OBPS (Output-Based Pricing System) Regulated Operations (IRC has determined the operation meets certain criteria and should be included in the program), then it is issued an ID."
5454
db_table = f'{Schemas.ERC.value}"."{RegistrationTableNames.BC_OBPS_REGULATED_OPERATION.value}'
5555

5656
Rls = BcObpsRegulatedOperationRls

bc_obps/registration/models/contact.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Contact(UserAndContactCommonInfo, TimeStampedModel):
1212
BusinessRole,
1313
on_delete=models.DO_NOTHING,
1414
related_name="contacts",
15-
db_comment="The role assigned to this contact which defines the permissions the contact has.",
15+
db_comment="The business role of this contact within the operator/operation (e.g. Operation Representative). Foreign key to erc.business_role",
1616
)
1717
address = models.ForeignKey(
1818
Address,
@@ -28,6 +28,7 @@ class Contact(UserAndContactCommonInfo, TimeStampedModel):
2828
blank=True,
2929
on_delete=models.DO_NOTHING,
3030
related_name="contacts",
31+
db_comment="The operator this contact belongs to. Foreign key to erc.operator",
3132
)
3233

3334
history = HistoricalRecords(

bc_obps/registration/models/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Document(TimeStampedModel, ScannedFileStorageMixin):
2222
DocumentType,
2323
on_delete=models.DO_NOTHING,
2424
related_name="documents",
25-
db_comment="Type of document, e.g., boundary map",
25+
db_comment="The type of this document (e.g. boundary map, process flow diagram). Foreign key to erc.document_type",
2626
)
2727
description = models.CharField(max_length=1000, blank=True, null=True, db_comment="Description of the document")
2828
operation = models.ForeignKey(
@@ -31,7 +31,7 @@ class Document(TimeStampedModel, ScannedFileStorageMixin):
3131
null=True,
3232
on_delete=models.DO_NOTHING,
3333
related_name="documents",
34-
db_comment="The operation that the document is about",
34+
db_comment="The operation this document is associated with. Foreign key to erc.operation",
3535
)
3636
history = HistoricalRecords(
3737
table_name='erc_history"."document_history',

bc_obps/registration/models/document_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DocumentType(BaseModel):
1717
)
1818

1919
class Meta:
20-
db_table_comment = "Table that contains types of documents."
20+
db_table_comment = "Lookup table containing valid document types that can be attached to operations (e.g. boundary map, process flow diagram, new entrant application, opt in signed statutory declaration). Documents are classified by type to allow the system to retrieve specific document kinds."
2121
db_table = f'{Schemas.ERC.value}"."{RegistrationTableNames.DOCUMENT_TYPE.value}'
2222

2323
Rls = DocumentTypeRls

bc_obps/registration/models/event/event_base_model.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55

66
class EventBaseModel(TimeStampedModel):
77
id = models.UUIDField(primary_key=True, default=uuid.uuid4, db_comment="Primary key to identify the event")
8-
effective_date = models.DateTimeField(db_comment="The effective date of the event")
9-
operation = models.ForeignKey(Operation, null=True, blank=True, on_delete=models.PROTECT)
8+
effective_date = models.DateTimeField(
9+
db_comment="The date on which the closure, restart, shutdown, or transfer takes effect operationally"
10+
)
11+
operation = models.ForeignKey(
12+
Operation,
13+
null=True,
14+
blank=True,
15+
on_delete=models.PROTECT,
16+
db_comment="The operation associated with this event. Foreign key to erc.operation",
17+
)
1018
facilities = models.ManyToManyField(Facility, blank=True)
1119

1220
class Meta(TimeStampedModel.Meta):

bc_obps/registration/models/event/transfer_event.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,43 @@ class Statuses(models.TextChoices):
1717
max_length=100,
1818
choices=Statuses.choices,
1919
default=Statuses.TO_BE_TRANSFERRED,
20+
db_comment="The status of the transfer event (e.g. To be transferred, Transferred, Complete)",
2021
)
2122
from_operator = models.ForeignKey(
2223
Operator,
2324
on_delete=models.PROTECT,
2425
related_name="transfer_events_from",
25-
db_comment="The operator who is transferring the operation or facility.",
26+
db_comment="The operator transferring the operation or facility to another operator. Foreign key to erc.operator",
2627
)
2728
to_operator = models.ForeignKey(
2829
Operator,
2930
on_delete=models.PROTECT,
3031
related_name="transfer_events_to",
31-
db_comment="The operator who is receiving the operation or facility.",
32+
db_comment="The operator receiving the operation or facility. Foreign key to erc.operator",
3233
)
3334
from_operation = models.ForeignKey(
3435
Operation,
3536
on_delete=models.PROTECT,
3637
null=True,
3738
blank=True,
3839
related_name="transfer_events_from",
39-
db_comment="The operation that facilities are being transferred from.",
40+
db_comment="The operation that facilities are being transferred away from (null if the entire operation is being transferred). Foreign key to erc.operation",
4041
)
4142
to_operation = models.ForeignKey(
4243
Operation,
4344
on_delete=models.PROTECT,
4445
null=True,
4546
blank=True,
4647
related_name="transfer_events_to",
47-
db_comment="The operation that facilities are being transferred to.",
48+
db_comment="The operation that facilities are being transferred into (null if no target operation yet exists). Foreign key to erc.operation",
4849
)
4950
history = HistoricalRecords(
5051
table_name='erc_history"."transfer_event_history',
5152
history_user_id_field=models.UUIDField(null=True, blank=True),
5253
)
5354

5455
class Meta(EventBaseModel.Meta):
55-
db_table_comment = "Transfer events for operations and/or facilities."
56+
db_table_comment = "Records transfer events where ownership of operations or facilities moves from one operator to another. The from_operator and to_operator fields identify the parties involved. The facilities M2M field (inherited from EventBaseModel) lists which facilities are being transferred."
5657
db_table = f'{Schemas.ERC.value}"."{RegistrationTableNames.TRANSFER_EVENT.value}'
5758
default_related_name = "transfer_events"
5859

bc_obps/registration/models/facility.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,43 @@ class Types(models.TextChoices):
2424
operation = models.ForeignKey(
2525
Operation,
2626
on_delete=models.PROTECT,
27-
db_comment="The operation who currently owns the facility (see the FacilityDesignatedOperationTimeline for past and upcoming ownership)",
27+
db_comment="The operation that currently owns this facility (historical ownership is tracked in erc.facility_designated_operation_timeline). Foreign key to erc.operation",
2828
related_name="facilities",
2929
)
3030
name = models.CharField(
3131
max_length=1000,
32-
db_comment="The name of the facility when the operation owned it",
32+
db_comment="The current name of the facility",
3333
unique=True,
3434
)
3535
is_current_year = models.BooleanField(
36-
blank=True, null=True, db_comment="The facility's starting date is within the current year or preceeding year"
36+
blank=True, null=True, db_comment="The facility's starting date is within the current year or preceding year"
3737
)
3838
starting_date = models.DateTimeField(
3939
blank=True, null=True, db_comment="The date of the facility starting operations"
4040
)
41-
type = models.CharField(max_length=100, choices=Types.choices, db_comment="The type of the facility")
41+
type = models.CharField(
42+
max_length=100,
43+
choices=Types.choices,
44+
db_comment="The type of the facility. Valid values: Single Facility, Large Facility, Medium Facility, Small Aggregate, Electricity Import",
45+
)
4246
address = models.ForeignKey(
4347
Address,
4448
on_delete=models.PROTECT,
45-
db_comment="The address of the facility",
49+
db_comment="The address of the facility. Foreign key to erc.address",
4650
blank=True,
4751
null=True,
4852
related_name='%(class)s_address',
4953
)
5054
swrs_facility_id = models.IntegerField(
51-
db_comment="A facility's SWRS facility ID.",
55+
db_comment="A facility's SWRS (Single Window Reporting System) facility ID. Only populated for facilities imported from the SWRS dataset.",
5256
blank=True,
5357
null=True,
5458
)
5559
bcghg_id = models.OneToOneField(
5660
"BcGreenhouseGasId",
5761
on_delete=models.PROTECT,
5862
max_length=1000,
59-
db_comment="A facility's BCGHG identifier.",
63+
db_comment="A facility's BCGHG (BC Greenhouse Gas) identifier. Foreign key to erc.bc_greenhouse_gas_id",
6064
blank=True,
6165
null=True,
6266
)
@@ -84,7 +88,7 @@ class Types(models.TextChoices):
8488
)
8589

8690
class Meta(TimeStampedModel.Meta):
87-
db_table_comment = "Contains data on facilities that emit carbon emissions and must report them to Clean Growth. A Linear Facilities Operation is made up of several different facilities whereas a Single Facility Operation has only one facility. In the case of a single facility operation, much of the data in this table will overlap with the parent record in the operation table."
91+
db_table_comment = "Contains data on facilities that emit carbon emissions and must report them to Clean Growth. A facility is a distinct location or unit within an industrial operation. A Linear Facilities Operation (LFO) is made up of several different facilities whereas a Single Facility Operation (SFO) has only one facility. In the case of an SFO, much of the data in this table will overlap with the parent record in the operation table."
8892
db_table = f'{Schemas.ERC.value}"."{RegistrationTableNames.FACILITY.value}'
8993
verbose_name_plural = "Facilities"
9094
triggers = [

0 commit comments

Comments
 (0)