Commit 952f8c33f7409d8f9b0b0e3ab468c7ff9df9350a

Authored by Filipe Medeiros
1 parent 7f42d767

Updating forms from courses

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