Commit bd6ca8ce authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

project/<str:slug>/branches

parent 18666ff2
......@@ -52,3 +52,9 @@ class RepoTable(StrippedTable):
def render_namespace(self, record):
return mark_safe(f'<a href="{record.url}">{record.namespace}</a>')
class BranchTable(StrippedTable):
class Meta:
model = models.Branch
fields = ('name', 'ahead', 'behind', 'updated')
......@@ -59,4 +59,6 @@
{% render_table repos %}
<h2><a href="{% url 'rainboard:branches' slug=project.slug %}">Branches</a></h2>
{% 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>
{% render_table branches %}
{% endblock %}
......@@ -13,4 +13,5 @@ urlpatterns = [
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'),
]
......@@ -45,3 +45,15 @@ class ProjectView(DetailView):
RequestConfig(self.request).configure(repos)
ctx['repos'] = repos
return ctx
class ProjectBranchesView(DetailView):
model = models.Project
template_name = 'rainboard/project_detail_branches.html'
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
branches = tables.BranchTable(self.object.branch_set.all())
RequestConfig(self.request).configure(branches)
ctx['branches'] = branches
return ctx
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