Download:
child 27:9fa79edc2e45
parent 25:52cac2f85af5
26:8c1ce7d12350
Anton Shestakov <av6@dwimlabs.net>, Wed, 15 Jun 2016 23:49:22 +0800
viewer: use new get_url() method for project and check links

4 файлов изменено, 18 вставок(+), 16 удалений(-) [+]
candolint/models.py file | annotate | diff | comparison | revisions
templates/check.html file | annotate | diff | comparison | revisions
templates/index.html file | annotate | diff | comparison | revisions
templates/project.html file | annotate | diff | comparison | revisions
--- a/candolint/models.py Wed Jun 15 22:20:45 2016 +0800
+++ b/candolint/models.py Wed Jun 15 23:49:22 2016 +0800
@@ -38,6 +38,14 @@
(('domain', 'user', 'name'), True),
)
+ def get_url(self, request=None):
+ if request is not None:
+ base = '{}://{}'.format(request.protocol, request.host)
+ return base + self.get_url()
+ else:
+ user = self.user if self.user is not None else '-'
+ return '/{}/{}/{}'.format(self.domain, user, self.name)
+
class Change(BaseModel):
rev = pw.IntegerField()
@@ -73,3 +81,6 @@
indexes = (
(('ordinal', 'project'), True),
)
+
+ def get_url(self, request=None):
+ return '{}/{}'.format(self.project.get_url(request), self.ordinal)
--- a/templates/check.html Wed Jun 15 22:20:45 2016 +0800
+++ b/templates/check.html Wed Jun 15 23:49:22 2016 +0800
@@ -4,7 +4,10 @@
{% block content %}
<div class="uk-container uk-container-center uk-margin-large-top">
- <h2>{{ project.name }}: check #{{ check.ordinal }}</h2>
+ <h2>
+ <a href="{{ project.get_url() }}">{{ project.name }}</a>:
+ check #{{ check.ordinal }}
+ </h2>
<p>
{% if check.success %}
{{ locale.translate('{} error', '{} errors', check.errors).format(check.errors) }},
--- a/templates/index.html Wed Jun 15 22:20:45 2016 +0800
+++ b/templates/index.html Wed Jun 15 23:49:22 2016 +0800
@@ -12,16 +12,8 @@
{% set change = check.change %}
<tr>
<td>{% module Badges(check) %}</td>
- <td>
- <a href="/{{ project.domain }}/{{ project.user or '-' }}/{{ project.name }}/{{ check.ordinal }}">
- #{{ check.ordinal }}
- </a>
- </td>
- <td>
- <a href="/{{ project.domain }}/{{ project.user or '-' }}/{{ project.name }}">
- {{ project.name }}
- </a>
- </td>
+ <td><a href="{{ check.get_url() }}">#{{ check.ordinal }}</a></td>
+ <td><a href="{{ project.get_url() }}">{{ project.name }}</a></td>
<td>{{ change.rev }}:{{ change.node[:12] }} {{ change.branch }}</td>
<td>{% module Time(check.started) %}</td>
<td>{% module Time(check.finished) %}</td>
--- a/templates/project.html Wed Jun 15 22:20:45 2016 +0800
+++ b/templates/project.html Wed Jun 15 23:49:22 2016 +0800
@@ -17,11 +17,7 @@
{% set change = check.change %}
<tr>
<td>{% module Badges(check) %}</td>
- <td>
- <a href="/{{ project.domain }}/{{ project.user or '-' }}/{{ project.name }}/{{ check.ordinal }}">
- #{{ check.ordinal }}
- </a>
- </td>
+ <td><a href="{{ check.get_url() }}">#{{ check.ordinal }}</a></td>
<td>{{ change.rev }}:{{ change.node[:12] }} {{ change.branch }}</td>
<td>
<div>{{ change.message }}</div>