From c2f49238b14f076768594db8c8da91a8d83d2aad Mon Sep 17 00:00:00 2001 From: Dmitry Novikov Date: Thu, 27 Dec 2018 14:03:59 +0300 Subject: [PATCH] filter inly active admins --- msg_app/forms.py | 2 +- msg_app/models.py | 2 +- taskapp/forms.py | 2 +- taskapp/models.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/msg_app/forms.py b/msg_app/forms.py index ff8c81b..af6a8cd 100644 --- a/msg_app/forms.py +++ b/msg_app/forms.py @@ -7,7 +7,7 @@ from accounts_app.models import UserProfile class ConversationForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ConversationForm, self).__init__(*args, **kwargs) - user_profile_queryset = UserProfile.objects.filter(is_admin=True) + user_profile_queryset = UserProfile.objects.filter(is_admin=True, is_active=True) if user_profile_queryset is not None: self.fields['participants'].choices = [(up.pk, up.get_full_name()) for up in user_profile_queryset] diff --git a/msg_app/models.py b/msg_app/models.py index 8e0f15f..136bebd 100644 --- a/msg_app/models.py +++ b/msg_app/models.py @@ -209,7 +209,7 @@ class Conversation(models.Model): attachment=attachment, author=author ) if with_status: - for participant in self.participants.all(): + for participant in self.participants.filter(is_active=True): if participant == author: continue MessageStatus.objects.create(msg=msg, user=participant) diff --git a/taskapp/forms.py b/taskapp/forms.py index ca9e8e1..e7ac2b8 100644 --- a/taskapp/forms.py +++ b/taskapp/forms.py @@ -11,7 +11,7 @@ class TaskFrm(forms.ModelForm): 'out_date': delta_add_days().strftime("%Y-%m-%d") }}) super(TaskFrm, self).__init__(*args, **kwargs) - self.fields['recipients'].queryset = UserProfile.objects.filter(is_admin=True) + self.fields['recipients'].queryset = UserProfile.objects.filter(is_admin=True, is_active=True) if initial_abon is not None: # fetch profiles that has been attached on group of selected subscriber diff --git a/taskapp/models.py b/taskapp/models.py index 09c6633..bf465ee 100644 --- a/taskapp/models.py +++ b/taskapp/models.py @@ -103,7 +103,7 @@ class Task(models.Model): def send_notification(self): task_handle( self, self.author, - self.recipients.all() + self.recipients.filter(is_active=True) ) def get_attachment_fname(self):