Commit 5c170f9f authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

refactor project views

parent 0b60d576
......@@ -31,6 +31,13 @@
</dl>
</div>
<ul class="nav nav-tabs">
<li role="presentation" {% if 'robotpkg' in request.path %}class="active"{% endif %}><a href="{% url 'rainboard:project' slug=project.slug %}">Robotpkg</a></h2></li>
<li role="presentation" {% if 'repos' in request.path %}class="active"{% endif %}><a href="{% url 'rainboard:project-repos' slug=project.slug %}">Repos</a></h2></li>
<li role="presentation" {% if 'branches' in request.path %}class="active"{% endif %}><a href="{% url 'rainboard:project-branches' slug=project.slug %}">Branches</a></h2></li>
</ul>
{% block project_detail_content %}
<h2>Robotpkg</h2>
{% for rpkg in project.robotpkg_set.all %}
......@@ -53,12 +60,6 @@
</dl>
{% endfor %}
<h2>Répos</h2>
{% render_table repos %}
<h2><a href="{% url 'rainboard:branches' slug=project.slug %}">Branches</a></h2>
{% endblock %}
{% endblock %}
{% extends 'base.html' %}
{% load django_tables2 bootstrap3 %}
{# TODO DRY project_detail.html #}
{% block content %}
<div class="clearfix">
<h1>{{ project }}</h1>
<div class="pull-right">
{% if project.license %}
{% bootstrap_label project.license label_class='label label-primary' %}
{% else %}
{% bootstrap_label 'UNLICENSED' label_class='label label-warning' %}
{% endif %}
{% if project.private %}
{% bootstrap_label 'private' label_class='label label-danger' %}
{% else %}
{% bootstrap_label 'public' label_class='label label-success' %}
{% endif %}
</div>
<dl class="dl-horizontal">
<dt>Main forge</dt> <dd>{{ project.main_forge.get_link }}</dd>
<dt>Main namespace</dt> <dd>{{ project.main_namespace }}</dd>
<dt>Main branch</dt> <dd>{{ project.main_branch }}</dd>
<dt>Description</dt> <dd>{{ project.description }}</dd>
<dt>Version</dt> <dd>{{ project.version|default:"—" }}</dd>
<dt>Homepage</dt> <dd>{% if project.homepage %}<a href="{{ project.homepage }}">{{ project.homepage }}</a>{% else %}—{% endif %}</dd>
<dt>Updated</dt> <dd>{{ project.updated }}</dd>
</dl>
</div>
<h2>Branches</h2>
{% extends 'rainboard/project_detail.html' %}
{% load django_tables2 %}
{% block project_detail_content %}
{% render_table branches %}
{% endblock %}
{% extends 'rainboard/project_detail.html' %}
{% load django_tables2 %}
{% block project_detail_content %}
{% render_table repos %}
{% endblock %}
......@@ -12,6 +12,7 @@ urlpatterns = [
path('article/create', views.ArticleCreateView.as_view(), name='article-new'),
path('namespaces', views.NamespacesView.as_view(), name='namespaces'),
path('projects', views.ProjectsView.as_view(), name='projects'),
path('project/<str:slug>', views.ProjectView.as_view(), name='project'),
path('project/<str:slug>/branches', views.ProjectBranchesView.as_view(), name='branches'),
path('project/<str:slug>/robotpkg', views.ProjectView.as_view(), name='project'),
path('project/<str:slug>/repos', views.ProjectReposView.as_view(), name='project-repos'),
path('project/<str:slug>/branches', views.ProjectBranchesView.as_view(), name='project-branches'),
]
......@@ -39,6 +39,10 @@ class ProjectsView(SingleTableMixin, FilterView):
class ProjectView(DetailView):
model = models.Project
class ProjectReposView(ProjectView):
template_name = 'rainboard/project_detail_repos.html'
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
repos = tables.RepoTable(self.object.repo_set.all())
......@@ -47,8 +51,7 @@ class ProjectView(DetailView):
return ctx
class ProjectBranchesView(DetailView):
model = models.Project
class ProjectBranchesView(ProjectView):
template_name = 'rainboard/project_detail_branches.html'
def get_context_data(self, **kwargs):
......
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