recipedetail: don't show homepage as link if not URL

Sometimes people put values that aren't URLs into the HOMEPAGE variable.
If that's the case, then we should not turn that value into a link which
will be invalid.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2016-10-25 20:58:31 +13:00
parent d5b0d578a6
commit 7ddf8f58d6
2 changed files with 13 additions and 1 deletions

View File

@ -292,6 +292,12 @@ class Recipe(models.Model):
else:
return self.filename.split('_')[0]
def homepage_url_only(self):
if '://' in self.homepage:
return self.homepage
else:
return None
def __str__(self):
return os.path.join(self.filepath, self.filename)

View File

@ -72,7 +72,13 @@
</tr>
<tr>
<th>Homepage</th>
<td>{% if recipe.homepage %}<a href="{{ recipe.homepage }}">{{ recipe.homepage }}</a>{% endif %}</td>
<td>
{% if recipe.homepage_url_only %}
<a href="{{ recipe.homepage }}">{{ recipe.homepage }}</a>
{% elif recipe.homepage %}
{{ recipe.homepage }}
{% endif %}
</td>
</tr>
{% if recipe.bugtracker %}
<tr>