Commit 4d08fb8f authored by Claude Paroz's avatar Claude Paroz

Add links to search for and report bugs when POT files have errors (fixes #458314)

Thanks to Adorilson Bezerra for the initial patch.
parent 0857a4a7
......@@ -95,19 +95,24 @@ class Module(models.Model):
""" This function checks if the module is hosted in the standard VCS of the project """
return re.search(settings.VCS_HOME_REGEX, self.vcs_root) is not None
def get_bugs_i18n_url(self):
def get_bugs_i18n_url(self, content=None):
if self.bugs_base.find("bugzilla") != -1 or self.bugs_base.find("freedesktop") != -1:
return utils.url_join(self.bugs_base,
"buglist.cgi?product=%s&keywords_type=anywords&keywords=I18N+L10N&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=NEEDINFO" % (self.bugs_product,))
link = utils.url_join(
self.bugs_base,
"buglist.cgi?product=%s&keywords_type=anywords&keywords=I18N+L10N"
"&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=NEEDINFO" % (self.bugs_product,))
if content:
link += "&content=%s" % content
return link
else:
return None
def get_bugs_enter_url(self):
if self.bugs_base.find("bugzilla") != -1 or self.bugs_base.find("freedesktop") != -1:
link = utils.url_join(self.bugs_base, "enter_bug.cgi?product=%s&keywords=I18N+L10N" % (self.bugs_product,))
if self.bugs_component:
return utils.url_join(self.bugs_base, "enter_bug.cgi?product=%s&component=%s" % (self.bugs_product, self.bugs_component))
else:
return utils.url_join(self.bugs_base, "enter_bug.cgi?product=%s" % (self.bugs_product,))
link += "&component=%s" % self.bugs_component
return link
else:
return self.bugs_base
......@@ -1562,6 +1567,14 @@ class Information(models.Model):
text = text.replace('%s',match,1)
return text
def report_bug_url(self):
link = self.statistics.branch.module.get_bugs_enter_url()
link += "&short_desc=%(short)s&content=%(short)s&comment=%(long)s" % {
'short': "Error regenerating POT file",
'long' : utils.stripHTML(self.get_description()),
}
return link
class InformationArchived(models.Model):
statistics = models.ForeignKey('StatisticsArchived')
# Priority of a stats message
......
......@@ -26,3 +26,7 @@ def escapeat(value):
@register.filter
def domain_type(stat):
return stat.domain.get_type(stat.branch)
@register.filter
def browse_bugs(module, content):
return module.get_bugs_i18n_url(content)
......@@ -21,6 +21,20 @@
<tr>
<td valign="top"><img src="{{ msg.get_icon }}" alt="{{ msg.type }}" /></td>
<td>{{ msg.get_description|safe }}</td>
{% if user.is_authenticated %}
{% if msg.type == 'error' or msg.type == 'error-ext' %}
<td>
<a href='{{ module|browse_bugs:"error+pot+file" }}' target='_blank'>
<img src="{{ MEDIA_URL }}img/search.png" alt="{% trans "Search for similar bugs before reporting it" %}" title="{% trans "Search for similar bugs before reporting it" %}"/>
</a>
</td>
<td>
<a href='{{ msg.report_bug_url }}' target='_blank'>
<img src="{{ MEDIA_URL }}img/bug.png" alt="{% trans "Report this bug" %}" title="{% trans "Report this bug" %}"/>
</a>
</td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
</table>
......
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