Anton Shestakov <av6@dwimlabs.net>, Sun, 19 Jun 2016 16:22:28 +0800
models: add Project.get_title() method, use it, test it
--- a/candolint/models.py Sun Jun 19 15:52:04 2016 +0800
+++ b/candolint/models.py Sun Jun 19 16:22:28 2016 +0800
user = self.user if self.user is not None else '-'
return '/{}/{}/{}'.format(self.domain, user, self.name)
+ owner = self.user if self.user is not None else self.domain
+ return '{}/{}'.format(owner, self.name)
--- a/templates/check.html Sun Jun 19 15:52:04 2016 +0800
+++ b/templates/check.html Sun Jun 19 16:22:28 2016 +0800
<div class="uk-container uk-container-center uk-margin-large-top">
- <a href="{{ project.get_url() }}">{{ project.name }}</a>:
+ <a href="{{ project.get_url() }}">{{ project.get_title() }}</a>:
check #{{ check.ordinal }}
--- a/templates/index.html Sun Jun 19 15:52:04 2016 +0800
+++ b/templates/index.html Sun Jun 19 16:22:28 2016 +0800
<td class="uk-text-nowrap">{% module Badges(check) %}</td>
<td><a href="{{ check.get_url() }}">#{{ check.ordinal }}</a></td>
- <td><a href="{{ project.get_url() }}">{{ project.name }}</a></td>
+ <td><a href="{{ project.get_url() }}">{{ project.get_title() }}</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 Sun Jun 19 15:52:04 2016 +0800
+++ b/templates/project.html Sun Jun 19 16:22:28 2016 +0800
{% extends "base.html" %}
-{% block title %}{{ project.name }}{% end %}
+{% block title %}{{ project.get_title() }}{% end %}
<div class="uk-container uk-container-center uk-margin-large-top">
- <h2>{{ project.name }}</h2>
+ <h2><a href="{{ project.get_url() }}">{{ project.get_title() }}</a></h2>
<img src="{{ project.get_url() }}/status.svg" alt="Lint Status">
<dl class="uk-description-list-horizontal list-terse">
--- a/tests/test_models.py Sun Jun 19 15:52:04 2016 +0800
+++ b/tests/test_models.py Sun Jun 19 16:22:28 2016 +0800
from datetime import datetime, timedelta
-from candolint.models import Check
+from candolint.models import Project, Check
+ project.domain = 'example.com'
+ project.name = 'hello-world'
+ assert project.get_title() == 'alice/hello-world'
+ project.domain = 'hello-world.com'
+ project.name = 'central'
+ assert project.get_title() == 'hello-world.com/central'