40d6891c had created a false illusion of working, which can
certainly be blamed on the patch author. That said, instead
of trying to work around what the standard Django filters
provide, it is more prudent to create a "URL checking"
function for the feature matrix descriptions. This can be
used both for the "featurelink" generation, as well as the
new check we make to get the stated goal of
40d6891c, i.e.
provide a clickable URL when that is the only content of a
feature description.
# Get a list of column based on all versions that are visible_default
return [choices_map[getattr(self, a)] for a, b in versions]
+ def featuredescription_is_url(self):
+ """
+ Returns true if the entirety of the feautre description is a URL, or
+ at least gives off the appearance that it is.
+ """
+ return self.featuredescription.startswith('https://') or self.featuredescription.startswith('http://')
+
@property
def featurelink(self):
- if self.featuredescription.startswith('https://') or self.featuredescription.startswith('http://'):
+ if self.featuredescription_is_url():
return self.featuredescription
else:
return 'detail/%s/' % self.id
<h1>Feature Description</h1>
<h2>{{feature.featurename}}</h2>
<p>
-{% if feature.featurelink|truncatechars:4 == "http" %}
+{% if feature.featuredescription_is_url %}
For more information, please visit : <a href="{{ feature.featurelink }}">{{ feature.featurelink }}</a>
{% else %}
{{ feature.featuredescription|markdown:"safe" }}