Commit 7f65c389 authored by BERJON Matthieu's avatar BERJON Matthieu
Browse files

Update of the runner update view



I updated the runner update view by creating a new route, updating the
view class naming and performing several changes in the templates
(links and breadcrumbs).
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent 371ff60e
......@@ -37,7 +37,7 @@ urlpatterns = [
url(r'^runners/$', views.RunnerList.as_view(), name='runner_list'),
url(r'^runners/add/$', views.RunnerCreate.as_view(), name='runner_create'),
url(r'^settings/runners/(?P<pk>\d+)/$', views.UserRunnerUpdateView.as_view(), name='user_runner_update'),
url(r'^runners/(?P<pk>\d+)/$', views.RunnerUpdate.as_view(), name='runner_update'),
url(r'^settings/runners/delete/(?P<pk>\d+)/$', views.UserRunnerDeleteView.as_view(), name='user_runner_delete'),
]
......
......@@ -658,21 +658,6 @@ class WebappCreateJobView(SuccessMessageMixin, LoginRequiredMixin, CreateView):
return super(WebappCreateJobView, self).get_context_data(**kwargs)
class UserRunnerUpdateView(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
model = Runner
form_class = RunnerForm
success_message = 'Runner updated successfully.'
success_url = reverse_lazy('main:user_runner_list')
template_name = 'user_runner_update_form.html'
def get_form_kwargs(self):
kwargs = super(UserRunnerUpdateView, self).get_form_kwargs()
kwargs['request'] = self.request
return kwargs
class UserRunnerDeleteView(SuccessMessageMixin, LoginRequiredMixin, DeleteView):
model = Runner
success_message = 'Runner successfully deleted.'
......@@ -849,3 +834,16 @@ class RunnerCreate(SuccessMessageMixin, LoginRequiredMixin, CreateView):
kwargs = super(RunnerCreate, self).get_form_kwargs()
kwargs['request'] = self.request
return kwargs
class RunnerUpdate(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
model = Runner
form_class = RunnerForm
success_message = 'Runner updated successfully.'
success_url = reverse_lazy('main:runner_list')
template_name = 'runner_update_form.html'
def get_form_kwargs(self):
kwargs = super(RunnerUpdate, self).get_form_kwargs()
kwargs['request'] = self.request
return kwargs
......@@ -39,7 +39,7 @@
{{ app.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
<td><a href="{% url 'main:user_runner_update' runner.id %}"><i class="fas fa-pencil-alt"></i></a></td>
<td><a href="{% url 'main:runner_update' runner.id %}"><i class="fas fa-pencil-alt"></i></a></td>
<td><a href="{% url 'main:user_runner_delete' runner.id %}"><i class="fas fa-trash-alt"></i></a></td>
</tr>
{% endfor %}
......
......@@ -5,7 +5,12 @@
{% block breadcrumb %}
<li class="breadcrumb-item"><a href="{% url 'main:runner_list' %}">Runners</a></li>
{% url 'main:runner_create' as runner_url %}
{% if request.get_full_path == runner_url %}
<li class="breadcrumb-item active" aria-current="page">Create</li>
{% else %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% endif %}
{% endblock %}
{% block content %}
......@@ -76,7 +81,12 @@
</div>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Runner">
{% url 'main:runner_create' as runner_url %}
{% if request.get_full_path == runner_url %}
<input class="btn btn-primary" type="submit" value="Create runner">
{% else %}
<input class="btn btn-primary" type="submit" value="Update runner">
{% endif %}
</form>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment