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

show / update keep_doc

parent 59a034f4
Pipeline #518 passed with stages
in 54 seconds
from django.utils.safestring import mark_safe
from django.urls import reverse
import django_tables2 as tables
......@@ -62,7 +63,7 @@ class BranchTable(StrippedTable):
class Meta:
model = models.Branch
fields = ('forge', 'namespace', 'name', 'ahead', 'behind', 'updated')
fields = ('forge', 'namespace', 'name', 'ahead', 'behind', 'updated', 'keep_doc')
def render_name(self, record, value):
if record.repo is None:
......@@ -78,6 +79,11 @@ class BranchTable(StrippedTable):
if value:
return mark_safe(f'<a href="{record.repo.url}">{value}</a>')
def render_keep_doc(self, record, value):
url = reverse('admin:rainboard_branch_change', args=[record.id])
status = {True: '✓', False: '✗'}[value]
return mark_safe(f'<a href="{url}">{status}</a>')
# TODO: this works, but we have to hide the pinned from the main dataset
# def get_top_pinned_data(self):
# return self.data.data.filter(name__in=models.MAIN_BRANCHES)
......
......@@ -90,5 +90,5 @@ def json_doc(request):
"""
Get the list of project / namespace / branch of which we want to keep the doc
"""
return JsonResponse({'ret': [(b.project.slug, b.repo.namespace.slug, b.name.split('/', maxsplit=2)[2]) for b in
models.Branch.objects.filter(keep_doc=True)]})
return JsonResponse({'ret': [(b.project.slug, b.repo.namespace.slug, b.name.split('/', maxsplit=2)[2])
for b in models.Branch.objects.filter(keep_doc=True)]})
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