Skip to content

Commit

Permalink
Merge pull request #534 from oakdbca/occ-uat-changes
Browse files Browse the repository at this point in the history
UAT Changes
  • Loading branch information
xzzy authored Nov 18, 2024
2 parents 105578f + ff68b95 commit e6dbcf2
Show file tree
Hide file tree
Showing 92 changed files with 1,089 additions and 4,292 deletions.
351 changes: 11 additions & 340 deletions boranga/components/conservation_status/api.py

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions boranga/components/conservation_status/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class CommonwealthConservationList(AbstractConservationList):
class Meta:
ordering = ["code"]
app_label = "boranga"
verbose_name = "Commonwealth Conservation List"
verbose_name = "Commonwealth Conservation Category"


class ConservationChangeCode(ArchivableModel):
Expand Down Expand Up @@ -567,11 +567,14 @@ class ConservationStatus(SubmitterInformationModelMixin, RevisionedMixin):
null=True,
related_name="curr_iucn_version",
)
commonwealth_conservation_list = models.ForeignKey(
# Although this field is a relationship to CommonwealthConservationList
# the business requirements was that it should be called a "category"
commonwealth_conservation_category = models.ForeignKey(
CommonwealthConservationList,
on_delete=models.PROTECT,
blank=True,
null=True,
# Leave the following as _list otherwise django has remove the field and create a new one
related_name="curr_commonwealth_conservation_list",
)
other_conservation_assessment = models.CharField(
Expand Down Expand Up @@ -820,7 +823,9 @@ def allowed_assessors(self):
@property
def assessor_recipients(self):
recipients = []
group_ids = member_ids(GROUP_NAME_CONSERVATION_STATUS_ASSESSOR)
group_ids = member_ids(
GROUP_NAME_CONSERVATION_STATUS_ASSESSOR, include_superusers=False
)
for id in group_ids:
recipients.append(EmailUser.objects.get(id=id).email)
return recipients
Expand Down Expand Up @@ -1918,7 +1923,9 @@ def get_related_items(self, filter_type, **kwargs):
for field_object in field_objects:
if field_object:
related_item = field_object.as_related_item
return_list.append(related_item)
if related_item not in return_list:
return_list.append(related_item)

species_filter = []
if "occurrences" in related_field_names:
species_filter.append("occurrences")
Expand All @@ -1928,12 +1935,15 @@ def get_related_items(self, filter_type, **kwargs):
if self.species:
species_occurences = self.species.get_related_items(occ_filter_type)
if species_occurences:
# return_list.append(species_occurences)
return_list += species_occurences
if self.community:
community_occurences = self.community.get_related_items(occ_filter_type)
if community_occurences:
return_list += community_occurences

# Remove duplicates
return_list = list(set(return_list))

return return_list

@property
Expand Down Expand Up @@ -1971,7 +1981,7 @@ def related_item_descriptor(self):

@property
def related_item_status(self):
return self.get_processing_status_display
return self.get_processing_status_display()

@property
def is_finalised(self):
Expand Down
56 changes: 29 additions & 27 deletions boranga/components/conservation_status/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class BasicConservationStatusSerializer(serializers.ModelSerializer):
wa_priority_category = serializers.CharField(
source="wa_priority_category.code", allow_null=True
)
commonwealth_conservation_list = serializers.CharField(
source="commonwealth_conservation_list.code", allow_null=True
commonwealth_conservation_category = serializers.CharField(
source="commonwealth_conservation_category.code", allow_null=True
)
under_review = serializers.SerializerMethodField()

Expand All @@ -60,7 +60,7 @@ class Meta:
"wa_legislative_list",
"wa_legislative_category",
"wa_priority_category",
"commonwealth_conservation_list",
"commonwealth_conservation_category",
"other_conservation_assessment",
"conservation_criteria",
"under_review",
Expand Down Expand Up @@ -163,8 +163,8 @@ class ListSpeciesConservationStatusSerializer(serializers.ModelSerializer):
wa_legislative_category = serializers.CharField(
source="wa_legislative_category.code", allow_null=True
)
commonwealth_conservation_list = serializers.CharField(
source="commonwealth_conservation_list.code", allow_null=True
commonwealth_conservation_category = serializers.CharField(
source="commonwealth_conservation_category.code", allow_null=True
)
processing_status = serializers.CharField(source="get_processing_status_display")
assessor_process = serializers.SerializerMethodField(read_only=True)
Expand Down Expand Up @@ -202,7 +202,7 @@ class Meta:
"wa_priority_category",
"wa_legislative_list",
"wa_legislative_category",
"commonwealth_conservation_list",
"commonwealth_conservation_category",
"other_conservation_assessment",
"conservation_criteria",
"processing_status",
Expand Down Expand Up @@ -239,7 +239,7 @@ class Meta:
"wa_priority_category",
"wa_legislative_list",
"wa_legislative_category",
"commonwealth_conservation_list",
"commonwealth_conservation_category",
"processing_status",
"customer_status",
"can_user_edit",
Expand Down Expand Up @@ -360,8 +360,8 @@ class ListCommunityConservationStatusSerializer(serializers.ModelSerializer):
wa_legislative_category = serializers.CharField(
source="wa_legislative_category.code", allow_null=True
)
commonwealth_conservation_list = serializers.CharField(
source="commonwealth_conservation_list.code", allow_null=True
commonwealth_conservation_category = serializers.CharField(
source="commonwealth_conservation_category.code", allow_null=True
)
change_code = serializers.CharField(
source="change_code.code", read_only=True, allow_null=True
Expand Down Expand Up @@ -400,7 +400,7 @@ class Meta:
"wa_priority_category",
"wa_legislative_list",
"wa_legislative_category",
"commonwealth_conservation_list",
"commonwealth_conservation_category",
"other_conservation_assessment",
"conservation_criteria",
"effective_from",
Expand Down Expand Up @@ -433,7 +433,7 @@ class Meta:
"wa_priority_category",
"wa_legislative_list",
"wa_legislative_category",
"commonwealth_conservation_list",
"commonwealth_conservation_category",
"other_conservation_assessment",
"conservation_criteria",
"effective_from",
Expand Down Expand Up @@ -536,7 +536,9 @@ class BaseConservationStatusSerializer(serializers.ModelSerializer):
wa_priority_list = serializers.SerializerMethodField(read_only=True)
wa_priority_category = serializers.SerializerMethodField(read_only=True)
iucn_version = serializers.SerializerMethodField(read_only=True)
commonwealth_conservation_list = serializers.SerializerMethodField(read_only=True)
commonwealth_conservation_category = serializers.SerializerMethodField(
read_only=True
)

class Meta:
model = ConservationStatus
Expand All @@ -558,8 +560,8 @@ class Meta:
"wa_priority_list",
"wa_priority_category_id",
"wa_priority_category",
"commonwealth_conservation_list_id",
"commonwealth_conservation_list",
"commonwealth_conservation_category_id",
"commonwealth_conservation_category",
"other_conservation_assessment",
"conservation_criteria",
"comment",
Expand Down Expand Up @@ -629,17 +631,17 @@ def get_wa_priority_category(self, obj):

return obj.wa_priority_category.code

def get_commonwealth_conservation_list(self, obj):
if not obj.commonwealth_conservation_list:
def get_commonwealth_conservation_category(self, obj):
if not obj.commonwealth_conservation_category:
return None

if (
obj.commonwealth_conservation_list.code
and obj.commonwealth_conservation_list.label
obj.commonwealth_conservation_category.code
and obj.commonwealth_conservation_category.label
):
return f"{obj.commonwealth_conservation_list.code} - {obj.commonwealth_conservation_list.label}"
return f"{obj.commonwealth_conservation_category.code} - {obj.commonwealth_conservation_category.label}"

return obj.commonwealth_conservation_list.code
return obj.commonwealth_conservation_category.code

def get_readonly(self, obj):
return False
Expand Down Expand Up @@ -784,7 +786,7 @@ class Meta:
"iucn_version_id",
"wa_priority_list_id",
"wa_priority_category_id",
"commonwealth_conservation_list_id",
"commonwealth_conservation_category_id",
"other_conservation_assessment",
"conservation_criteria",
]
Expand Down Expand Up @@ -849,8 +851,8 @@ class Meta:
"wa_priority_list",
"wa_priority_category_id",
"wa_priority_category",
"commonwealth_conservation_list_id",
"commonwealth_conservation_list",
"commonwealth_conservation_category_id",
"commonwealth_conservation_category",
"other_conservation_assessment",
"conservation_criteria",
"comment",
Expand Down Expand Up @@ -1087,7 +1089,7 @@ class SaveSpeciesConservationStatusSerializer(BaseConservationStatusSerializer):
wa_priority_category_id = serializers.IntegerField(
required=False, allow_null=True, write_only=True
)
commonwealth_conservation_list_id = serializers.IntegerField(
commonwealth_conservation_category_id = serializers.IntegerField(
required=False, allow_null=True, write_only=True
)
change_code_id = serializers.IntegerField(
Expand All @@ -1110,7 +1112,7 @@ class Meta:
"iucn_version_id",
"wa_priority_list_id",
"wa_priority_category_id",
"commonwealth_conservation_list_id",
"commonwealth_conservation_category_id",
"other_conservation_assessment",
"conservation_criteria",
"comment",
Expand Down Expand Up @@ -1246,7 +1248,7 @@ class SaveCommunityConservationStatusSerializer(BaseConservationStatusSerializer
wa_priority_category_id = serializers.IntegerField(
required=False, allow_null=True, write_only=True
)
commonwealth_conservation_list_id = serializers.IntegerField(
commonwealth_conservation_category_id = serializers.IntegerField(
required=False, allow_null=True, write_only=True
)
change_code_id = serializers.IntegerField(
Expand All @@ -1264,7 +1266,7 @@ class Meta:
"iucn_version_id",
"wa_priority_list_id",
"wa_priority_category_id",
"commonwealth_conservation_list_id",
"commonwealth_conservation_category_id",
"other_conservation_assessment",
"conservation_criteria",
"comment",
Expand Down
25 changes: 25 additions & 0 deletions boranga/components/main/fixtures/helptextentries.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/home/oak/dev/boranga
[
{
"model": "boranga.helptextentry",
Expand Down Expand Up @@ -70,5 +71,29 @@
"authenticated_users_only": true,
"internal_users_only": true
}
},
{
"model": "boranga.helptextentry",
"pk": 10,
"fields": {
"archived": false,
"section_id": "occurrence_report_is_for_occurrence_number",
"text": "The proposed or suggested occurrence number to link the occurence report to. For legacy OCRs the Population ID may be used.",
"icon_with_popover": true,
"authenticated_users_only": true,
"internal_users_only": true
}
},
{
"model": "boranga.helptextentry",
"pk": 11,
"fields": {
"archived": false,
"section_id": "occurrence_report_for_occurrence_name",
"text": "The occurrence name to the link the occurrence report to (or a suggested name if a new occurrence is to be created).",
"icon_with_popover": true,
"authenticated_users_only": true,
"internal_users_only": true
}
}
]
12 changes: 5 additions & 7 deletions boranga/components/main/related_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ def __init__(

def __hash__(self):
return hash(
(
self.model_name,
self.identifier,
self.descriptor,
self.status,
self.action_url,
)
self.model_name
+ self.identifier
+ self.descriptor
+ self.status
+ self.action_url
)

def __eq__(self, other):
Expand Down
Loading

0 comments on commit e6dbcf2

Please sign in to comment.