Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
dashboard
Commits
f53530a6
Commit
f53530a6
authored
Apr 09, 2018
by
Guilhem Saurel
Browse files
show / update keep_doc
parent
59a034f4
Pipeline
#518
passed with stages
in 54 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
rainboard/tables.py
View file @
f53530a6
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)
...
...
rainboard/views.py
View file @
f53530a6
...
...
@@ -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
)]})
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment