Commit 371ff60e authored by BERJON Matthieu's avatar BERJON Matthieu
Browse files

Update of the runner create view



I updated the runner creation view by creating a new route, updating the
view and adapting the template accordingly.
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent 241a4c76
......@@ -36,7 +36,7 @@ urlpatterns = [
url(r'^profile/password$', views.UserPasswordUpdate.as_view(), name='user_password'),
url(r'^runners/$', views.RunnerList.as_view(), name='runner_list'),
url(r'^settings/runners/add/$', views.UserRunnerCreateView.as_view(), name='user_runner_create'),
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'^settings/runners/delete/(?P<pk>\d+)/$', views.UserRunnerDeleteView.as_view(), name='user_runner_delete'),
]
......
......@@ -659,18 +659,6 @@ class WebappCreateJobView(SuccessMessageMixin, LoginRequiredMixin, CreateView):
class UserRunnerCreateView(SuccessMessageMixin, LoginRequiredMixin, CreateView):
model = Runner
form_class = RunnerForm
success_message = 'Runner saved successfully.'
success_url = reverse_lazy('main:user_runner_list')
template_name = 'user_runner_update_form.html'
def get_form_kwargs(self):
kwargs = super(UserRunnerCreateView, self).get_form_kwargs()
kwargs['request'] = self.request
return kwargs
class UserRunnerUpdateView(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
model = Runner
......@@ -848,3 +836,16 @@ class RunnerList(LoginRequiredMixin, ListView):
def get_object(self):
queryset = Runner.objects.filter(account=self.request.user.id).order_by('-created_at')
return queryset
class RunnerCreate(SuccessMessageMixin, LoginRequiredMixin, CreateView):
model = Runner
form_class = RunnerForm
success_message = 'Runner saved successfully.'
success_url = reverse_lazy('main:runner_list')
template_name = 'runner_update_form.html'
def get_form_kwargs(self):
kwargs = super(RunnerCreate, self).get_form_kwargs()
kwargs['request'] = self.request
return kwargs
......@@ -13,7 +13,7 @@
<h5 class="title-page">
<span>Runner list</span>
<a class="btn btn-primary float-right" href="{% url 'main:user_runner_create' %}">New runner</a>
<a class="btn btn-primary float-right" href="{% url 'main:runner_create' %}">New runner</a>
</h5>
{% if runner_list %}
......
......@@ -4,19 +4,13 @@
{% block title %}Update of create a runner{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item"><a href="{% url 'main:user_settings' %}">Settings</a></li>
<li class="breadcrumb-item"><a href="{% url 'main:user_runner_list' %}">Runners</a></li>
<li class="breadcrumb-item active" aria-current="page">Add/Update runner</li>
<li class="breadcrumb-item"><a href="{% url 'main:runner_list' %}">Runners</a></li>
<li class="breadcrumb-item active" aria-current="page">Create</li>
{% endblock %}
{% block content %}
<div class="container">
<div class="allgo-page">
<div class="row">
{% include 'partials/_user_settings_menu.html' %}
<div class="col-10">
<h1 class="page-title">Runner data</h1>
<ul class="nav nav-tabs">
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#configuration">Configuration</a></li>
......@@ -82,12 +76,9 @@
</div>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Update">
<input class="btn btn-primary" type="submit" value="Runner">
</form>
</div>
</div>
</div>
</div>
{% endblock %}
......
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