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