Commit 2ceb0949f1ffb00b7b638745fe59e59cf5b51e9d
1 parent
89bac9d5
Exists in
master
and in
5 other branches
updated dependent files #140
Showing
4 changed files
with
22 additions
and
22 deletions
Show diff stats
courses/admin.py
courses/forms.py
1 | 1 | from django import forms |
2 | 2 | from django.utils.translation import ugettext_lazy as _ |
3 | -from .models import Category, Course, Subject, Topic, ActivityFile, Activity | |
3 | +from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity | |
4 | 4 | from s3direct.widgets import S3DirectWidget |
5 | 5 | |
6 | 6 | |
7 | -class CategoryForm(forms.ModelForm): | |
7 | +class CategoryCourseForm(forms.ModelForm): | |
8 | 8 | |
9 | 9 | class Meta: |
10 | - model = Category | |
10 | + model = CourseCategory | |
11 | 11 | fields = ('name',) |
12 | 12 | labels = { |
13 | 13 | 'name': _('Name') |
14 | 14 | } |
15 | 15 | help_texts = { |
16 | - 'name': _('Category name') | |
16 | + 'name': _('CourseCategory name') | |
17 | 17 | } |
18 | 18 | |
19 | 19 | |
... | ... | @@ -62,7 +62,7 @@ class CourseForm(forms.ModelForm): |
62 | 62 | 'init_date': _('Course start date'), |
63 | 63 | 'end_date': _('Course end date'), |
64 | 64 | 'image': _('Image'), |
65 | - 'category': _('Category'), | |
65 | + 'category': _('CourseCategory'), | |
66 | 66 | } |
67 | 67 | help_texts = { |
68 | 68 | 'name': _('Course name'), |
... | ... | @@ -74,7 +74,7 @@ class CourseForm(forms.ModelForm): |
74 | 74 | 'init_date': _('Date that the course starts (dd/mm/yyyy)'), |
75 | 75 | 'end_date': _('Date that the course ends (dd/mm/yyyy)'), |
76 | 76 | 'image': _('Representative image of the course'), |
77 | - 'category': _('Category which the course belongs'), | |
77 | + 'category': _('CourseCategory which the course belongs'), | |
78 | 78 | } |
79 | 79 | |
80 | 80 | widgets = { |
... | ... | @@ -102,7 +102,7 @@ class UpdateCourseForm(CourseForm): |
102 | 102 | 'init_date': _('Course start date'), |
103 | 103 | 'end_date': _('Course end date'), |
104 | 104 | 'image': _('Image'), |
105 | - 'category': _('Category'), | |
105 | + 'category': _('CourseCategory'), | |
106 | 106 | 'students': _('Student'), |
107 | 107 | } |
108 | 108 | help_texts = { |
... | ... | @@ -115,7 +115,7 @@ class UpdateCourseForm(CourseForm): |
115 | 115 | 'init_date': _('Date that the course starts (dd/mm/yyyy)'), |
116 | 116 | 'end_date': _('Date that the course ends (dd/mm/yyyy)'), |
117 | 117 | 'image': _('Representative image of the course'), |
118 | - 'category': _('Category which the course belongs'), | |
118 | + 'category': _('CourseCategory which the course belongs'), | |
119 | 119 | 'students': _("Course's Students"), |
120 | 120 | } |
121 | 121 | widgets = { | ... | ... |
courses/models.py
... | ... | @@ -31,7 +31,7 @@ class Course(models.Model): |
31 | 31 | init_date = models.DateField(_('Begin of Course Date')) |
32 | 32 | end_date = models.DateField(_('End of Course Date')) |
33 | 33 | image = models.ImageField(verbose_name = _('Image'), blank = True, upload_to = 'courses/') |
34 | - category = models.ForeignKey(Category, verbose_name = _('Category')) | |
34 | + category = models.ForeignKey(CourseCategory, verbose_name = _('Category')) | |
35 | 35 | professors = models.ManyToManyField(User,verbose_name=_('Professors'), related_name='courses_professors') |
36 | 36 | students = models.ManyToManyField(User,verbose_name=_('Students'), related_name='courses_student') |
37 | 37 | ... | ... |
courses/views.py
... | ... | @@ -11,8 +11,8 @@ from rolepermissions.verifications import has_role |
11 | 11 | from django.db.models import Q |
12 | 12 | from rolepermissions.verifications import has_object_permission |
13 | 13 | |
14 | -from .forms import CourseForm, UpdateCourseForm, CategoryForm, SubjectForm,TopicForm,ActivityForm | |
15 | -from .models import Course, Subject, Category,Topic, SubjectCategory,Activity | |
14 | +from .forms import CourseForm, UpdateCourseForm, CategoryCourseForm, SubjectForm,TopicForm,ActivityForm | |
15 | +from .models import Course, Subject, CourseCategory,Topic, SubjectCategory,Activity | |
16 | 16 | from core.mixins import NotificationMixin |
17 | 17 | from users.models import User |
18 | 18 | |
... | ... | @@ -29,7 +29,7 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
29 | 29 | |
30 | 30 | def get_context_data(self, **kwargs): |
31 | 31 | context = super(IndexView, self).get_context_data(**kwargs) |
32 | - context['categories'] = Category.objects.all() | |
32 | + context['categories'] = CourseCategory.objects.all() | |
33 | 33 | context['courses_teacher'] = Course.objects.filter(professors__name = self.request.user.name) |
34 | 34 | context['courses_student'] = Course.objects.filter(students__name = self.request.user.name) |
35 | 35 | |
... | ... | @@ -178,13 +178,13 @@ class FilteredView(LoginRequiredMixin, generic.ListView): |
178 | 178 | paginate_by = 3 |
179 | 179 | |
180 | 180 | def get_queryset(self): |
181 | - category = get_object_or_404(Category, slug = self.kwargs.get('slug')) | |
181 | + category = get_object_or_404(CourseCategory, slug = self.kwargs.get('slug')) | |
182 | 182 | return Course.objects.filter(category = category) |
183 | 183 | |
184 | 184 | def get_context_data(self, **kwargs): |
185 | - category = get_object_or_404(Category, slug = self.kwargs.get('slug')) | |
185 | + category = get_object_or_404(CourseCategory, slug = self.kwargs.get('slug')) | |
186 | 186 | context = super(FilteredView, self).get_context_data(**kwargs) |
187 | - context['categories'] = Category.objects.all() | |
187 | + context['categories'] = CourseCategory.objects.all() | |
188 | 188 | context['cat'] = category |
189 | 189 | |
190 | 190 | return context |
... | ... | @@ -193,7 +193,7 @@ class IndexCatView(LoginRequiredMixin, generic.ListView): |
193 | 193 | |
194 | 194 | login_url = reverse_lazy("core:home") |
195 | 195 | redirect_field_name = 'next' |
196 | - queryset = Category.objects.all() | |
196 | + queryset = CourseCategory.objects.all() | |
197 | 197 | template_name = 'category/index.html' |
198 | 198 | context_object_name = 'categories' |
199 | 199 | paginate_by = 3 |
... | ... | @@ -204,7 +204,7 @@ class CreateCatView(LoginRequiredMixin, HasRoleMixin, generic.edit.CreateView): |
204 | 204 | login_url = reverse_lazy("core:home") |
205 | 205 | redirect_field_name = 'next' |
206 | 206 | template_name = 'category/create.html' |
207 | - form_class = CategoryForm | |
207 | + form_class = CategoryCourseForm | |
208 | 208 | success_url = reverse_lazy('course:manage_cat') |
209 | 209 | |
210 | 210 | def render_to_response(self, context, **response_kwargs): |
... | ... | @@ -218,8 +218,8 @@ class UpdateCatView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): |
218 | 218 | login_url = reverse_lazy("core:home") |
219 | 219 | redirect_field_name = 'next' |
220 | 220 | template_name = 'category/update.html' |
221 | - model = Category | |
222 | - form_class = CategoryForm | |
221 | + model = CourseCategory | |
222 | + form_class = CategoryCourseForm | |
223 | 223 | success_url = reverse_lazy('course:manage_cat') |
224 | 224 | |
225 | 225 | def render_to_response(self, context, **response_kwargs): |
... | ... | @@ -230,7 +230,7 @@ class UpdateCatView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): |
230 | 230 | class ViewCat(LoginRequiredMixin, generic.DetailView): |
231 | 231 | login_url = reverse_lazy("core:home") |
232 | 232 | redirect_field_name = 'next' |
233 | - model = Category | |
233 | + model = CourseCategory | |
234 | 234 | template_name = 'category/view.html' |
235 | 235 | context_object_name = 'category' |
236 | 236 | |
... | ... | @@ -239,7 +239,7 @@ class DeleteCatView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
239 | 239 | allowed_roles = ['professor', 'system_admin'] |
240 | 240 | login_url = reverse_lazy("core:home") |
241 | 241 | redirect_field_name = 'next' |
242 | - model = Category | |
242 | + model = CourseCategory | |
243 | 243 | template_name = 'category/delete.html' |
244 | 244 | success_url = reverse_lazy('course:manage_cat') |
245 | 245 | ... | ... |