diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index bb0f16c..7831d9d 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -268,10 +268,6 @@ class RescueOrganization(models.Model): """ return self.instagram or self.facebook or self.website or self.phone_number or self.email or self.fediverse_profile - def set_exclusion_from_checks(self): - self.exclude_from_check = True - self.save() - @property def child_organizations(self): return RescueOrganization.objects.filter(parent_org=self) @@ -423,9 +419,10 @@ class AdoptionNotice(models.Model): @property def num_per_sex(self): + print(f"{self.pk} x") num_per_sex = dict() for sex in SexChoices: - num_per_sex[sex] = self.animals.filter(sex=sex).count() + num_per_sex[sex] = len([animal for animal in self.animals if animal.sex == sex]) return num_per_sex @property diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 3c76b28..a1c2028 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -866,8 +866,7 @@ def rescue_organization_check(request, context=None): action = request.POST.get("action") if action == "checked": rescue_org.set_checked() - elif action == "exclude": - rescue_org.set_exclusion_from_checks() + Log.objects.create(user=request.user, action="rescue_organization_checked", ) elif action == "set_species_url": species_url_form = SpeciesURLForm(request.POST) @@ -878,6 +877,7 @@ def rescue_organization_check(request, context=None): elif action == "update_internal_comment": comment_form = RescueOrgInternalComment(request.POST, instance=rescue_org) if comment_form.is_valid(): + Log.objects.create(user=request.user, action="rescue_organization_added_internal_comment", ) comment_form.save() rescue_orgs_to_check = RescueOrganization.objects.filter(exclude_from_check=False, @@ -926,6 +926,10 @@ def exclude_from_regular_check(request, rescue_organization_id, source="organiza to_be_excluded = form.cleaned_data["regular_check_status"] != RegularCheckStatusChoices.REGULAR_CHECK rescue_org.exclude_from_check = to_be_excluded rescue_org.save() + if to_be_excluded: + Log.objects.create(user=request.user, + action="rescue_organization_excluded_from_check", + text=f"New status: {form.cleaned_data["regular_check_status"]}") return redirect(reverse(source)) else: