Commit 16bef47618f579afc56afa6583b47b40bb9ab78d
1 parent
f2ece574
Exists in
master
and in
3 other branches
started replicate procedure, I'm still having problems setting up description field and coordinators
Showing
3 changed files
with
22 additions
and
1 deletions
Show diff stats
categories/templates/categories/list.html
@@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
46 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | 46 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
47 | </button> | 47 | </button> |
48 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | 48 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
49 | - <li><a href="#"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | 49 | + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> |
50 | <li><a href="#"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | 50 | <li><a href="#"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> |
51 | <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | 51 | <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> |
52 | </ul> | 52 | </ul> |
categories/urls.py
@@ -5,4 +5,5 @@ urlpatterns = [ | @@ -5,4 +5,5 @@ urlpatterns = [ | ||
5 | url(r'^$', views.IndexView.as_view(), name='index'), | 5 | url(r'^$', views.IndexView.as_view(), name='index'), |
6 | url(r'^create/$', views.CreateCategory.as_view(), name='create'), | 6 | url(r'^create/$', views.CreateCategory.as_view(), name='create'), |
7 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.DeleteCategory.as_view(), name='delete'), | 7 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.DeleteCategory.as_view(), name='delete'), |
8 | + url(r'^replicate/(?P<slug>[\w_-]+)/$', views.CreateCategory.as_view(), name='replicate'), | ||
8 | ] | 9 | ] |
9 | \ No newline at end of file | 10 | \ No newline at end of file |
categories/views.py
@@ -76,8 +76,28 @@ class CreateCategory(HasRoleMixin, CreateView): | @@ -76,8 +76,28 @@ class CreateCategory(HasRoleMixin, CreateView): | ||
76 | 76 | ||
77 | def get_initial(self): | 77 | def get_initial(self): |
78 | initial = super(CreateCategory, self).get_initial() | 78 | initial = super(CreateCategory, self).get_initial() |
79 | + if self.kwargs.get('slug'): | ||
80 | + category = get_object_or_404(Category, slug = self.kwargs['slug']) | ||
81 | + initial = initial.copy() | ||
82 | + | ||
83 | + initial['description'] = category.description | ||
84 | + initial['name'] = category.name | ||
85 | + initial['visible'] = category.visible | ||
86 | + #initial['coordinators'] = category.coordinators | ||
79 | return initial | 87 | return initial |
80 | 88 | ||
89 | + | ||
90 | + def get_form(self, form_class=None): | ||
91 | + """ | ||
92 | + Returns an instance of the form to be used in this view. | ||
93 | + """ | ||
94 | + #print(self.kwargs) | ||
95 | + if form_class is None: | ||
96 | + form_class = self.get_form_class() | ||
97 | + | ||
98 | + | ||
99 | + return form_class(**self.get_form_kwargs()) | ||
100 | + | ||
81 | def form_valid(self, form): | 101 | def form_valid(self, form): |
82 | self.object = form.save() | 102 | self.object = form.save() |
83 | #TODO: Implement log calls | 103 | #TODO: Implement log calls |