From 22dc44c638cfd91d49bfa13031ac8ed299087f00 Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 7 Sep 2017 11:25:07 -0300 Subject: [PATCH] Changing multiple user selects to display email as well --- file_link/forms.py | 3 +++ links/forms.py | 4 ++++ pdf_file/forms.py | 3 +++ students_group/forms.py | 2 ++ subjects/forms.py | 13 +++++++++++++ webconference/forms.py | 2 ++ webpage/forms.py | 2 ++ youtube_video/forms.py | 2 ++ 8 files changed, 31 insertions(+), 0 deletions(-) diff --git a/file_link/forms.py b/file_link/forms.py index bbeb431..156c19d 100644 --- a/file_link/forms.py +++ b/file_link/forms.py @@ -5,12 +5,15 @@ from django.utils.html import strip_tags from resubmit.widgets import ResubmitFileWidget from subjects.models import Tag +from subjects.forms import ParticipantsMultipleChoiceField from .models import FileLink class FileLinkForm(forms.ModelForm): subject = None MAX_UPLOAD_SIZE = 10*1024*1024 + + students = ParticipantsMultipleChoiceField(queryset = None) def __init__(self, *args, **kwargs): super(FileLinkForm, self).__init__(*args, **kwargs) diff --git a/links/forms.py b/links/forms.py index 2349d25..9c15c75 100644 --- a/links/forms.py +++ b/links/forms.py @@ -3,7 +3,9 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from django.utils.html import strip_tags from django.core.exceptions import ValidationError + from subjects.models import Tag +from subjects.forms import ParticipantsMultipleChoiceField from pendencies.forms import PendenciesForm from .models import Link @@ -11,6 +13,8 @@ from .models import Link class LinkForm(forms.ModelForm): subject = None MAX_UPLOAD_SIZE = 10*1024*1024 + + students = ParticipantsMultipleChoiceField(queryset = None) def __init__(self, *args, **kwargs): super(LinkForm, self).__init__(*args, **kwargs) diff --git a/pdf_file/forms.py b/pdf_file/forms.py index af10d1c..031ebfe 100644 --- a/pdf_file/forms.py +++ b/pdf_file/forms.py @@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.html import strip_tags from subjects.models import Tag +from subjects.forms import ParticipantsMultipleChoiceField from resubmit.widgets import ResubmitFileWidget from .models import PDFFile @@ -11,6 +12,8 @@ class PDFFileForm(forms.ModelForm): subject = None MAX_UPLOAD_SIZE = 10*1024*1024 + students = ParticipantsMultipleChoiceField(queryset = None) + def __init__(self, *args, **kwargs): super(PDFFileForm, self).__init__(*args, **kwargs) self.subject = kwargs.get('initial').get('subject', None) diff --git a/students_group/forms.py b/students_group/forms.py index 70760b6..055e096 100644 --- a/students_group/forms.py +++ b/students_group/forms.py @@ -3,11 +3,13 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from subjects.models import Subject +from subjects.forms import ParticipantsMultipleChoiceField from .models import StudentsGroup class StudentsGroupForm(forms.ModelForm): subject = None + participants = ParticipantsMultipleChoiceField(queryset = None) def __init__(self, *args, **kwargs): super(StudentsGroupForm, self).__init__(*args, **kwargs) diff --git a/subjects/forms.py b/subjects/forms.py index f21d653..a067c09 100644 --- a/subjects/forms.py +++ b/subjects/forms.py @@ -1,11 +1,24 @@ from django import forms from django.utils.translation import ugettext_lazy as _ import datetime + +from users.models import User + from .models import Subject, Tag + +class ParticipantsMultipleChoiceField(forms.ModelMultipleChoiceField): + def label_from_instance(self, obj): + label = str(obj) + " - (" + obj.email + ")" + + return label + class CreateSubjectForm(forms.ModelForm): category_id = None + students = ParticipantsMultipleChoiceField(queryset = User.objects.all()) + professor = ParticipantsMultipleChoiceField(queryset = User.objects.all()) + def __init__(self, *args, **kwargs): super(CreateSubjectForm, self).__init__(*args, **kwargs) diff --git a/webconference/forms.py b/webconference/forms.py index fc0eaf4..1c3f865 100644 --- a/webconference/forms.py +++ b/webconference/forms.py @@ -6,6 +6,7 @@ from django.forms.models import inlineformset_factory import datetime from subjects.models import Tag +from subjects.forms import ParticipantsMultipleChoiceField from .models import Webconference, ConferenceSettings @@ -15,6 +16,7 @@ from pendencies.models import Pendencies class WebconferenceForm(forms.ModelForm): subject = None control_subject = forms.CharField(widget = forms.HiddenInput()) + students = ParticipantsMultipleChoiceField(queryset = None) def __init__(self, *args, **kwargs): super(WebconferenceForm, self).__init__(*args, **kwargs) diff --git a/webpage/forms.py b/webpage/forms.py index 21b240c..ca12e96 100644 --- a/webpage/forms.py +++ b/webpage/forms.py @@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.html import strip_tags from subjects.models import Tag +from subjects.forms import ParticipantsMultipleChoiceField from .models import Webpage @@ -11,6 +12,7 @@ from resubmit.widgets import ResubmitFileWidget class WebpageForm(forms.ModelForm): subject = None + students = ParticipantsMultipleChoiceField(queryset = None) def __init__(self, *args, **kwargs): super(WebpageForm, self).__init__(*args, **kwargs) diff --git a/youtube_video/forms.py b/youtube_video/forms.py index 7d62fd7..27f974b 100644 --- a/youtube_video/forms.py +++ b/youtube_video/forms.py @@ -8,6 +8,7 @@ import requests import re from subjects.models import Tag +from subjects.forms import ParticipantsMultipleChoiceField from pendencies.forms import PendenciesForm from pendencies.models import Pendencies @@ -18,6 +19,7 @@ from .models import YTVideo class YTVideoForm(forms.ModelForm): subject = None control_subject = forms.CharField(widget = forms.HiddenInput()) + students = ParticipantsMultipleChoiceField(queryset = None) def __init__(self, *args, **kwargs): super(YTVideoForm, self).__init__(*args, **kwargs) -- libgit2 0.21.2