From 2df9990e4b4a98afa22ab311ec036f01c8ec8b30 Mon Sep 17 00:00:00 2001
From: Hangzhi Yu <hangzhi@protonmail.com>
Date: Thu, 23 Mar 2023 16:31:50 +0100
Subject: [PATCH] Use id of the respectie ExtraMark and ExcuseType object when
 using them as column aliases

---
 CHANGELOG.rst                  | 8 ++++++++
 aleksis/apps/alsijil/models.py | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 1ee95a29f..2c77d1f13 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
 The format is based on `Keep a Changelog`_,
 and this project adheres to `Semantic Versioning`_.
 
+Unreleased
+----------
+
+Fixed
+~~~~~
+* In some cases, pages showing the count of extra marks and lessons with custom excuse types of
+  persons threw an error.
+
 `3.0b0`_ - 2022-02-28
 ---------------------
 
diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py
index b504a2941..615b28b36 100644
--- a/aleksis/apps/alsijil/models.py
+++ b/aleksis/apps/alsijil/models.py
@@ -1,12 +1,14 @@
 from datetime import date
 from typing import Optional, Union
 from urllib.parse import urlparse
+from uuid import uuid4
 
 from django.db import models
 from django.db.models.constraints import CheckConstraint
 from django.db.models.query_utils import Q
 from django.urls import reverse
 from django.utils.formats import date_format
+from django.utils.text import slugify
 from django.utils.translation import gettext_lazy as _
 
 from calendarweek import CalendarWeek
@@ -66,7 +68,7 @@ class ExcuseType(ExtensibleModel):
 
     @property
     def count_label(self):
-        return f"{self.short_name}_count"
+        return f"excuse_type_{self.id}_count"
 
     class Meta:
         ordering = ["name"]
@@ -437,7 +439,7 @@ class ExtraMark(ExtensibleModel):
 
     @property
     def count_label(self):
-        return f"{self.short_name}_count"
+        return f"extra_mark_{self.id}_count"
 
     class Meta:
         ordering = ["short_name"]
-- 
GitLab