Skip to content

Commit

Permalink
Merge pull request #513 from oakdbca/main
Browse files Browse the repository at this point in the history
Archivable Models, Blacklist Fixes and Migrated From ID
  • Loading branch information
xzzy authored Aug 9, 2024
2 parents eb95db4 + 8b80ae7 commit f8d85ed
Show file tree
Hide file tree
Showing 45 changed files with 1,128 additions and 311 deletions.
15 changes: 15 additions & 0 deletions boranga/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from boranga import helpers as boranga_helpers
from boranga.components.main.models import ArchivableManager, ArchivableModel
from boranga.components.users.models import ExternalContributorBlacklist


class DeleteProtectedModelAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -134,6 +135,20 @@ def clean(self):
"Only external users can be added to external groups."
)

if system_group.name != settings.GROUP_NAME_EXTERNAL_CONTRIBUTOR:
return cleaned_data

if not ExternalContributorBlacklist.objects.filter(
email=emailuser.email
).exists():
return cleaned_data

raise ValidationError(
f"The email address {emailuser.email} is blacklisted. "
"Please remove the email from the blacklist and the user will be automatically "
"added back into the external contributor group."
)


class CustomSystemGroupPermissionInline(SystemGroupPermissionInline):
form = CustomSystemGroupPermissionInlineForm
Expand Down
62 changes: 52 additions & 10 deletions boranga/components/occurrence/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,31 +424,73 @@ class PrimaryDetectionMethodAdmin(DeleteProtectedModelAdmin):
# more work on the frontend due to django-multiselectfield


class PlantCountMethodAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class PlantCountAccuracyAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class PlantConditionAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class ObservationMethodAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class LocationAccuracyAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class IntensityAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class IdentificationCertaintyAdmin(
ArchivableModelAdminMixin, DeleteProtectedModelAdmin
):
list_display = ["name"]


class DrainageAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class DeathReasonAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


class CountedSubjectAdmin(ArchivableModelAdminMixin, DeleteProtectedModelAdmin):
list_display = ["name"]


# Each of the following models will be available to Django Admin.
admin.site.register(LandForm, LandFormAdmin)
admin.site.register(RockType, RockTypeAdmin)
admin.site.register(SoilType, SoilTypeAdmin)
admin.site.register(SiteType, SiteTypeAdmin)
admin.site.register(SoilColour, SoilColourAdmin)
admin.site.register(SoilCondition, SoilConditionAdmin)
admin.site.register(Drainage, DeleteProtectedModelAdmin)
admin.site.register(Intensity, DeleteProtectedModelAdmin)
admin.site.register(ObservationMethod, DeleteProtectedModelAdmin)
admin.site.register(PlantCountMethod, DeleteProtectedModelAdmin)
admin.site.register(PlantCountAccuracy, DeleteProtectedModelAdmin)
admin.site.register(CountedSubject, DeleteProtectedModelAdmin)
admin.site.register(PlantCondition, DeleteProtectedModelAdmin)
admin.site.register(Drainage, DrainageAdmin)
admin.site.register(Intensity, IntensityAdmin)
admin.site.register(ObservationMethod, ObservationMethodAdmin)
admin.site.register(PlantCountMethod, PlantCountMethodAdmin)
admin.site.register(PlantCountAccuracy, PlantCountAccuracyAdmin)
admin.site.register(CountedSubject, CountedSubjectAdmin)
admin.site.register(PlantCondition, PlantConditionAdmin)
admin.site.register(PrimaryDetectionMethod, PrimaryDetectionMethodAdmin)
admin.site.register(SecondarySign, SecondarySignAdmin)
admin.site.register(ReproductiveState, ReproductiveStateAdmin)
admin.site.register(DeathReason, DeleteProtectedModelAdmin)
admin.site.register(DeathReason, DeathReasonAdmin)
admin.site.register(AnimalHealth, DeleteProtectedModelAdmin)
admin.site.register(IdentificationCertainty, DeleteProtectedModelAdmin)
admin.site.register(IdentificationCertainty, IdentificationCertaintyAdmin)
admin.site.register(SampleType, SampleTypeAdmin)
admin.site.register(SampleDestination, SampleDestinationAdmin)
admin.site.register(PermitType, PermitTypeAdmin)
admin.site.register(Datum, DatumAdmin)
admin.site.register(CoordinateSource, CoordinateSourceAdmin)
admin.site.register(LocationAccuracy, DeleteProtectedModelAdmin)
admin.site.register(LocationAccuracy, LocationAccuracyAdmin)
admin.site.register(WildStatus, WildStatusAdmin)
admin.site.register(OccurrenceSite)
60 changes: 30 additions & 30 deletions boranga/components/occurrence/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def location_list_of_values(self, request, *args, **kwargs):
}
)
location_accuracy_list = []
values = LocationAccuracy.objects.all()
values = LocationAccuracy.objects.active()
if values:
for val in values:
location_accuracy_list.append(
Expand Down Expand Up @@ -1008,7 +1008,7 @@ def list_of_values(self, request, *args, **kwargs):
}
)
drainage_list = []
drainages = Drainage.objects.all()
drainages = Drainage.objects.active()
if drainages:
for val in drainages:
drainage_list.append(
Expand All @@ -1018,7 +1018,7 @@ def list_of_values(self, request, *args, **kwargs):
}
)
intensity_list = []
intensities = Intensity.objects.all()
intensities = Intensity.objects.active()
if intensities:
for val in intensities:
intensity_list.append(
Expand Down Expand Up @@ -1205,7 +1205,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
)

observation_method_list = []
values = ObservationMethod.objects.all()
values = ObservationMethod.objects.active()
if values:
for val in values:
observation_method_list.append(
Expand All @@ -1215,7 +1215,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
plant_count_method_list = []
values = PlantCountMethod.objects.all()
values = PlantCountMethod.objects.active()
if values:
for val in values:
plant_count_method_list.append(
Expand All @@ -1225,7 +1225,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
plant_count_accuracy_list = []
values = PlantCountAccuracy.objects.all()
values = PlantCountAccuracy.objects.active()
if values:
for val in values:
plant_count_accuracy_list.append(
Expand All @@ -1235,7 +1235,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
plant_condition_list = []
values = PlantCondition.objects.all()
values = PlantCondition.objects.active()
if values:
for val in values:
plant_condition_list.append(
Expand All @@ -1245,7 +1245,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
counted_subject_list = []
values = CountedSubject.objects.all()
values = CountedSubject.objects.active()
if values:
for val in values:
counted_subject_list.append(
Expand Down Expand Up @@ -1285,7 +1285,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
death_reason_list = []
values = DeathReason.objects.all()
values = DeathReason.objects.active()
if values:
for val in values:
death_reason_list.append(
Expand All @@ -1305,7 +1305,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
identification_certainty_list = []
values = IdentificationCertainty.objects.all()
values = IdentificationCertainty.objects.active()
if values:
for val in values:
identification_certainty_list.append(
Expand Down Expand Up @@ -1375,7 +1375,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
"""used for Occurrence Report external form"""

plant_count_method_list = []
values = PlantCountMethod.objects.all()
values = PlantCountMethod.objects.active()
if values:
for val in values:
plant_count_method_list.append(
Expand All @@ -1385,7 +1385,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
}
)
plant_count_accuracy_list = []
values = PlantCountAccuracy.objects.all()
values = PlantCountAccuracy.objects.active()
if values:
for val in values:
plant_count_accuracy_list.append(
Expand All @@ -1395,7 +1395,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
}
)
plant_condition_list = []
values = PlantCondition.objects.all()
values = PlantCondition.objects.active()
if values:
for val in values:
plant_condition_list.append(
Expand All @@ -1405,7 +1405,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
}
)
counted_subject_list = []
values = CountedSubject.objects.all()
values = CountedSubject.objects.active()
if values:
for val in values:
counted_subject_list.append(
Expand Down Expand Up @@ -1465,7 +1465,7 @@ def animal_observation_list_of_values(self, request, *args, **kwargs):
}
)
death_reason_list = []
values = DeathReason.objects.all()
values = DeathReason.objects.active()
if values:
for val in values:
death_reason_list.append(
Expand Down Expand Up @@ -4512,7 +4512,7 @@ def location_list_of_values(self, request, *args, **kwargs):
}
)
location_accuracy_list = []
values = LocationAccuracy.objects.all()
values = LocationAccuracy.objects.active()
if values:
for val in values:
location_accuracy_list.append(
Expand Down Expand Up @@ -5057,7 +5057,7 @@ def list_of_values(self, request, *args, **kwargs):
}
)
drainage_list = []
drainages = Drainage.objects.all()
drainages = Drainage.objects.active()
if drainages:
for val in drainages:
drainage_list.append(
Expand All @@ -5067,7 +5067,7 @@ def list_of_values(self, request, *args, **kwargs):
}
)
intensity_list = []
intensities = Intensity.objects.all()
intensities = Intensity.objects.active()
if intensities:
for val in intensities:
intensity_list.append(
Expand Down Expand Up @@ -5106,7 +5106,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
)

