Rewrite some API on Event and ExtraLesson #433

Merged
hansegucker merged 4 commits from feature/restructure-event-extra-lesson-api into master 2021-02-21 19:45:41 +01:00
hansegucker commented 2021-02-13 16:59:00 +01:00 (Migrated from edugit.org)
No description provided.
hansegucker commented 2021-02-13 17:01:15 +01:00 (Migrated from edugit.org)

mentioned in merge request AlekSIS-App-Alsijil!424

mentioned in merge request AlekSIS-App-Alsijil!424
nik commented 2021-02-13 19:07:13 +01:00 (Migrated from edugit.org)

There is no linked issue and no description, and the commit message says absolutely nothing.

Why should the code be changed? Assuming you did not just change it for fun because you wanted to change some code, please describe what the intention is, at least in the commit message, and, ideally, also in the MR.

There is no linked issue and no description, and the commit message says absolutely nothing. Why should the code be changed? Assuming you did not just change it for fun because you wanted to change some code, please describe what the intention is, at least in the commit message, and, ideally, also in the MR.
nik commented 2021-02-13 19:34:56 +01:00 (Migrated from edugit.org)

Looking at the code, it seems your commit also mixes a bugfix and a new feature. Please separate these.

Looking at the code, it seems your commit also mixes a bugfix and a new feature. Please separate these.
nik commented 2021-02-13 19:36:52 +01:00 (Migrated from edugit.org)

Annotations are done in the QuerySet using the annotate method. While adding arbitrary attributes to Model instances technically works, it will some day hit back when we think it is a real annotation (i.e. one the ORM is aware of) but it is a pure Python attribute.

Annotations are done in the `QuerySet` using the `annotate` method. While adding arbitrary attributes to `Model` instances technically works, it will some day hit back when we think it is a real annotation (i.e. one the ORM is aware of) but it is a pure Python attribute.
nik commented 2021-02-13 19:38:57 +01:00 (Migrated from edugit.org)

Firstly, if this method stays where it is, it should be renamed:

    def from_period(cls, period: int, day: date):

Methods starting with the get_ prefix are thought to be getter methods, which return an attribute of the current instance. Factories that generate an instance from another object start with the from_ prefix only.

But this also looks like it belongs into the QuerySet or even manager.

Firstly, if this method stays where it is, it should be renamed: ```suggestion:-0+0 def from_period(cls, period: int, day: date): ``` Methods starting with the `get_` prefix are thought to be getter methods, which return an attribute of the current instance. Factories that generate an instance from another object start with the `from_` prefix only. But this also looks like it belongs into the `QuerySet` or even manager.
nik commented 2021-02-13 19:40:46 +01:00 (Migrated from edugit.org)

This needs proper commetnary.

(Now that this is practically a new method written by you, you have to add a docstring anyway ;).)

This needs proper commetnary. (Now that this is practically a new method written by you, you have to add a docstring anyway ;).)
nik commented 2021-02-13 19:42:07 +01:00 (Migrated from edugit.org)

See above — annotations are the QuerySet's job.

See above — annotations are the `QuerySet`'s job.
nik commented 2021-02-13 19:42:29 +01:00 (Migrated from edugit.org)

Wat are these getters good for? They simply return a raw attribute…

Wat are these getters good for? They simply return a raw attribute…
nik commented 2021-02-13 19:42:48 +01:00 (Migrated from edugit.org)

Wat are these getters good for? They simply return a raw attribute…

Wat are these getters good for? They simply return a raw attribute…
nik commented 2021-02-13 19:46:05 +01:00 (Migrated from edugit.org)

Now I went through it until the end, it looks like the commit history should have even more logical steps.

Now I went through it until the end, it looks like the commit history should have even more logical steps.
hansegucker commented 2021-02-13 20:07:19 +01:00 (Migrated from edugit.org)

marked this merge request as draft

marked this merge request as **draft**
hansegucker commented 2021-02-13 20:08:32 +01:00 (Migrated from edugit.org)

Oh, sorry, of course this is actually still a draft. I missed to add "Draft:" in the title. All necessary information will follow.

Oh, sorry, of course this is actually still a draft. I missed to add "Draft:" in the title. All necessary information will follow.
hansegucker commented 2021-02-16 13:04:20 +01:00 (Migrated from edugit.org)

added 2 commits

  • 3d1e3660 - Unify API methods of LessonPeriod, Event and ExtraLesson
  • aec87faa - Add some API methods to access dates and periods for events and extra lessons better

Compare with previous version

added 2 commits <ul><li>3d1e3660 - Unify API methods of LessonPeriod, Event and ExtraLesson</li><li>aec87faa - Add some API methods to access dates and periods for events and extra lessons better</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-App-Chronos/-/merge_requests/129/diffs?diff_id=4830&start_sha=f9e128fb442a399144d5640fb14106987f1d185c)
hansegucker commented 2021-02-16 13:08:28 +01:00 (Migrated from edugit.org)

They are necessary in order to have an unified API of getters on LessonPeriod, Event and ExtraLesson.

They are necessary in order to have an unified API of getters on `LessonPeriod`, `Event` and `ExtraLesson`.
hansegucker commented 2021-02-16 13:08:29 +01:00 (Migrated from edugit.org)

Okay, I will use from_period as classmethod because it doesn't return a queryset but a single TimePeriod.

Okay, I will use `from_period` as classmethod because it doesn't return a queryset but a single `TimePeriod`.
hansegucker commented 2021-02-16 13:08:29 +01:00 (Migrated from edugit.org)

They are necessary in order to have an unified API of getters on LessonPeriod, Event and ExtraLesson.

They are necessary in order to have an unified API of getters on `LessonPeriod`, `Event` and `ExtraLesson`.
hansegucker commented 2021-02-16 16:35:25 +01:00 (Migrated from edugit.org)

changed this line in version 3 of the diff

changed this line in [version 3 of the diff](/AlekSIS/official/AlekSIS-App-Chronos/-/merge_requests/129/diffs?diff_id=4831&start_sha=aec87faa8928e45c7c5df56a2bf98e3c274771b5#aff889560e418df674a6887a541974fc95f8cd36_221_221)
hansegucker commented 2021-02-16 16:35:27 +01:00 (Migrated from edugit.org)

added 1 commit

  • 4fe76e99 - Fix type hints and add missing doc strings for improved API on ExtraLesson/Event/LessonPeriod

Compare with previous version

added 1 commit <ul><li>4fe76e99 - Fix type hints and add missing doc strings for improved API on ExtraLesson/Event/LessonPeriod</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-App-Chronos/-/merge_requests/129/diffs?diff_id=4831&start_sha=aec87faa8928e45c7c5df56a2bf98e3c274771b5)
hansegucker commented 2021-02-16 16:38:20 +01:00 (Migrated from edugit.org)

added 1 commit

  • 83c085b6 - Rename get_from_period to from_period and add docstring

Compare with previous version

added 1 commit <ul><li>83c085b6 - Rename get_from_period to from_period and add docstring</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-App-Chronos/-/merge_requests/129/diffs?diff_id=4832&start_sha=4fe76e9975034d3703c8c5829aadab4f21446892)
hansegucker commented 2021-02-16 19:34:34 +01:00 (Migrated from edugit.org)

marked this merge request as ready

marked this merge request as **ready**
nik commented 2021-02-16 19:54:03 +01:00 (Migrated from edugit.org)

We discussed this, and concluded that gettin the week into a model across a foreign key relation through a manager is non-trivial.

We discussed this, and concluded that gettin the week into a model across a foreign key relation through a manager is non-trivial.
nik commented 2021-02-21 19:40:01 +01:00 (Migrated from edugit.org)

resolved all threads

resolved all threads
nik (Migrated from edugit.org) merged commit abd5712123 into master 2021-02-21 19:45:41 +01:00
nik commented 2021-02-21 19:45:46 +01:00 (Migrated from edugit.org)

mentioned in commit abd5712123

mentioned in commit abd5712123ae6a9706bbd7082e89c1bbf3823bad
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aleksis/AlekSIS-App-Chronos!433
No description provided.