Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] CLDT seat implementation #2689

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

[WIP] CLDT seat implementation #2689

wants to merge 7 commits into from

Conversation

froggleston
Copy link
Contributor

This PR is a WIP to implement CLDT seat allocation and tracking

@froggleston froggleston changed the title Cldt seats [WIP] CLDT seat implementation Aug 19, 2024
@@ -140,6 +140,10 @@ class Meta:

class MembershipManager(models.Manager):
def annotate_with_seat_usage(self):
cldt_tag = Tag.objects.get(name="CLDT")
# TTT/ITT included
ttt_tags = Tag.objects.exclude(name__in=["SWC", "DC", "LC", "WiSE", "CLDT"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here (L143, L145) use tag names:

cldt_tag_name = "CLDT"
ttt_tag_names = ["TTT", "ITT"]

Then the lookups using ttt_tags or cldt_tag have to be changed:

  1. from task__event__tags=[ttt_tags] to task__event__tags__name__in=ttt_tag_names
  2. from task__event__tags=[cldt_tag] to task__event__tags__name__in=[cldt_tag_name]

@cached_property
def cldt_seats_utilized(self) -> int:
"""Count number of learner tasks that point to this membership."""
return self.task_set.filter(role__name="learner", seat_public=False).count()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this property should mimick the query in MembershipManager.annotate_with_seat_usage, there's additional filtering missing:

  1. cld_seats_utilized() should also filter by event tag CLDT
  2. in MembershipManager.annotate_with_seat_usage, _cldt_seats_utilized should also filter by seat_public
  3. in MembershipManager.annotate_with_seat_usage, _cldt_seats_remaining should filter by seat_public in the same way (currently it uses public=True)
  4. both public_instructor_training_seats_utilized() and inhouse_instructor_training_seats_utilized() should also filter by TTT tags (TTT, ITT)

Generally speaking the model properties should come down to the same equations as in annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all calculations and set CLDT to public=False as these events are member based and not open to the public.

@@ -35,6 +36,9 @@
<td>{{ result.instructor_training_seats_total }}</td>
<td>{{ result.instructor_training_seats_utilized }}</td>
<td>{{ result.instructor_training_seats_remaining }}</td>
<td>{{ result._cldt_training_seats_total }}</td>
<td>{{ result._cldt_training_seats_utilized }}</td>
<td>{{ result._cldt_training_seats_remaining }}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django template is complaining about these names. Apparently they can't start with _, so my proposition is to use these names instead:

  1. cldt_seats_total_annotation
  2. cldt_seats_utilized_annotation
  3. cldt_seats_remaining_annotation

Changes should be applied here and in MembershipManager.annotate_with_seat_usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the CLDT annotation variable names but not the others. We can do this after merge/rebase?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only CLDT annotations started with _, so only they needed to be updated with that prefix. Other annotations work just fine because they don't have name clash with model properties.

@@ -16,6 +16,7 @@
<th rowspan="2">Agreement</th>
<th rowspan="2">Contribution</th>
<th colspan="3" class="text-center">Instructor training seats (combined public and in-house)</th>
<th colspan="3" class="text-center">CLDT seats</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces 3 new columns in the row that's following (lines 23-25 below). Can you duplicate those lines? This way the header displays correctly:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

{{ membership.instructor_training_seats_remaining }} / {{ membership.instructor_training_seats_total }}
</td>
<td {% if membership._cldt_seats_remaining <= 0 and membership._cldt_seats_total > 0 or membership._cldt_seats_remaining < 0 and membership._cldt_seats_total == 0 %}class="table-danger"{% endif %}>
{{ membership._cldt_seats_remaining }} / {{ membership._cldt_seats_total }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django template also complains here, so I suggest applying these changes in the lines above:

  1. _cldt_seats_remaining -> cldt_seats_remaining_annotation
  2. _cldt_seats_total -> cldt_seats_total_annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -41,7 +42,10 @@
<td>{{ membership.agreement_start|date:"Y-m-d" }} &mdash; {{ membership.agreement_end|date:"Y-m-d" }}</td>
<td>{{ membership.get_contribution_type_display }}</td>
<td {% if membership.instructor_training_seats_remaining <= 0 and membership.instructor_training_seats_total > 0 or membership.instructor_training_seats_remaining < 0 and membership.instructor_training_seats_total == 0 %}class="table-danger"{% endif %}>
{{ membership.instructor_training_seats_remaining }}
{{ membership.instructor_training_seats_remaining }} / {{ membership.instructor_training_seats_total }}
Copy link
Contributor

@pbanaszkiewicz pbanaszkiewicz Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This notation (remaining count / total count) is clever, but I'm wondering if users would know this is remaining / total, and not utilized / total.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check this with the CT, but as these calculations have been in place for the other seat types, I wouldn't want to change it without consulting them.

cldt_tag_name = "CLDT"
ttt_tag_names = ["TTT", "ITT"]
# cldt_tag_name = "CLDT"
# ttt_tag_names = ["TTT", "ITT"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this commented-out code?

@@ -5,3 +5,6 @@
STR_LONG = 100 # length of long strings
STR_LONGEST = 255 # length of the longest strings
STR_REG_KEY = 20 # length of Eventbrite registration key

CLDT_TAG_NAME = ["CLDT"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this plural (nameS) since this is a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants