Skip to content

Commit

Permalink
Allow the current user to be assigned to memo
Browse files Browse the repository at this point in the history
  • Loading branch information
DjangoCRM committed Dec 8, 2024
1 parent e42d0cb commit cfc11c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tasks/site/memoadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def delete_model(self, request, obj):
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'to':
if not any((request.user.is_superuser, request.user.is_task_operator)):
q_params = Q(groups__name__in=(
'chiefs', 'department heads', 'task_operators'))
q_params |= Q(id=request.user.id)
kwargs["queryset"] = USER_MODEL.objects.filter(
groups__name__in=(
'chiefs', 'department heads', 'task_operators')
).distinct()
q_params).distinct()

return super().formfield_for_foreignkey(db_field, request, **kwargs)

def formfield_for_manytomany(self, db_field, request, **kwargs):
Expand Down

0 comments on commit cfc11c6

Please sign in to comment.