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

badges: templates → models

parent 68b4d90f
...@@ -23,6 +23,7 @@ logger = logging.getLogger('rainboard.models') ...@@ -23,6 +23,7 @@ logger = logging.getLogger('rainboard.models')
MAIN_BRANCHES = ['master', 'devel'] MAIN_BRANCHES = ['master', 'devel']
RPKG_URL = 'http://robotpkg.openrobots.org' RPKG_URL = 'http://robotpkg.openrobots.org'
DOC_URL = 'http://projects.laas.fr/gepetto/doc'
RPKG_LICENSES = {'gnu-lgpl-v3': 'LGPL-3.0', 'gnu-lgpl-v2': 'LGPL-2.0', 'mit': 'MIT', 'gnu-gpl-v3': 'GPL-3.0', RPKG_LICENSES = {'gnu-lgpl-v3': 'LGPL-3.0', 'gnu-lgpl-v2': 'LGPL-2.0', 'mit': 'MIT', 'gnu-gpl-v3': 'GPL-3.0',
'2-clause-bsd': 'BSD-2-Clause', 'eclipse': 'EPL-1.0', 'modified-bsd': 'BSD-3-Clause'} '2-clause-bsd': 'BSD-2-Clause', 'eclipse': 'EPL-1.0', 'modified-bsd': 'BSD-3-Clause'}
RPKG_FIELDS = ['PKGBASE', 'PKGVERSION', 'MASTER_SITES', 'MASTER_REPOSITORY', 'MAINTAINER', 'COMMENT', 'HOMEPAGE'] RPKG_FIELDS = ['PKGBASE', 'PKGVERSION', 'MASTER_SITES', 'MASTER_REPOSITORY', 'MAINTAINER', 'COMMENT', 'HOMEPAGE']
...@@ -320,6 +321,28 @@ class Project(Links, NamedModel, TimeStampedModel): ...@@ -320,6 +321,28 @@ class Project(Links, NamedModel, TimeStampedModel):
def ordered_robotpkg(self): def ordered_robotpkg(self):
return self.robotpkg_set.order_by('name') return self.robotpkg_set.order_by('name')
def url_travis(self):
return f'https://travis-ci.org/{self.main_namespace.slug}/{self.slug}'
def url_gitlab(self):
return f'https://gepgitlab.laas.fr/{self.main_namespace.slug}/{self.slug}'
def badge(self, link, img, alt):
return mark_safe(f'<a href="{link}"><img src="{img}" alt="{alt}" /></a> ')
def badge_travis(self):
return self.badge(self.url_travis(), f'{self.url_travis()}.svg?branch=master', 'Building Status')
def badge_gitlab(self):
return self.badge(self.url_gitlab(), f'{self.url_gitlab()}/badges/master/pipeline.svg', 'Pipeline Status')
def badge_coverage(self):
return self.badge(f'{DOC_URL}/{self.main_namespace.slug}/{self.slug}/master/coverage',
f'{self.url_gitlab()}/badges/master/coverage.svg?job=doc-coverage"', 'Coverage Report')
def badges(self):
return self.badge_travis() + self.badge_gitlab() + self.badge_coverage()
class Repo(TimeStampedModel): class Repo(TimeStampedModel):
name = models.CharField(max_length=200) name = models.CharField(max_length=200)
......
...@@ -19,18 +19,7 @@ ...@@ -19,18 +19,7 @@
{% bootstrap_label 'private' label_class='label label-danger' %} {% bootstrap_label 'private' label_class='label label-danger' %}
{% endif %} {% endif %}
<a href="https://travis-ci.org/{{ project.main_namespace.slug }}/{{ project.slug }}"> {{ project.badges }}
<img src="https://travis-ci.org/{{project.main_namespace.slug }}/{{ project.slug }}.svg?branch=master"
alt="Building Status" />
</a>
<a href="https://gepgitlab.laas.fr/{{ project.main_namespace.slug }}/{{ project.slug }}">
<img src="https://gepgitlab.laas.fr/{{ project.main_namespace.slug }}/{{ project.slug }}/badges/master/pipeline.svg"
alt="Pipeline Status" />
</a>
<a href="http://projects.laas.fr/gepetto/doc/{{ project.main_namespace.slug }}/{{ project.slug }}/master/coverage">
<img src="https://gepgitlab.laas.fr/{{ project.main_namespace.slug }}/{{ project.slug }}/badges/master/coverage.svg?job=doc-coverage"
alt="Coverage Report" />
</a>
</div> </div>
<dl class="row" style="line-height: 1"> <dl class="row" style="line-height: 1">
......
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