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 | 46 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
47 | 47 | </button> |
48 | 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 | 50 | <li><a href="#"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> |
51 | 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 | 52 | </ul> | ... | ... |
categories/urls.py
... | ... | @@ -5,4 +5,5 @@ urlpatterns = [ |
5 | 5 | url(r'^$', views.IndexView.as_view(), name='index'), |
6 | 6 | url(r'^create/$', views.CreateCategory.as_view(), name='create'), |
7 | 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 | 10 | \ No newline at end of file | ... | ... |
categories/views.py
... | ... | @@ -76,8 +76,28 @@ class CreateCategory(HasRoleMixin, CreateView): |
76 | 76 | |
77 | 77 | def get_initial(self): |
78 | 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 | 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 | 101 | def form_valid(self, form): |
82 | 102 | self.object = form.save() |
83 | 103 | #TODO: Implement log calls | ... | ... |