diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5aeb0368516a20fd84948c7d6597a89c02226ea3..c155de6b42507575d190c2a7c2f90e8466b4f97d 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`_. +`2.0rc2`_ - 2021-06-26 +---------------------- + +Fixed +~~~~~ + +* "My overview" and "All lessons" didn't work if there was no current school term. + `2.0rc1`_ - 2021-06-23 ---------------------- @@ -141,3 +149,4 @@ Fixed .. _2.0a1: https://edugit.org/AlekSIS/Official/AlekSIS-App-Alsijil/-/tags/2.0a1 .. _2.0b0: https://edugit.org/AlekSIS/Official/AlekSIS-App-Alsijil/-/tags/2.0b0 .. _2.0rc1: https://edugit.org/AlekSIS/Official/AlekSIS-App-Alsijil/-/tags/2.0rc1 +.. _2.0rc2: https://edugit.org/AlekSIS/Official/AlekSIS-App-Alsijil/-/tags/2.0rc2 diff --git a/aleksis/apps/alsijil/forms.py b/aleksis/apps/alsijil/forms.py index 53b5ffee1c68c2b0645d86753e0eb8eb934d2c0c..cb12a4eb86e424167d4301b31fca0a0dd035b625 100644 --- a/aleksis/apps/alsijil/forms.py +++ b/aleksis/apps/alsijil/forms.py @@ -296,8 +296,14 @@ class FilterRegisterObjectForm(forms.Form): def get_initial(cls, has_documentation: Optional[bool] = None): date_end = timezone.now().date() date_start = date_end - timedelta(days=30) + school_term = SchoolTerm.current + + # If there is no current school year, use last known school year. + if not school_term: + school_term = SchoolTerm.objects.all().last() + return { - "school_term": SchoolTerm.current, + "school_term": school_term, "date_start": date_start, "date_end": date_end, "has_documentation": has_documentation, diff --git a/aleksis/apps/alsijil/util/alsijil_helpers.py b/aleksis/apps/alsijil/util/alsijil_helpers.py index b7442f9986730dc23de2611602f06b85e5ef9b9b..29381c6cb76cd424e945b6e42bd2fdddf414c05c 100644 --- a/aleksis/apps/alsijil/util/alsijil_helpers.py +++ b/aleksis/apps/alsijil/util/alsijil_helpers.py @@ -336,6 +336,11 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[D # Always force a value for school term, start and end date so that queries won't get too big initial_filter_data = FilterRegisterObjectForm.get_initial() filter_dict["school_term"] = filter_dict.get("school_term", initial_filter_data["school_term"]) + + # If there is not school year at all, there are definitely no data. + if not filter_dict["school_term"]: + return [] + filter_dict["date_start"] = filter_dict.get("date_start", initial_filter_data["date_start"]) filter_dict["date_end"] = filter_dict.get("date_end", initial_filter_data["date_end"]) filter_dict["filter_date"] = bool(filter_dict.get("date_start")) and bool( diff --git a/pyproject.toml b/pyproject.toml index 3dff4cbb04db67599dc0d89dce84863226a0e33c..774582acabb0b64e7c053d0042aa7d1f12e76380 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "AlekSIS-App-Alsijil" -version = "2.0rc1" +version = "2.0rc2" packages = [ { include = "aleksis" } ]