[WIP] CLDT seat implementation#2689
Conversation
| 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"]) |
There was a problem hiding this comment.
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:
- from
task__event__tags=[ttt_tags]totask__event__tags__name__in=ttt_tag_names - from
task__event__tags=[cldt_tag]totask__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() |
There was a problem hiding this comment.
Since this property should mimick the query in MembershipManager.annotate_with_seat_usage, there's additional filtering missing:
cld_seats_utilized()should also filter by event tag CLDT- in
MembershipManager.annotate_with_seat_usage,_cldt_seats_utilizedshould also filter byseat_public - in
MembershipManager.annotate_with_seat_usage,_cldt_seats_remainingshould filter byseat_publicin the same way (currently it usespublic=True) - both
public_instructor_training_seats_utilized()andinhouse_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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Django template is complaining about these names. Apparently they can't start with _, so my proposition is to use these names instead:
cldt_seats_total_annotationcldt_seats_utilized_annotationcldt_seats_remaining_annotation
Changes should be applied here and in MembershipManager.annotate_with_seat_usage.
There was a problem hiding this comment.
I've changed the CLDT annotation variable names but not the others. We can do this after merge/rebase?
There was a problem hiding this comment.
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> |
| {{ 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 }} |
There was a problem hiding this comment.
Django template also complains here, so I suggest applying these changes in the lines above:
_cldt_seats_remaining->cldt_seats_remaining_annotation_cldt_seats_total->cldt_seats_total_annotation
| <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 }} |
There was a problem hiding this comment.
This notation (remaining count / total count) is clever, but I'm wondering if users would know this is remaining / total, and not utilized / total.
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
Can you remove this commented-out code?
| STR_LONGEST = 255 # length of the longest strings | ||
| STR_REG_KEY = 20 # length of Eventbrite registration key | ||
|
|
||
| CLDT_TAG_NAME = ["CLDT"] |
There was a problem hiding this comment.
I'd keep this plural (nameS) since this is a list.
|
@froggleston I think this is now obsolete with the new benefits model, correct? |
|
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. |

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