Skip to content

[WIP] CLDT seat implementation#2689

Open
froggleston wants to merge 7 commits into
developfrom
cldt_seats
Open

[WIP] CLDT seat implementation#2689
froggleston wants to merge 7 commits into
developfrom
cldt_seats

Conversation

@froggleston

Copy link
Copy Markdown
Member

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
Comment thread amy/workshops/models.py Outdated
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
Copy Markdown
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]

Comment thread amy/workshops/models.py Outdated
@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
Copy Markdown
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
Copy Markdown
Member 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.

<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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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.

<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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done!

<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 }}

@pbanaszkiewicz pbanaszkiewicz Sep 23, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member 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.

Comment thread amy/workshops/models.py
cldt_tag_name = "CLDT"
ttt_tag_names = ["TTT", "ITT"]
# cldt_tag_name = "CLDT"
# ttt_tag_names = ["TTT", "ITT"]

Copy link
Copy Markdown
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?

Comment thread amy/workshops/consts.py
STR_LONGEST = 255 # length of the longest strings
STR_REG_KEY = 20 # length of Eventbrite registration key

CLDT_TAG_NAME = ["CLDT"]

Copy link
Copy Markdown
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.

@maneesha

Copy link
Copy Markdown
Contributor

@froggleston I think this is now obsolete with the new benefits model, correct?

@froggleston

Copy link
Copy Markdown
Member Author

Hey @maneesha - yes, I believe we'll have another go at this once we have a follow-up about the general approach to tags vs proper lesson program entities/enums.

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