-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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.inhouse_instructor_training_seats, # noqa | ||
"additional_cldt_seats": self.membership.additional_inhouse_instructor_training_seats, # noqa | ||
This comment has been minimized.
Sorry, something went wrong.
pbanaszkiewicz
Contributor
|
||
"cldt_seats_rolled_from_previous": 0, | ||
"emergency_contact": self.membership.emergency_contact, | ||
} | ||
|
||
|
@@ -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, | ||
|
@@ -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() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
This comment has been minimized.
Sorry, something went wrong.
pbanaszkiewicz
Contributor
|
||
.exclude(person__badges__in=instructor_badges) | ||
.order_by("person__family", "person__personal", "event__start") | ||
.select_related("person", "event") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,9 @@ class Meta: | |
|
||
class MembershipManager(models.Manager): | ||
def annotate_with_seat_usage(self): | ||
cldt_tag = Tag.objects.get(name="CLDT") | ||
no_cldt_tags = Tag.objects.filter(name__in=["SWC", "DC", "LC", "TTT", "ITT", "WiSE"]) | ||
|
||
return self.get_queryset().annotate( | ||
instructor_training_seats_total=( | ||
# Public | ||
|
@@ -152,7 +155,10 @@ def annotate_with_seat_usage(self): | |
+ Coalesce("inhouse_instructor_training_seats_rolled_from_previous", 0) | ||
), | ||
instructor_training_seats_utilized=( | ||
Count("task", filter=Q(task__role__name="learner")) | ||
Count("task", filter=Q( | ||
task__role__name="learner", | ||
task__event__tags=[no_cldt_tags] | ||
)) | ||
This comment has been minimized.
Sorry, something went wrong.
pbanaszkiewicz
Contributor
|
||
), | ||
instructor_training_seats_remaining=( | ||
# Public | ||
|
@@ -161,7 +167,11 @@ def annotate_with_seat_usage(self): | |
# Coalesce returns first non-NULL value | ||
+ Coalesce("public_instructor_training_seats_rolled_from_previous", 0) | ||
- Count( | ||
"task", filter=Q(task__role__name="learner", task__seat_public=True) | ||
"task", filter=Q( | ||
task__role__name="learner", | ||
task__seat_public=True, | ||
task__event__tags=[no_cldt_tags] | ||
) | ||
) | ||
- Coalesce("public_instructor_training_seats_rolled_over", 0) | ||
# Inhouse | ||
|
@@ -170,10 +180,42 @@ def annotate_with_seat_usage(self): | |
+ Coalesce("inhouse_instructor_training_seats_rolled_from_previous", 0) | ||
- Count( | ||
"task", | ||
filter=Q(task__role__name="learner", task__seat_public=False), | ||
filter=Q( | ||
task__role__name="learner", | ||
task__seat_public=False, | ||
task__event__tags=[no_cldt_tags] | ||
), | ||
) | ||
- Coalesce("inhouse_instructor_training_seats_rolled_over", 0) | ||
), | ||
|
||
# CLDT | ||
cldt_seats_total=( | ||
F("cldt_seats") | ||
+ F("additional_cldt_seats") | ||
# Coalesce returns first non-NULL value | ||
+ Coalesce("cldt_seats_rolled_from_previous", 0) | ||
), | ||
cldt_seats_utilized=( | ||
Count("task", filter=Q( | ||
task__role__name="learner", | ||
task__event__tags=[cldt_tag] | ||
)) | ||
), | ||
cldt_seats_remaining=( | ||
F("cldt_seats") | ||
+ F("additional_cldt_seats") | ||
# Coalesce returns first non-NULL value | ||
+ Coalesce("cldt_seats_rolled_from_previous", 0) | ||
- Count( | ||
"task", filter=Q( | ||
task__role__name="learner", | ||
task__seat_public=True, | ||
task__event__tags=[cldt_tag] | ||
) | ||
) | ||
- Coalesce("cldt_seats_rolled_over", 0) | ||
), | ||
) | ||
|
||
|
||
|
@@ -290,6 +332,34 @@ class Membership(models.Model): | |
blank=True, | ||
help_text="In-house instructor training seats rolled over into next membership.", # noqa | ||
) | ||
|
||
#CLDT | ||
cldt_seats = models.PositiveIntegerField( | ||
null=False, | ||
blank=False, | ||
default=0, | ||
verbose_name="Collaborative Lesson Development Training seats", | ||
help_text="Number of CLDT seats", | ||
) | ||
additional_cldt_seats = models.PositiveIntegerField( | ||
null=False, | ||
blank=False, | ||
default=0, | ||
verbose_name="Additional CLDT seats", | ||
help_text="Use this field if you want to grant more CLDT seats than " | ||
"the agreement provides for.", | ||
) | ||
cldt_seats_rolled_from_previous = models.PositiveIntegerField( | ||
null=True, | ||
blank=True, | ||
help_text="CLDT seats rolled over from previous membership.", | ||
) | ||
cldt_seats_rolled_over = models.PositiveIntegerField( | ||
null=True, | ||
blank=True, | ||
help_text="CLDT seats rolled over into next membership.", | ||
) | ||
|
||
organizations = models.ManyToManyField( | ||
Organization, | ||
blank=False, | ||
|
@@ -322,7 +392,7 @@ class Membership(models.Model): | |
max_length=20, | ||
choices=PUBLIC_STATUS_CHOICES, | ||
default=PUBLIC_STATUS_CHOICES[1][0], | ||
verbose_name="Can this membership be publicized on The carpentries websites?", | ||
verbose_name="Can this membership be publicized on The Carpentries websites?", | ||
help_text="Public memberships may be listed on any of The Carpentries " | ||
"websites.", | ||
) | ||
|
@@ -559,6 +629,30 @@ def inhouse_instructor_training_seats_remaining(self) -> int: | |
c = self.inhouse_instructor_training_seats_rolled_over or 0 | ||
return a - b - c | ||
|
||
@property | ||
def cldt_seats_total(self) -> int: | ||
"""Calculate combined CLDT seats total. | ||
Unlike workshops w/o admin fee, CLDT seats have two numbers | ||
combined to calculate total of allowed seats in CLDT events. | ||
""" | ||
a = self.cldt_seats | ||
b = self.additional_cldt_seats | ||
c = self.cldt_seats_rolled_from_previous or 0 | ||
return a + b + c | ||
|
||
@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() | ||
This comment has been minimized.
Sorry, something went wrong.
pbanaszkiewicz
Contributor
|
||
|
||
@property | ||
def cldt_seats_remaining(self) -> int: | ||
"""Count remaining seats for CLDT.""" | ||
a = self.cldt_seats_total | ||
b = self.cldt_seats_utilized | ||
c = self.cldt_seats_rolled_over or 0 | ||
return a - b - c | ||
|
||
# ------------------------------------------------------------ | ||
|
||
|
@@ -1075,11 +1169,11 @@ def archive(self) -> None: | |
|
||
class TagQuerySet(QuerySet): | ||
def main_tags(self): | ||
names = ["SWC", "DC", "LC", "TTT", "ITT", "WiSE"] | ||
names = ["SWC", "DC", "LC", "TTT", "ITT", "WiSE", "CLDT"] | ||
return self.filter(name__in=names) | ||
|
||
def carpentries(self): | ||
return self.filter(name__in=["SWC", "DC", "LC"]) | ||
return self.filter(name__in=["SWC", "DC", "LC", "CLDT"]) | ||
|
||
def strings(self): | ||
return self.values_list("name", flat=True) | ||
|
@@ -1481,6 +1575,16 @@ class Event(AssignmentMixin, RQJobsMixin, models.Model): | |
"this event's member sites can also take part in this event.", | ||
) | ||
|
||
open_CLDT_applications = models.BooleanField( | ||
null=False, | ||
blank=True, | ||
default=False, | ||
verbose_name="CLDT Open applications", | ||
help_text="If this event is <b>CLDT</b>, you can mark it as 'open " | ||
"applications' which means that people not associated with " | ||
"this event's member sites can also take part in this event.", | ||
) | ||
This comment has been minimized.
Sorry, something went wrong.
pbanaszkiewicz
Contributor
|
||
|
||
# taught curriculum information | ||
curricula = models.ManyToManyField( | ||
"Curriculum", | ||
|
I'm not sure if this part should be here. I can imagine that training seats belong either to instructor training or to CLDT, so there should be two separate checks for them:
I wrote additional conditions for the seat "type" in the parentheses because currently we don't distinguish between validation for either of the "type" (CLDT or instructor training). This function
member_code_valid_training
is used in:...so we should know if those forms are going to be used for applying for CLDT training.