update trainee / supervisor management
This commit is contained in:
+15
-1
@@ -1,5 +1,5 @@
|
||||
import secrets
|
||||
from typing import Optional
|
||||
from typing import Any, Optional
|
||||
from django.conf import settings
|
||||
|
||||
from django_tables2 import SingleTableMixin
|
||||
@@ -77,6 +77,8 @@ from django.template import RequestContext
|
||||
|
||||
from django.db.models import Q
|
||||
|
||||
from dal import autocomplete
|
||||
|
||||
def feedback_checker(user):
|
||||
return user.groups.filter(name="feedback_checker").exists()
|
||||
|
||||
@@ -655,6 +657,18 @@ class UpdateUserProfileView(UpdateView):
|
||||
self.fields = ["grade", "registration_number", "site"]
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs: reverse_lazy) -> dict[str, Any]:
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
form = context["form"]
|
||||
|
||||
if "supervisor" in form.fields:
|
||||
#form.fields["supervisor"].queryset = Supervisor.objects.all()
|
||||
form.fields["supervisor"] = forms.ModelChoiceField(
|
||||
Supervisor.objects.all().order_by("name"), required=False, widget=autocomplete.ModelSelect2(url='generic:supervisor-autocomplete')
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
def get_success_url(self):
|
||||
if "redirect" in self.request.GET:
|
||||
|
||||
Reference in New Issue
Block a user