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
cdea649e
Commit
cdea649e
authored
Feb 08, 2018
by
Guilhem Saurel
Browse files
utils.domain{,_link} for tables
parent
8538cd04
Changes
2
Hide whitespace changes
Inline
Side-by-side
rainboard/tables.py
View file @
cdea649e
...
...
@@ -2,7 +2,7 @@ from django.utils.safestring import mark_safe
import
django_tables2
as
tables
from
.
import
models
from
.
import
models
,
utils
class
StrippedTable
(
tables
.
Table
):
...
...
@@ -40,6 +40,9 @@ class ProjectTable(StrippedTable):
def
render_name
(
self
,
record
):
return
record
.
get_link
()
def
render_homepage
(
self
,
value
):
return
utils
.
domain_link
(
value
)
class
RepoTable
(
StrippedTable
):
ahead
=
tables
.
Column
(
accessor
=
'ahead'
,
orderable
=
False
)
...
...
rainboard/utils.py
View file @
cdea649e
...
...
@@ -26,3 +26,16 @@ def api_next(source, req):
if
source
==
SOURCES
.
gitlab
:
if
'X-Next-Page'
in
req
.
headers
and
req
.
headers
[
'X-Next-Page'
]:
return
int
(
req
.
headers
[
'X-Next-Page'
])
def
domain
(
url
):
"""
Extracts the domain of an url
"""
if
'://'
in
url
or
url
.
startswith
(
'//'
):
url
=
url
.
split
(
'//'
)[
1
]
return
url
.
split
(
'/'
)[
0
]
def
domain_link
(
url
):
dn
=
domain
(
url
)
return
mark_safe
(
f
'<a href="
{
url
}
">
{
dn
}
</a>'
)
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