Commit efe9211511b329a0a898abd09abd21a4c91af927
1 parent
b5382624
Exists in
master
and in
5 other branches
Ajustes nos campos da classe Course
Showing
7 changed files
with
9 additions
and
195 deletions
Show diff stats
app/templates/home_admin_content.html
... | ... | @@ -2,16 +2,7 @@ |
2 | 2 | |
3 | 3 | {% for course in objects %} |
4 | 4 | <div class="panel panel-default courseHome"> |
5 | - <div class="panel-body"> | |
6 | - <p>{{ course }}</p> | |
7 | - </div> | |
8 | - <div class="panel-footer"> | |
9 | - <ul> | |
10 | - <li>{% trans 'Students' %}: {{ course.max_students }}</li> | |
11 | - <li>{% trans 'Beginning' %}: {{ course.init_date }}</li> | |
12 | - <li>{% trans 'End' %}: {{ course.end_date }}</li> | |
13 | - </ul> | |
14 | - </div> | |
5 | + <br><h4>{{ course }}</h4> | |
15 | 6 | <a href="{% url 'course:update' course.slug %}" class="btn btn-outline-info">{% trans 'Edit' %}</a> |
16 | 7 | </div> |
17 | -{% endfor %} | |
18 | 8 | \ No newline at end of file |
9 | +{% endfor %} | ... | ... |
courses/forms.py
... | ... | @@ -16,60 +16,19 @@ class CategoryCourseForm(forms.ModelForm): |
16 | 16 | 'name': _('CourseCategory name') |
17 | 17 | } |
18 | 18 | |
19 | - | |
20 | 19 | class CourseForm(forms.ModelForm): |
21 | - def clean_end_register_date(self): | |
22 | - init_register_date = self.cleaned_data['init_register_date'] | |
23 | - end_register_date = self.cleaned_data['end_register_date'] | |
24 | - | |
25 | - if init_register_date and end_register_date and end_register_date < init_register_date: | |
26 | - raise forms.ValidationError(_('The end date may not be before the start date.')) | |
27 | - return end_register_date | |
28 | - | |
29 | - def clean_init_date(self): | |
30 | - end_register_date = self.cleaned_data['end_register_date'] | |
31 | - init_date = self.cleaned_data['init_date'] | |
32 | - | |
33 | - if end_register_date and init_date and init_date <= end_register_date: | |
34 | - raise forms.ValidationError(_('The course start date must be after the end of registration.')) | |
35 | - return init_date | |
36 | - | |
37 | - def clean_end_date(self): | |
38 | - init_date = self.cleaned_data['init_date'] | |
39 | - end_date = self.cleaned_data['end_date'] | |
40 | - | |
41 | - if init_date and end_date and end_date < init_date: | |
42 | - raise forms.ValidationError(_('The end date may not be before the start date.')) | |
43 | - return end_date | |
44 | - | |
45 | 20 | |
46 | 21 | class Meta: |
47 | 22 | model = Course |
48 | - fields = ('name', 'objectivies', 'content', 'max_students', 'init_register_date', 'end_register_date', | |
49 | - 'init_date', 'end_date', 'category', 'coordenator','public') | |
23 | + fields = ('name', 'category', 'coordenator','public') | |
50 | 24 | labels = { |
51 | 25 | 'name': _('Name'), |
52 | - 'objectivies': _('Objectives'), | |
53 | - 'content': _('Content'), | |
54 | - 'max_students': _('Number of studets maximum'), | |
55 | - 'init_register_date': _('Course registration start date'), | |
56 | - 'end_register_date': _('Course registration end date'), | |
57 | - 'init_date': _('Course start date'), | |
58 | - 'end_date': _('Course end date'), | |
59 | 26 | 'category': _('Category'), |
60 | 27 | 'coordenator': _('Coordenator'), |
61 | 28 | 'public':_('Public'), |
62 | 29 | } |
63 | 30 | help_texts = { |
64 | 31 | 'name': _('Course name'), |
65 | - 'objectivies': _('Course objective'), | |
66 | - 'content': _('Course modules'), | |
67 | - 'max_students': _('Max number of students that a class can have'), | |
68 | - 'init_register_date': _('Date that starts the registration period of the course (dd/mm/yyyy)'), | |
69 | - 'end_register_date': _('Date that ends the registration period of the course (dd/mm/yyyy)'), | |
70 | - 'init_date': _('Date that the course starts (dd/mm/yyyy)'), | |
71 | - 'end_date': _('Date that the course ends (dd/mm/yyyy)'), | |
72 | - 'category': _('CourseCategory which the course belongs'), | |
73 | 32 | 'coordenator': _('Course Coordenator'), |
74 | 33 | 'public':_('To define if the course can be accessed by people not registered'), |
75 | 34 | } |
... | ... | @@ -77,77 +36,31 @@ class CourseForm(forms.ModelForm): |
77 | 36 | widgets = { |
78 | 37 | 'ategoy': forms.Select(), |
79 | 38 | 'coordenator': forms.Select(), |
80 | - 'content': SummernoteWidget(), | |
81 | - 'objectivies': SummernoteWidget(), | |
82 | 39 | } |
83 | 40 | |
84 | 41 | class UpdateCourseForm(CourseForm): |
85 | 42 | |
86 | - def clean_end_register_date(self): | |
87 | - init_register_date = self.cleaned_data['init_register_date'] | |
88 | - end_register_date = self.cleaned_data['end_register_date'] | |
89 | - | |
90 | - if init_register_date and end_register_date and end_register_date < init_register_date: | |
91 | - raise forms.ValidationError(_('The end date may not be before the start date.')) | |
92 | - return end_register_date | |
93 | - | |
94 | - def clean_init_date(self): | |
95 | - end_register_date = self.cleaned_data['end_register_date'] | |
96 | - init_date = self.cleaned_data['init_date'] | |
97 | - | |
98 | - if end_register_date and init_date and init_date <= end_register_date: | |
99 | - raise forms.ValidationError(_('The course start date must be after the end of registration.')) | |
100 | - return init_date | |
101 | - | |
102 | - def clean_end_date(self): | |
103 | - init_date = self.cleaned_data['init_date'] | |
104 | - end_date = self.cleaned_data['end_date'] | |
105 | - | |
106 | - if init_date and end_date and end_date < init_date: | |
107 | - raise forms.ValidationError(_('The end date may not be before the start date.')) | |
108 | - return end_date | |
109 | - | |
110 | 43 | def __init__(self, *args, **kwargs): |
111 | 44 | super(UpdateCourseForm, self).__init__(*args, **kwargs) |
112 | 45 | self.fields["students"].required = False |
113 | 46 | |
114 | 47 | class Meta: |
115 | 48 | model = Course |
116 | - fields = ('name', 'objectivies', 'content', 'max_students', 'init_register_date', 'end_register_date', | |
117 | - 'init_date', 'end_date', 'category','students', 'coordenator','public') | |
49 | + fields = ('name', 'category', 'coordenator','public') | |
118 | 50 | labels = { |
119 | 51 | 'name': _('Name'), |
120 | - 'objectivies': _('Objectives'), | |
121 | - 'content': _('Content'), | |
122 | - 'max_students': _('Number of studets maximum'), | |
123 | - 'init_register_date': _('Course registration start date'), | |
124 | - 'end_register_date': _('Course registration end date'), | |
125 | - 'init_date': _('Course start date'), | |
126 | - 'end_date': _('Course end date'), | |
127 | 52 | 'category': _('Category'), |
128 | 53 | 'coordenator': _('Coordenator'), |
129 | - 'students': _('Student'), | |
130 | 54 | 'public':_('Public'), |
131 | 55 | } |
132 | 56 | help_texts = { |
133 | 57 | 'name': _('Course name'), |
134 | - 'objectivies': _('Course objective'), | |
135 | - 'content': _('Course modules'), | |
136 | - 'max_students': _('Max number of students that a class can have'), | |
137 | - 'init_register_date': _('Date that starts the registration period of the course (dd/mm/yyyy)'), | |
138 | - 'end_register_date': _('Date that ends the registration period of the course (dd/mm/yyyy)'), | |
139 | - 'init_date': _('Date that the course starts (dd/mm/yyyy)'), | |
140 | - 'end_date': _('Date that the course ends (dd/mm/yyyy)'), | |
141 | - 'category': _('CourseCategory which the course belongs'), | |
142 | 58 | 'coordenator': _('Course Coordenator'), |
143 | - 'students': _("Course's Students"), | |
144 | 59 | 'public':_('To define if the course can be accessed by people not registered'), |
145 | 60 | } |
146 | 61 | widgets = { |
147 | 62 | 'categoy': forms.Select(), |
148 | 63 | 'coordenator': forms.Select(), |
149 | - 'content': SummernoteWidget(), | |
150 | - 'objectivies': SummernoteWidget(), | |
151 | 64 | } |
152 | 65 | |
153 | 66 | class SubjectForm(forms.ModelForm): | ... | ... |
courses/migrations/0001_initial.py
... | ... | @@ -57,20 +57,13 @@ class Migration(migrations.Migration): |
57 | 57 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
58 | 58 | ('name', models.CharField(max_length=100, verbose_name='Name')), |
59 | 59 | ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name', unique=True, verbose_name='Slug')), |
60 | - ('objectivies', models.TextField(blank=True, verbose_name='Objectivies')), | |
61 | - ('content', models.TextField(blank=True, verbose_name='Content')), | |
62 | - ('max_students', models.PositiveIntegerField(blank=True, verbose_name='Maximum Students')), | |
63 | 60 | ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation Date')), |
64 | - ('init_register_date', models.DateField(verbose_name='Register Date (Begin)')), | |
65 | - ('end_register_date', models.DateField(verbose_name='Register Date (End)')), | |
66 | - ('init_date', models.DateField(verbose_name='Begin of Course Date')), | |
67 | - ('end_date', models.DateField(verbose_name='End of Course Date')), | |
68 | 61 | ('public', models.BooleanField(default=False, verbose_name='Public')), |
69 | 62 | ], |
70 | 63 | options={ |
71 | 64 | 'verbose_name_plural': 'Courses', |
72 | 65 | 'verbose_name': 'Course', |
73 | - 'ordering': ('create_date', 'name'), | |
66 | + 'ordering': ('create_date', 'name'), | |
74 | 67 | }, |
75 | 68 | ), |
76 | 69 | migrations.CreateModel( | ... | ... |
courses/models.py
... | ... | @@ -38,16 +38,9 @@ class Course(models.Model): |
38 | 38 | |
39 | 39 | name = models.CharField(_('Name'), max_length = 100) |
40 | 40 | slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) |
41 | - objectivies = models.TextField(_('Objectivies'), blank = True) | |
42 | - content = models.TextField(_('Content'), blank = True) | |
43 | - max_students = models.PositiveIntegerField(_('Maximum Students'), blank = True) | |
44 | - create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) | |
45 | - init_register_date = models.DateField(_('Register Date (Begin)')) | |
46 | - end_register_date = models.DateField(_('Register Date (End)')) | |
47 | - init_date = models.DateField(_('Begin of Course Date')) | |
48 | - end_date = models.DateField(_('End of Course Date')) | |
41 | + create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True, blank = True) | |
49 | 42 | category = models.ForeignKey(CourseCategory, verbose_name = _('Category'), related_name='course_category') |
50 | - coordenator = models.ForeignKey(User, verbose_name = _('Coordenator'), related_name ='course_coordenator', null = True) | |
43 | + coordenator = models.ForeignKey(User, verbose_name = _('Coordenator'), related_name ='course_coordenator', null = True, blank = True) | |
51 | 44 | professors = models.ManyToManyField(User,verbose_name=_('Professors'), related_name='courses_professors') |
52 | 45 | students = models.ManyToManyField(User,verbose_name=_('Students'), related_name='courses_student', blank = True) |
53 | 46 | public = models.BooleanField(_('Public'), default=False) | ... | ... |
courses/serializers.py
... | ... | @@ -6,8 +6,7 @@ class CourseSerializer(serializers.ModelSerializer): |
6 | 6 | #The set comes from the ManyToMany Relationship in django |
7 | 7 | class Meta: |
8 | 8 | model = Course |
9 | - fields = ('name', 'slug', 'objectivies', 'content', 'max_students', 'create_date', | |
10 | - 'init_register_date', 'end_register_date', 'init_date', 'end_date', 'public', 'category' ,'students', 'professors') | |
9 | + fields = ('name', 'category', 'coordenator','public') | |
11 | 10 | |
12 | 11 | class SubjectSerializer(serializers.ModelSerializer): |
13 | 12 | class Meta: |
... | ... | @@ -18,5 +17,3 @@ class TopicSerializer(serializers.ModelSerializer): |
18 | 17 | class Meta: |
19 | 18 | model = Topic |
20 | 19 | fields = ('name', 'slug','description','create_date','update_date','visible','owner','subject') |
21 | - | |
22 | - | ... | ... |
courses/templates/course/course_card.html
... | ... | @@ -3,9 +3,6 @@ |
3 | 3 | <div class="panel panel-info"> |
4 | 4 | <div class="panel-heading course"> |
5 | 5 | <div class="row"> |
6 | - <div class="col-md-1 moreAccordion" data-toggle="collapse" data-parent="#accordion-{{course.slug}}" href=".collapseOne-{{course.slug}}" aria-expanded="false" aria-controls="collapseOne-{{course.slug}}"> | |
7 | - <button class="btn btn-default btn-sm caret-square"><i class="fa fa-caret-square-o-down fa-2x" aria-hidden="true"></i></button> | |
8 | - </div> | |
9 | 6 | <div class="col-xs-5 col-md-5 titleTopic"> |
10 | 7 | <a role="button" href="{% url 'course:view' course.slug %}"> |
11 | 8 | <h4>{{course.name}}</h4> |
... | ... | @@ -31,27 +28,6 @@ |
31 | 28 | {% endif %} |
32 | 29 | </div> |
33 | 30 | </div> |
34 | - <div class="panel-collapse collapseOne-{{course.slug}} collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> | |
35 | - <div class="panel-body"> | |
36 | - <p><b>{% trans 'Course Name' %}: </b>{{course.name}}</p> | |
37 | - <p><b>{% trans 'Coordenator' %}: </b>{{course.coordenator}}</p> | |
38 | - <p><b>{% trans 'Professor' %}: </b>{{course.professors.all.0}}</p> | |
39 | - <p> | |
40 | - <b>{% trans 'Description' %}:</b> | |
41 | - <i> | |
42 | - {{course.content | safe }} | |
43 | - </i> | |
44 | - </p> | |
45 | - <div class="row"> | |
46 | - <div class="col-xs-6 col-md-6 data_register_course"> | |
47 | - <p><b>{% trans 'Init register' %}: </b>{{course.init_register_date}}</p> | |
48 | - </div> | |
49 | - <div class="col-xs-6 col-md-6 data_register_course"> | |
50 | - <p><b>{% trans 'End register' %}: </b>{{course.end_register_date}}</p> | |
51 | - </div> | |
52 | - </div> | |
53 | - </div> | |
54 | - </div> | |
55 | 31 | </div> |
56 | 32 | </div> |
57 | 33 | ... | ... |
courses/templates/course/view.html
... | ... | @@ -47,21 +47,6 @@ |
47 | 47 | </div> |
48 | 48 | <div class="panel-body"> |
49 | 49 | <p><b>{% trans 'Coordinator' %}: </b>{{course.coordenator}}</p> |
50 | - <p><b>{% trans 'Teacher' %}: </b>{{course.professors.all.0}}</p> | |
51 | - <p> | |
52 | - <b>{% trans 'Description' %}:</b> | |
53 | - <i> | |
54 | - {{ course.objectivies |safe }} | |
55 | - </i> | |
56 | - </p> | |
57 | - <div class="row"> | |
58 | - <div class="col-xs-6 col-md-6 data_register_course"> | |
59 | - <p><b>{% trans 'Begin of Course Date' %}: </b>{{course.init_date}}</p> | |
60 | - </div> | |
61 | - <div class="col-xs-6 col-md-6 data_register_course"> | |
62 | - <p><b>{% trans 'End of Course Date' %}: </b>{{course.end_date}}</p> | |
63 | - </div> | |
64 | - </div> | |
65 | 50 | </div> |
66 | 51 | </div> |
67 | 52 | |
... | ... | @@ -84,20 +69,12 @@ |
84 | 69 | </div> |
85 | 70 | </div> |
86 | 71 | |
87 | -<div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"> | |
88 | - <div> | |
89 | - | |
90 | - <div class="panel panel-info"> | |
91 | -</div> | |
92 | -</div> | |
72 | +<div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"></div> | |
93 | 73 | <div class="cards-detail"> |
94 | 74 | {% for subject in subjects %} |
95 | 75 | <div class="panel panel-default panel_{{ subject.id }}"> |
96 | 76 | <div class="panel-heading heading_{{subject.id}} subject ui-sortable-handle"> |
97 | 77 | <div class="row"> |
98 | - <div class="col-md-1 moreAccordion" data-toggle="collapse" data-parent="#accordion-{{subject.slug}}" href=".collapseSubject-{{subject.slug}}" aria-expanded="false" aria-controls="collapseSubject-{{subject.slug}}"> | |
99 | - <button class="btn btn-default btn-sm caret-square"><i class="fa fa-caret-square-o-down fa-2x" aria-hidden="true"></i></button> | |
100 | - </div> | |
101 | 78 | <div class="col-xs-9 col-md-10 titleTopic"> |
102 | 79 | <a role="button" href="{% url 'course:view_subject' subject.slug %}"> |
103 | 80 | <h4>{{subject.name}}</h4> |
... | ... | @@ -126,29 +103,6 @@ |
126 | 103 | {% endif %} |
127 | 104 | </div> |
128 | 105 | </div> |
129 | - <div class="panel-collapse collapseSubject-{{subject.slug}} collapse in" aria-labelledby="heading_{{subject.id}}" aria-expanded="true" aria-hidden="false"> | |
130 | - <div class="panel-body"> | |
131 | - <p><b>{% trans "Professor" %}: </b>{% for professor in subject.professors.all %}{% if not forloop.first %},{% endif %} | |
132 | - {{professor}}{% if forloop.last %}.{% endif %}{% endfor %}</p> | |
133 | - <p> | |
134 | - <b>{% trans 'Category' %}: </b><i>{{ subject.category }}</i> | |
135 | - </p> | |
136 | - <p> | |
137 | - <b>{% trans "Description" %}: </b> | |
138 | - <i> | |
139 | - {{subject.description | safe}} | |
140 | - </i> | |
141 | - </p> | |
142 | - <div class="row"> | |
143 | - <div class="col-xs-6 col-md-6"> | |
144 | - <p><b>{% trans "Begining" %}: </b>{{subject.init_date}}</p> | |
145 | - </div> | |
146 | - <div class="col-xs-6 col-md-6"> | |
147 | - <p><b>{% trans "End" %}: </b>{{subject.end_date}}</p> | |
148 | - </div> | |
149 | - </div> | |
150 | - </div> | |
151 | - </div> | |
152 | 106 | </div> |
153 | 107 | {% endfor %} |
154 | 108 | |
... | ... | @@ -159,10 +113,7 @@ |
159 | 113 | <a href="{% url 'course:create_subject' course.slug %}" data-toggle="modal" data-target="" class="btn btn-primary btn-lg btn-block btn-raised">{% trans 'Create Subject' %}<div class="ripple-container"></div></a> |
160 | 114 | </div> |
161 | 115 | {% endif %} |
162 | - | |
163 | -</div> | |
164 | 116 | </div> |
165 | 117 | </div> |
166 | -<div class="row" id="modal_subject"> | |
167 | 118 | |
168 | 119 | {% endblock %} | ... | ... |