Commit ddf2cf17 authored by sebastien letort's avatar sebastien letort
Browse files

list all versions available for an app.

The app owner will be able to update published status, not yet implemented.
parent d2d6176a
......@@ -54,6 +54,7 @@ urlpatterns = [
url(r'^apps/_create/$', views.WebappCreate.as_view(), name='webapp_creation'),
url(r'^apps/_import/$', views.WebappImport.as_view(), name='webapp_import'),
url(r'^apps/(?P<docker_name>[\w-]+)/import$', views.WebappVersionImport.as_view(), name="webapp_version_import"),
url(r'^apps/(?P<docker_name>[\w-]+)/versions$', views.WebappVersionList.as_view(), name="webapp_version_list"),
url(r'^apps/(?P<docker_name>[\w-]+)/update$', views.WebappUpdate.as_view(), name="webapp_update"),
url(r'^apps/(?P<docker_name>[\w-]+)/sandbox$', views.WebappSandboxPanel.as_view(), name="webapp_sandbox_panel"),
url(r'^apps/(?P<docker_name>[\w-]+)/json$', views.WebappJson.as_view(), name='webapp_json'),
......
......@@ -567,6 +567,39 @@ class WebappVersionImport(UserAccessMixin, DetailView):
return HttpResponseRedirect(request.path_info)
class WebappVersionList(UserAccessMixin, ListView):
"""Display the list of versions for a given app and identified user
Attributes:
model: model used in the view.
# ~ context_object_name: the name used in the template to display each
# ~ variable.
# ~ paginate_by: the number of occurences per page
template_name: name of the template loaded with this view.
"""
model = WebappVersion
context_object_name = 'version_list'
template_name = 'webapp_version_list.html'
# ~ paginate_by = 10
def get_queryset(self):
"""get all versions of this webapp"""
name = self.kwargs['docker_name']
queryset = WebappVersion.objects \
.filter(webapp__docker_name=name) \
.exclude(state__in=(WebappVersion.ERROR, WebappVersion.REPLACED))
return queryset
def get_context_data(self, **kwargs):
"""Pass on the docker name to the template"""
webapp = Webapp.objects.get(docker_name=self.kwargs['docker_name'])
kwargs['webapp'] = webapp
return super().get_context_data(**kwargs)
class WebappJson(UserAccessMixin, DetailView):
"""json variant of the application details
......
......@@ -55,6 +55,16 @@
</a>
{% endif %}
{% endif %}
<a class="fa-layers fa-2x"
href="{% url 'main:webapp_version_list' webapp.docker_name %}"
data-toggle="tooltip"
data-placement="top"
title="List versions">
<i class="fas fa-square"></i>
<i class="fa-inverse fas fa-tasks" data-fa-transform="shrink-7 down-.25 left-.25"></i>
<span class="text-hide">List versions</span>
</a>
</div>
</div>
......
{% extends "base.html" %}
{% load static converters humanize %}
{% block title %}{{ webapp.name | fancy_webapp_name | title }} versions{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item"><a href="{% url 'main:webapp_list' %}">Applications</a></li>
<li class="breadcrumb-item active" aria-current="page">
<a href="{% url 'main:webapp_detail' webapp.name %}">{{ webapp.name | fancy_webapp_name | title }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">versions</li>
{% endblock %}
{% block content %}
<div class="container">
<div class="allgo-page">
<h5>Versions available for the app.</h5>
{% if version_list %}
<form action="{% url 'main:webapp_version_list' webapp.name %}" method="post">
{% csrf_token %}
<table class="table table-striped">
<thead>
<tr>
<th scope="col">name</th>
<th scope="col">description</th>
{% if webapp.user == user %}
<th scope="col">published</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for version in version_list %}
<tr id="version-{{version.id}}">
<td>{{ version.number }}</td>
<td>{{ version.description }}</td>
{% if webapp.user == user %}
<td>
{% if version.published %}
<input type="radio" name="{{version.id}}" id="{{version.id}}_yes" value="True" checked>
<label for="{{version.id}}_yes">yes</label>
<input type="radio" name="{{version.id}}" id="{{version.id}}_no" value="False" >
<label for="{{version.id}}_no">no</label>
{% else %}
<input type="radio" name="{{version.id}}" id="{{version.id}}_yes" value="True" >
<label for="{{version.id}}_yes">yes</label>
<input type="radio" name="{{version.id}}" id="{{version.id}}_no" value="False" checked>
<label for="{{version.id}}_no">no</label>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<input type="submit" value="Update all">
</form>
{% else %}
<p>No version available.
{% if webapp.user == user %}
create a
<a href="{% url 'main:webapp_sandbox_panel' webapp.docker_name %}"
title="Create a new version">
new version.
</a>.
{% endif %}
</p>
{% endif %}
</div>
</div>
{% endblock %}
Markdown is supported
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