Commit 22dc44c638cfd91d49bfa13031ac8ed299087f00
1 parent
fac0372e
Exists in
master
and in
2 other branches
Changing multiple user selects to display email as well
Showing
8 changed files
with
31 additions
and
0 deletions
Show diff stats
file_link/forms.py
... | ... | @@ -5,12 +5,15 @@ from django.utils.html import strip_tags |
5 | 5 | from resubmit.widgets import ResubmitFileWidget |
6 | 6 | |
7 | 7 | from subjects.models import Tag |
8 | +from subjects.forms import ParticipantsMultipleChoiceField | |
8 | 9 | |
9 | 10 | from .models import FileLink |
10 | 11 | |
11 | 12 | class FileLinkForm(forms.ModelForm): |
12 | 13 | subject = None |
13 | 14 | MAX_UPLOAD_SIZE = 10*1024*1024 |
15 | + | |
16 | + students = ParticipantsMultipleChoiceField(queryset = None) | |
14 | 17 | |
15 | 18 | def __init__(self, *args, **kwargs): |
16 | 19 | super(FileLinkForm, self).__init__(*args, **kwargs) | ... | ... |
links/forms.py
... | ... | @@ -3,7 +3,9 @@ from django import forms |
3 | 3 | from django.utils.translation import ugettext_lazy as _ |
4 | 4 | from django.utils.html import strip_tags |
5 | 5 | from django.core.exceptions import ValidationError |
6 | + | |
6 | 7 | from subjects.models import Tag |
8 | +from subjects.forms import ParticipantsMultipleChoiceField | |
7 | 9 | |
8 | 10 | from pendencies.forms import PendenciesForm |
9 | 11 | from .models import Link |
... | ... | @@ -11,6 +13,8 @@ from .models import Link |
11 | 13 | class LinkForm(forms.ModelForm): |
12 | 14 | subject = None |
13 | 15 | MAX_UPLOAD_SIZE = 10*1024*1024 |
16 | + | |
17 | + students = ParticipantsMultipleChoiceField(queryset = None) | |
14 | 18 | |
15 | 19 | def __init__(self, *args, **kwargs): |
16 | 20 | super(LinkForm, self).__init__(*args, **kwargs) | ... | ... |
pdf_file/forms.py
... | ... | @@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ |
3 | 3 | from django.utils.html import strip_tags |
4 | 4 | |
5 | 5 | from subjects.models import Tag |
6 | +from subjects.forms import ParticipantsMultipleChoiceField | |
6 | 7 | from resubmit.widgets import ResubmitFileWidget |
7 | 8 | |
8 | 9 | from .models import PDFFile |
... | ... | @@ -11,6 +12,8 @@ class PDFFileForm(forms.ModelForm): |
11 | 12 | subject = None |
12 | 13 | MAX_UPLOAD_SIZE = 10*1024*1024 |
13 | 14 | |
15 | + students = ParticipantsMultipleChoiceField(queryset = None) | |
16 | + | |
14 | 17 | def __init__(self, *args, **kwargs): |
15 | 18 | super(PDFFileForm, self).__init__(*args, **kwargs) |
16 | 19 | self.subject = kwargs.get('initial').get('subject', None) | ... | ... |
students_group/forms.py
... | ... | @@ -3,11 +3,13 @@ from django import forms |
3 | 3 | from django.utils.translation import ugettext_lazy as _ |
4 | 4 | |
5 | 5 | from subjects.models import Subject |
6 | +from subjects.forms import ParticipantsMultipleChoiceField | |
6 | 7 | |
7 | 8 | from .models import StudentsGroup |
8 | 9 | |
9 | 10 | class StudentsGroupForm(forms.ModelForm): |
10 | 11 | subject = None |
12 | + participants = ParticipantsMultipleChoiceField(queryset = None) | |
11 | 13 | |
12 | 14 | def __init__(self, *args, **kwargs): |
13 | 15 | super(StudentsGroupForm, self).__init__(*args, **kwargs) | ... | ... |
subjects/forms.py
1 | 1 | from django import forms |
2 | 2 | from django.utils.translation import ugettext_lazy as _ |
3 | 3 | import datetime |
4 | + | |
5 | +from users.models import User | |
6 | + | |
4 | 7 | from .models import Subject, Tag |
5 | 8 | |
9 | + | |
10 | +class ParticipantsMultipleChoiceField(forms.ModelMultipleChoiceField): | |
11 | + def label_from_instance(self, obj): | |
12 | + label = str(obj) + " - (" + obj.email + ")" | |
13 | + | |
14 | + return label | |
15 | + | |
6 | 16 | class CreateSubjectForm(forms.ModelForm): |
7 | 17 | category_id = None |
8 | 18 | |
19 | + students = ParticipantsMultipleChoiceField(queryset = User.objects.all()) | |
20 | + professor = ParticipantsMultipleChoiceField(queryset = User.objects.all()) | |
21 | + | |
9 | 22 | def __init__(self, *args, **kwargs): |
10 | 23 | super(CreateSubjectForm, self).__init__(*args, **kwargs) |
11 | 24 | ... | ... |
webconference/forms.py
... | ... | @@ -6,6 +6,7 @@ from django.forms.models import inlineformset_factory |
6 | 6 | import datetime |
7 | 7 | |
8 | 8 | from subjects.models import Tag |
9 | +from subjects.forms import ParticipantsMultipleChoiceField | |
9 | 10 | |
10 | 11 | from .models import Webconference, ConferenceSettings |
11 | 12 | |
... | ... | @@ -15,6 +16,7 @@ from pendencies.models import Pendencies |
15 | 16 | class WebconferenceForm(forms.ModelForm): |
16 | 17 | subject = None |
17 | 18 | control_subject = forms.CharField(widget = forms.HiddenInput()) |
19 | + students = ParticipantsMultipleChoiceField(queryset = None) | |
18 | 20 | |
19 | 21 | def __init__(self, *args, **kwargs): |
20 | 22 | super(WebconferenceForm, self).__init__(*args, **kwargs) | ... | ... |
webpage/forms.py
... | ... | @@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _ |
4 | 4 | from django.utils.html import strip_tags |
5 | 5 | |
6 | 6 | from subjects.models import Tag |
7 | +from subjects.forms import ParticipantsMultipleChoiceField | |
7 | 8 | |
8 | 9 | from .models import Webpage |
9 | 10 | |
... | ... | @@ -11,6 +12,7 @@ from resubmit.widgets import ResubmitFileWidget |
11 | 12 | |
12 | 13 | class WebpageForm(forms.ModelForm): |
13 | 14 | subject = None |
15 | + students = ParticipantsMultipleChoiceField(queryset = None) | |
14 | 16 | |
15 | 17 | def __init__(self, *args, **kwargs): |
16 | 18 | super(WebpageForm, self).__init__(*args, **kwargs) | ... | ... |
youtube_video/forms.py
... | ... | @@ -8,6 +8,7 @@ import requests |
8 | 8 | import re |
9 | 9 | |
10 | 10 | from subjects.models import Tag |
11 | +from subjects.forms import ParticipantsMultipleChoiceField | |
11 | 12 | |
12 | 13 | from pendencies.forms import PendenciesForm |
13 | 14 | from pendencies.models import Pendencies |
... | ... | @@ -18,6 +19,7 @@ from .models import YTVideo |
18 | 19 | class YTVideoForm(forms.ModelForm): |
19 | 20 | subject = None |
20 | 21 | control_subject = forms.CharField(widget = forms.HiddenInput()) |
22 | + students = ParticipantsMultipleChoiceField(queryset = None) | |
21 | 23 | |
22 | 24 | def __init__(self, *args, **kwargs): |
23 | 25 | super(YTVideoForm, self).__init__(*args, **kwargs) | ... | ... |