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,12 +5,15 @@ from django.utils.html import strip_tags | ||
5 | from resubmit.widgets import ResubmitFileWidget | 5 | from resubmit.widgets import ResubmitFileWidget |
6 | 6 | ||
7 | from subjects.models import Tag | 7 | from subjects.models import Tag |
8 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
8 | 9 | ||
9 | from .models import FileLink | 10 | from .models import FileLink |
10 | 11 | ||
11 | class FileLinkForm(forms.ModelForm): | 12 | class FileLinkForm(forms.ModelForm): |
12 | subject = None | 13 | subject = None |
13 | MAX_UPLOAD_SIZE = 10*1024*1024 | 14 | MAX_UPLOAD_SIZE = 10*1024*1024 |
15 | + | ||
16 | + students = ParticipantsMultipleChoiceField(queryset = None) | ||
14 | 17 | ||
15 | def __init__(self, *args, **kwargs): | 18 | def __init__(self, *args, **kwargs): |
16 | super(FileLinkForm, self).__init__(*args, **kwargs) | 19 | super(FileLinkForm, self).__init__(*args, **kwargs) |
links/forms.py
@@ -3,7 +3,9 @@ from django import forms | @@ -3,7 +3,9 @@ from django import forms | ||
3 | from django.utils.translation import ugettext_lazy as _ | 3 | from django.utils.translation import ugettext_lazy as _ |
4 | from django.utils.html import strip_tags | 4 | from django.utils.html import strip_tags |
5 | from django.core.exceptions import ValidationError | 5 | from django.core.exceptions import ValidationError |
6 | + | ||
6 | from subjects.models import Tag | 7 | from subjects.models import Tag |
8 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
7 | 9 | ||
8 | from pendencies.forms import PendenciesForm | 10 | from pendencies.forms import PendenciesForm |
9 | from .models import Link | 11 | from .models import Link |
@@ -11,6 +13,8 @@ from .models import Link | @@ -11,6 +13,8 @@ from .models import Link | ||
11 | class LinkForm(forms.ModelForm): | 13 | class LinkForm(forms.ModelForm): |
12 | subject = None | 14 | subject = None |
13 | MAX_UPLOAD_SIZE = 10*1024*1024 | 15 | MAX_UPLOAD_SIZE = 10*1024*1024 |
16 | + | ||
17 | + students = ParticipantsMultipleChoiceField(queryset = None) | ||
14 | 18 | ||
15 | def __init__(self, *args, **kwargs): | 19 | def __init__(self, *args, **kwargs): |
16 | super(LinkForm, self).__init__(*args, **kwargs) | 20 | super(LinkForm, self).__init__(*args, **kwargs) |
pdf_file/forms.py
@@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ | @@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ | ||
3 | from django.utils.html import strip_tags | 3 | from django.utils.html import strip_tags |
4 | 4 | ||
5 | from subjects.models import Tag | 5 | from subjects.models import Tag |
6 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
6 | from resubmit.widgets import ResubmitFileWidget | 7 | from resubmit.widgets import ResubmitFileWidget |
7 | 8 | ||
8 | from .models import PDFFile | 9 | from .models import PDFFile |
@@ -11,6 +12,8 @@ class PDFFileForm(forms.ModelForm): | @@ -11,6 +12,8 @@ class PDFFileForm(forms.ModelForm): | ||
11 | subject = None | 12 | subject = None |
12 | MAX_UPLOAD_SIZE = 10*1024*1024 | 13 | MAX_UPLOAD_SIZE = 10*1024*1024 |
13 | 14 | ||
15 | + students = ParticipantsMultipleChoiceField(queryset = None) | ||
16 | + | ||
14 | def __init__(self, *args, **kwargs): | 17 | def __init__(self, *args, **kwargs): |
15 | super(PDFFileForm, self).__init__(*args, **kwargs) | 18 | super(PDFFileForm, self).__init__(*args, **kwargs) |
16 | self.subject = kwargs.get('initial').get('subject', None) | 19 | self.subject = kwargs.get('initial').get('subject', None) |
students_group/forms.py
@@ -3,11 +3,13 @@ from django import forms | @@ -3,11 +3,13 @@ from django import forms | ||
3 | from django.utils.translation import ugettext_lazy as _ | 3 | from django.utils.translation import ugettext_lazy as _ |
4 | 4 | ||
5 | from subjects.models import Subject | 5 | from subjects.models import Subject |
6 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
6 | 7 | ||
7 | from .models import StudentsGroup | 8 | from .models import StudentsGroup |
8 | 9 | ||
9 | class StudentsGroupForm(forms.ModelForm): | 10 | class StudentsGroupForm(forms.ModelForm): |
10 | subject = None | 11 | subject = None |
12 | + participants = ParticipantsMultipleChoiceField(queryset = None) | ||
11 | 13 | ||
12 | def __init__(self, *args, **kwargs): | 14 | def __init__(self, *args, **kwargs): |
13 | super(StudentsGroupForm, self).__init__(*args, **kwargs) | 15 | super(StudentsGroupForm, self).__init__(*args, **kwargs) |
subjects/forms.py
1 | from django import forms | 1 | from django import forms |
2 | from django.utils.translation import ugettext_lazy as _ | 2 | from django.utils.translation import ugettext_lazy as _ |
3 | import datetime | 3 | import datetime |
4 | + | ||
5 | +from users.models import User | ||
6 | + | ||
4 | from .models import Subject, Tag | 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 | class CreateSubjectForm(forms.ModelForm): | 16 | class CreateSubjectForm(forms.ModelForm): |
7 | category_id = None | 17 | category_id = None |
8 | 18 | ||
19 | + students = ParticipantsMultipleChoiceField(queryset = User.objects.all()) | ||
20 | + professor = ParticipantsMultipleChoiceField(queryset = User.objects.all()) | ||
21 | + | ||
9 | def __init__(self, *args, **kwargs): | 22 | def __init__(self, *args, **kwargs): |
10 | super(CreateSubjectForm, self).__init__(*args, **kwargs) | 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 +6,7 @@ from django.forms.models import inlineformset_factory | ||
6 | import datetime | 6 | import datetime |
7 | 7 | ||
8 | from subjects.models import Tag | 8 | from subjects.models import Tag |
9 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
9 | 10 | ||
10 | from .models import Webconference, ConferenceSettings | 11 | from .models import Webconference, ConferenceSettings |
11 | 12 | ||
@@ -15,6 +16,7 @@ from pendencies.models import Pendencies | @@ -15,6 +16,7 @@ from pendencies.models import Pendencies | ||
15 | class WebconferenceForm(forms.ModelForm): | 16 | class WebconferenceForm(forms.ModelForm): |
16 | subject = None | 17 | subject = None |
17 | control_subject = forms.CharField(widget = forms.HiddenInput()) | 18 | control_subject = forms.CharField(widget = forms.HiddenInput()) |
19 | + students = ParticipantsMultipleChoiceField(queryset = None) | ||
18 | 20 | ||
19 | def __init__(self, *args, **kwargs): | 21 | def __init__(self, *args, **kwargs): |
20 | super(WebconferenceForm, self).__init__(*args, **kwargs) | 22 | super(WebconferenceForm, self).__init__(*args, **kwargs) |
webpage/forms.py
@@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _ | @@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _ | ||
4 | from django.utils.html import strip_tags | 4 | from django.utils.html import strip_tags |
5 | 5 | ||
6 | from subjects.models import Tag | 6 | from subjects.models import Tag |
7 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
7 | 8 | ||
8 | from .models import Webpage | 9 | from .models import Webpage |
9 | 10 | ||
@@ -11,6 +12,7 @@ from resubmit.widgets import ResubmitFileWidget | @@ -11,6 +12,7 @@ from resubmit.widgets import ResubmitFileWidget | ||
11 | 12 | ||
12 | class WebpageForm(forms.ModelForm): | 13 | class WebpageForm(forms.ModelForm): |
13 | subject = None | 14 | subject = None |
15 | + students = ParticipantsMultipleChoiceField(queryset = None) | ||
14 | 16 | ||
15 | def __init__(self, *args, **kwargs): | 17 | def __init__(self, *args, **kwargs): |
16 | super(WebpageForm, self).__init__(*args, **kwargs) | 18 | super(WebpageForm, self).__init__(*args, **kwargs) |
youtube_video/forms.py
@@ -8,6 +8,7 @@ import requests | @@ -8,6 +8,7 @@ import requests | ||
8 | import re | 8 | import re |
9 | 9 | ||
10 | from subjects.models import Tag | 10 | from subjects.models import Tag |
11 | +from subjects.forms import ParticipantsMultipleChoiceField | ||
11 | 12 | ||
12 | from pendencies.forms import PendenciesForm | 13 | from pendencies.forms import PendenciesForm |
13 | from pendencies.models import Pendencies | 14 | from pendencies.models import Pendencies |
@@ -18,6 +19,7 @@ from .models import YTVideo | @@ -18,6 +19,7 @@ from .models import YTVideo | ||
18 | class YTVideoForm(forms.ModelForm): | 19 | class YTVideoForm(forms.ModelForm): |
19 | subject = None | 20 | subject = None |
20 | control_subject = forms.CharField(widget = forms.HiddenInput()) | 21 | control_subject = forms.CharField(widget = forms.HiddenInput()) |
22 | + students = ParticipantsMultipleChoiceField(queryset = None) | ||
21 | 23 | ||
22 | def __init__(self, *args, **kwargs): | 24 | def __init__(self, *args, **kwargs): |
23 | super(YTVideoForm, self).__init__(*args, **kwargs) | 25 | super(YTVideoForm, self).__init__(*args, **kwargs) |