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
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions amy/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class MembershipSerializer(serializers.ModelSerializer):
inhouse_instructor_training_seats_total = serializers.IntegerField()
inhouse_instructor_training_seats_utilized = serializers.IntegerField()
inhouse_instructor_training_seats_remaining = serializers.IntegerField()
cldt_seats_total = serializers.IntegerField()
cldt_seats_utilized = serializers.IntegerField()
cldt_seats_remaining = serializers.IntegerField()

class Meta:
model = Membership
Expand Down Expand Up @@ -220,6 +223,9 @@ class Meta:
"inhouse_instructor_training_seats_total",
"inhouse_instructor_training_seats_utilized",
"inhouse_instructor_training_seats_remaining",
"cldt_seats_total",
"cldt_seats_utilized",
"cldt_seats_remaining",
)


Expand Down
7 changes: 7 additions & 0 deletions amy/extrequests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ def get_membership_warnings_after_match(
"it's been allowed.",
)

cldt_remaining = membership.cldt_seats_remaining
if cldt_remaining <= 0:
warnings.append(
f'Membership "{membership}" is using more CLDT seats than '
"it's been allowed.",
)

# check if membership is active
if not (membership.agreement_start <= date.today() <= membership.agreement_end):
warnings.append(
Expand Down
10 changes: 10 additions & 0 deletions amy/fiscal/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ class Meta:
"additional_public_instructor_training_seats",
"inhouse_instructor_training_seats",
"additional_inhouse_instructor_training_seats",
"cldt_seats",
"additional_cldt_seats",
"emergency_contact",
"workshops_without_admin_fee_rolled_over",
"workshops_without_admin_fee_rolled_from_previous",
"public_instructor_training_seats_rolled_over",
"public_instructor_training_seats_rolled_from_previous",
"inhouse_instructor_training_seats_rolled_over",
"inhouse_instructor_training_seats_rolled_from_previous",
"cldt_seats_rolled_over",
"cldt_seats_rolled_from_previous",
]

def __init__(
Expand All @@ -145,10 +149,12 @@ def __init__(
del self.fields["workshops_without_admin_fee_rolled_over"]
del self.fields["public_instructor_training_seats_rolled_over"]
del self.fields["inhouse_instructor_training_seats_rolled_over"]
del self.fields["cldt_seats_rolled_over"]
if not show_rolled_from_previous:
del self.fields["workshops_without_admin_fee_rolled_from_previous"]
del self.fields["public_instructor_training_seats_rolled_from_previous"]
del self.fields["inhouse_instructor_training_seats_rolled_from_previous"]
del self.fields["cldt_seats_rolled_from_previous"]

# set up a layout object for the helper
self.helper.layout = self.helper.build_default_layout(self)
Expand Down Expand Up @@ -288,6 +294,9 @@ class Meta(MembershipCreateForm.Meta):
"inhouse_instructor_training_seats",
"additional_inhouse_instructor_training_seats",
"inhouse_instructor_training_seats_rolled_from_previous",
"cldt_seats",
"additional_cldt_seats",
"cldt_seats_rolled_from_previous",
"emergency_contact",
"comment",
]
Expand All @@ -303,6 +312,7 @@ def __init__(self, *args, **kwargs):
"workshops_without_admin_fee_rolled_from_previous",
"public_instructor_training_seats_rolled_from_previous",
"inhouse_instructor_training_seats_rolled_from_previous",
"cldt_seats_rolled_from_previous",
]
for field in fields:
self[field].field.min_value = 0
Expand Down
13 changes: 13 additions & 0 deletions amy/fiscal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def form_valid(self, form):
"inhouse_instructor_training_seats_rolled_over",
"inhouse_instructor_training_seats_rolled_from_previous",
),
(
"cldt_seats_rolled_over",
"cldt_seats_rolled_from_previous",
),
)
save_rolled_to = False
try:
Expand Down Expand Up @@ -584,6 +588,9 @@ def get_initial(self) -> Dict[str, Any]:
"inhouse_instructor_training_seats": self.membership.inhouse_instructor_training_seats, # noqa
"additional_inhouse_instructor_training_seats": self.membership.additional_inhouse_instructor_training_seats, # noqa
"inhouse_instructor_training_seats_rolled_from_previous": 0,
"cldt_seats": self.membership.cldt_seats, # noqa
"additional_cldt_seats": self.membership.additional_cldt_seats, # noqa
"cldt_seats_rolled_from_previous": 0,
"emergency_contact": self.membership.emergency_contact,
}

