-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: develop
Are you sure you want to change the base?
Conversation
amy/workshops/models.py
Outdated
@@ -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"]) |
There was a problem hiding this comment.
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:
- 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]
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() |
There was a problem hiding this comment.
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:
cld_seats_utilized()
should also filter by event tag CLDT- in
MembershipManager.annotate_with_seat_usage
,_cldt_seats_utilized
should also filter byseat_public
- in
MembershipManager.annotate_with_seat_usage
,_cldt_seats_remaining
should filter byseat_public
in 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.
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> |
There was a problem hiding this comment.
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:
cldt_seats_total_annotation
cldt_seats_utilized_annotation
cldt_seats_remaining_annotation
Changes should be applied here and in MembershipManager.annotate_with_seat_usage
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 }} |
There was a problem hiding this comment.
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:
_cldt_seats_remaining
->cldt_seats_remaining_annotation
_cldt_seats_total
->cldt_seats_total_annotation
There was a problem hiding this comment.
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" }} — {{ 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 }} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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.
This PR is a WIP to implement CLDT seat allocation and tracking