observation_method_list = []
values = ObservationMethod.objects.all()
values = ObservationMethod.objects.active()
if values:
for val in values:
observation_method_list.append(
Expand All @@ -5116,7 +5116,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
plant_count_method_list = []
values = PlantCountMethod.objects.all()
values = PlantCountMethod.objects.active()
if values:
for val in values:
plant_count_method_list.append(
Expand All @@ -5126,7 +5126,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
plant_count_accuracy_list = []
values = PlantCountAccuracy.objects.all()
values = PlantCountAccuracy.objects.active()
if values:
for val in values:
plant_count_accuracy_list.append(
Expand All @@ -5136,7 +5136,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
plant_condition_list = []
values = PlantCondition.objects.all()
values = PlantCondition.objects.active()
if values:
for val in values:
plant_condition_list.append(
Expand All @@ -5146,7 +5146,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
counted_subject_list = []
values = CountedSubject.objects.all()
values = CountedSubject.objects.active()
if values:
for val in values:
counted_subject_list.append(
Expand Down Expand Up @@ -5186,7 +5186,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
death_reason_list = []
values = DeathReason.objects.all()
values = DeathReason.objects.active()
if values:
for val in values:
death_reason_list.append(
Expand All @@ -5206,7 +5206,7 @@ def observation_list_of_values(self, request, *args, **kwargs):
}
)
identification_certainty_list = []
values = IdentificationCertainty.objects.all()
values = IdentificationCertainty.objects.active()
if values:
for val in values:
identification_certainty_list.append(
Expand Down Expand Up @@ -5276,7 +5276,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
"""used for Occurrence external form"""

plant_count_method_list = []
values = PlantCountMethod.objects.all()
values = PlantCountMethod.objects.active()
if values:
for val in values:
plant_count_method_list.append(
Expand All @@ -5286,7 +5286,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
}
)
plant_count_accuracy_list = []
values = PlantCountAccuracy.objects.all()
values = PlantCountAccuracy.objects.active()
if values:
for val in values:
plant_count_accuracy_list.append(
Expand All @@ -5296,7 +5296,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
}
)
plant_condition_list = []
values = PlantCondition.objects.all()
values = PlantCondition.objects.active()
if values:
for val in values:
plant_condition_list.append(
Expand All @@ -5306,7 +5306,7 @@ def plant_count_list_of_values(self, request, *args, **kwargs):
}
)
counted_subject_list = []
values = CountedSubject.objects.all()
values = CountedSubject.objects.active()
if values:
for val in values:
counted_subject_list.append(
Expand Down Expand Up @@ -5366,7 +5366,7 @@ def animal_observation_list_of_values(self, request, *args, **kwargs):
}
)
death_reason_list = []
values = DeathReason.objects.all()
values = DeathReason.objects.active()
if values:
for val in values:
death_reason_list.append(
Expand Down
Loading

0 comments on commit f8d85ed

Please sign in to comment.