mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-10-10 14:52:53 +00:00
Allow technicians to record training sessions (#664)
* Allow technicians to record training sessions Add a per-item technician_can_train flag. Technicians in an item's department who are passed out on a flagged item may log Training Started/Complete for it. * Run linter
This commit is contained in:
@@ -155,6 +155,7 @@ class AddQualification(generic.CreateView, ModalURLMixin):
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["pk"] = self.kwargs["pk"]
|
||||
kwargs["user"] = self.request.user
|
||||
return kwargs
|
||||
|
||||
|
||||
@@ -163,6 +164,17 @@ class EditQualification(generic.UpdateView, ModalURLMixin):
|
||||
model = models.TrainingItemQualification
|
||||
form_class = forms.QualificationForm
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["user"] = self.request.user
|
||||
return kwargs
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
if not self.request.user.is_supervisor: # Technicians may only edit records they delivered
|
||||
queryset = queryset.filter(supervisor=self.request.user.pk)
|
||||
return queryset
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["depths"] = models.TrainingItemQualification.CHOICES
|
||||
@@ -251,6 +263,11 @@ class SessionLog(generic.FormView):
|
||||
form_class = forms.SessionLogForm
|
||||
success_url = reverse_lazy("trainee_list")
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["user"] = self.request.user
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form, *args, **kwargs):
|
||||
for trainee in form.cleaned_data.get("trainees", []):
|
||||
for depth in models.TrainingItemQualification.CHOICES:
|
||||
|
||||
Reference in New Issue
Block a user