Expand All @@ -599,6 +606,9 @@ def get_form_kwargs(self) -> Dict[str, Any]:
"inhouse_instructor_training_seats_rolled_from_previous": max(
self.membership.inhouse_instructor_training_seats_remaining, 0
),
"cldt_seats_rolled_from_previous": max(
self.membership.cldt_seats_remaining, 0
),
}
return {
"max_values": max_values,
Expand All @@ -623,6 +633,9 @@ def form_valid(self, form):
self.membership.inhouse_instructor_training_seats_rolled_over = (
form.instance.inhouse_instructor_training_seats_rolled_from_previous
)
self.membership.cldt_seats_rolled_over = (
form.instance.cldt_seats_rolled_from_previous
)
self.membership.rolled_to_membership = self.object
self.membership.save()

Expand Down
5 changes: 3 additions & 2 deletions amy/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ def instructor_issues(request):
airport__isnull=True
)

# Everyone who's been in instructor training but doesn't yet have a badge.
# Everyone who's been in instructor training or CLDT but doesn't yet have a badge.
learner = Role.objects.get(name="learner")
ttt = Tag.objects.get(name="TTT")
cldt = Tag.objects.get(name="CLDT")
stalled = Tag.objects.get(name="stalled")
trainees = (
Task.objects.filter(event__tags__in=[ttt], role=learner)
Task.objects.filter(event__tags__in=[ttt, cldt], role=learner)
.exclude(person__badges__in=instructor_badges)
.order_by("person__family", "person__personal", "event__start")
.select_related("person", "event")
Expand Down
8 changes: 6 additions & 2 deletions amy/templates/fiscal/all_memberships.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<th>Variant</th>
<th>Dates</th>
<th>Contribution</th>
<th>Remaining instructor training seats</th>
<th>IT seats</th>
<th>CLDT seats</th>
<th class="additional-links"></th>
</tr>
{% for membership in all_memberships %}
Expand All @@ -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.

</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 }}
</td>
<td>
<a href="{% url 'membership_details' membership.pk %}" title="View membership"><i class="fas fa-info-circle"></i></a>
Expand Down
24 changes: 24 additions & 0 deletions amy/templates/fiscal/membership.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,30 @@
</p>
</td>
</tr>
<tr>
<th rowspan="3" width="30%">CLDT seats</th>
<th>Allowed:</th>
<td>
{{ membership.cldt_seats_total }}
<p class="small">
Includes {{ membership.additional_cldt_seats }} additional seats.<br>
Includes {{ membership.cldt_seats_rolled_from_previous|default_if_none:0 }} seats rolled from previous membership.
</p>
</td>
</tr>
<tr>
<th>Utilized:</th>
<td>{{ membership.cldt_seats_utilized }}</td>
</tr>
<tr {% 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 %}>
<th>Remaining:</th>
<td>
{{ membership.cldt_seats_remaining }}
<p class="small">
{{ membership.cldt_seats_rolled_over|default:"None" }} were rolled over to following membership.
</p>
</td>
</tr>
<tr>
<th>Instructor training seats:</th>
<td colspan="2">
Expand Down
23 changes: 23 additions & 0 deletions amy/templates/fiscal/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h2>Memberships</h2>
<th colspan="2">Self-organised workshops <i class="fas fa-question-circle" data-toggle="tooltip" title="Per agreement duration"></i></th>
<th colspan="3">Public instructor training seats</th>
<th colspan="3">In-house instructor training seats</th>
<th colspan="3">CLDT seats</th>
<th rowspan="2" class="additional-links"></th>
</tr>
<tr>
Expand All @@ -137,6 +138,10 @@ <h2>Memberships</h2>
<th><small>Allowed</small></th>
<th><small>Utilized</small></th>
<th><small>Remaining</small></th>
<!-- CLDT seats -->
<th><small>Allowed</small></th>
<th><small>Utilized</small></th>
<th><small>Remaining</small></th>
</tr>
{% for membership in organization.memberships.all %}
<tr>
Expand Down Expand Up @@ -203,6 +208,24 @@ <h2>Memberships</h2>
Inc. {{ membership.inhouse_instructor_training_seats_rolled_over|default:0 }} rolled over
</p>
</td>
<!-- CLDT seats -->
<td>
{{ membership.cldt_seats_total|default_if_none:"&mdash;" }}
<p class="small">
Inc.
{{ membership.additional_cldt_seats|default:0 }} additional,
{{ membership.cldt_seats_rolled_from_previous|default:0 }} rolled from prev.
</p>
</td>
<td>{{ membership.cldt_seats_utilized|default_if_none:"&mdash;" }}</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 }}
<p class="small">
Inc. {{ membership.cldt_seats_rolled_over|default:0 }} rolled over
</p>
</td>
<!-- link -->
<td>
<a href="{% url 'membership_details' membership.pk %}" title="View membership"><i class="fas fa-info-circle"></i></a>
Expand Down
1 change: 1 addition & 0 deletions amy/workshops/management/commands/fake_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def fake_tags(self):
("LSO", 170, "Lesson Specific Onboarding"),
("hackathon", 180, "Event is a hackathon"),
("WiSE", 190, "Women in Science and Engineering"),
("CLDT", 200, "Collaborative Lesson Development Training"),
]

self.stdout.write("Generating {} fake tags...".format(len(tags)))
Expand Down
Loading
Loading