This commit is contained in:
brocasm
2023-09-10 23:52:05 +02:00
parent c4b7fcd629
commit a4f2488732
2 changed files with 9 additions and 8 deletions

View File

@@ -29,15 +29,16 @@ class _cl_Student_eval_admin(admin.ModelAdmin):
search_fields = ['sStudent', 'sRef']
list_filter = ['sStudent',"sAuthor", "nEval_Type", "nEval_Mode", ('dtDate', DateRangeFilter)]
list_filter = ['sStudent',"sAuthor", "nEval_Type", "nEval_Mode"]
def get_form(self, request, obj=None, **kwargs):
user_obj = request.user
author_id = obj.Author.id if obj.Author is not None else 0
student_id = obj.Student.id if obj.Student is not None else 0
if obj is not None:
author_id = obj.Author.id if obj.Author is not None else 0
student_id = obj.Student.id if obj.Student is not None else 0
if not user_obj.id == author_id and not user_obj.id == student_id and not is_member(user_obj, "FI-Encadrants"):
raise PermissionDenied
if not user_obj.id == author_id and not user_obj.id == student_id and not is_member(user_obj, "FI-Encadrants"):
raise PermissionDenied
return super().get_form(request, obj, **kwargs)