forms.py
5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from django import forms
from django.utils.translation import ugettext_lazy as _
from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity, FileMaterial, LinkMaterial
from s3direct.widgets import S3DirectWidget
from django_summernote.widgets import SummernoteWidget
class CategoryCourseForm(forms.ModelForm):
class Meta:
model = CourseCategory
fields = ('name',)
labels = {
'name': _('Name')
}
help_texts = {
'name': _('CourseCategory name')
}
class CourseForm(forms.ModelForm):
class Meta:
model = Course
fields = ('name', 'description',
'category', 'coordenator','public')
labels = {
'name': _('Name'),
'content': _('Content'),
'category': _('Category'),
'coordenator': _('Coordenator'),
'public':_('Public'),
}
help_texts = {
'name': _('Course name'),
'content': _('Course modules'),
'category': _('CourseCategory which the course belongs'),
'coordenator': _('Course Coordenator'),
'public':_('To define if the course can be accessed by people not registered'),
}
widgets = {
'category': forms.Select(),
'coordenator': forms.Select(),
'content': SummernoteWidget(),
'objectivies': SummernoteWidget(),
}
class UpdateCourseForm(CourseForm):
def __init__(self, *args, **kwargs):
super(UpdateCourseForm, self).__init__(*args, **kwargs)
class Meta:
model = Course
fields = ('name', 'description',
'category', 'coordenator','public')
labels = {
'name': _('Name'),
'description': _('Description'),
'category': _('Category'),
'coordenator': _('Coordenator'),
'public':_('Public'),
}
help_texts = {
'name': _('Course name'),
'description': _('Description about the course'),
'category': _('CourseCategory which the course belongs'),
'coordenator': _('Course Coordenator'),
'public':_('To define if the course can be accessed by people not registered'),
}
widgets = {
'category': forms.Select(),
'coordenator': forms.Select(),
'description': SummernoteWidget(),
'objectivies': SummernoteWidget(),
}
class SubjectForm(forms.ModelForm):
class Meta:
model = Subject
fields = ('name', 'description','init_date', 'end_date', 'visible',)
labels = {
'name': _('Name'),
'description': _('Description'),
'init_date': _('Start date'),
'end_date': _('End date'),
'visible': _('Is it visible?'),
}
help_texts = {
'name': _("Subjects's name"),
'description': _("Subjects's description"),
'init_date': _('Start date of the subject'),
'end_date': _('End date of the subject'),
'visible': _('Is the subject visible?'),
}
widgets = {
'description':SummernoteWidget(),
}
class TopicForm(forms.ModelForm):
class Meta:
model = Topic
fields = ('name', 'description',)
labels = {
'name': _('Name'),
'description': _('Description'),
}
help_texts = {
'name': _("Topic's name"),
'description': _("Topic's description"),
}
widgets = {
'description':SummernoteWidget(),
}
class ActivityFileForm(forms.ModelForm):
name = forms.CharField(
required=False,
max_length=100,
widget=forms.TextInput(attrs={
'placeholder': 'Nome',
'class': 'form-control'
},
)
)
pdf = forms.URLField(required=True, widget=S3DirectWidget(
dest='activitys',
html=(
'<div class="s3direct" data-policy-url="{policy_url}">'
' <a class="file-link" target="_blank" href="{file_url}">{file_name}</a>'
' <a class="file-remove" href="#remove">Remover</a>'
' <input class="file-url" type="hidden" value="{file_url}" id="{element_id}" name="{name}" />'
' <input class="file-dest" type="hidden" value="{dest}">'
' <input class="file-input" type="file" />'
' <div class="progress">'
' <div class="progress-bar progress-bar-success progress-bar-striped active bar">'
' </div>'
' </div>'
'</div>'
)))
class Meta:
model = ActivityFile
fields = ['pdf','name']
class ActivityForm(forms.ModelForm):
class Meta:
model = Activity
fields = ['topic', 'limit_date', 'students','all_students']
class FileMaterialForm(forms.ModelForm):
class Meta:
model = FileMaterial
fields = ['name', 'file']
class LinkMaterialForm(forms.ModelForm):
class Meta:
model = LinkMaterial
fields = ['material', 'name', 'description','url']