From 741eb444b2d3f4171dd9e1a7074d2dffad01e231 Mon Sep 17 00:00:00 2001
From: bansalnitish
Date: Wed, 28 Feb 2018 20:54:19 +0530
Subject: [PATCH] Requested Changes
---
readthedocs/builds/views.py | 28 ++++++++++++++++++-
.../templates/builds/build_detail.html | 11 ++------
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/readthedocs/builds/views.py b/readthedocs/builds/views.py
index 4be37d268b3..f1de58635e2 100644
--- a/readthedocs/builds/views.py
+++ b/readthedocs/builds/views.py
@@ -11,6 +11,8 @@
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.utils.decorators import method_decorator
+from requests.utils import quote
+from future.backports.urllib.parse import urlparse
from readthedocs.builds.models import Build, Version
from readthedocs.core.utils import trigger_build
@@ -82,11 +84,35 @@ class BuildDetail(BuildBase, DetailView):
def get_context_data(self, **kwargs):
context = super(BuildDetail, self).get_context_data(**kwargs)
context['project'] = self.project
+ scheme = ("https://github.com/rtfd/readthedocs.org/issues/new"
+ "?title={title}{build_id}"
+ "&body={body}")
+
+ body = ("# Details:\n\n"
+ "*Project URL: https://readthedocs.org/projects/{projname}/\n"
+ "*Build URL(if applicable): https://readthedocs.org{build_path}\n"
+ "*Read the Docs username(if applicable): {uname}\n\n"
+ "## Expected Result\n\n"
+ "*A description of what you wanted to happen*\n\n"
+ "## Actual Result\n\n"
+ "*A description of what actually happened*")
+
+ body_dict = {'projname': self.project,
+ 'build_path': self.request.path,
+ 'uname': self.request.user}
+
+ scheme_dict = {'title': quote("Build error with build id #"),
+ 'build_id': self.request.path[-2:-1],
+ 'body': quote(body.format(**body_dict))}
+
+ issue_url = scheme.format(**scheme_dict)
+ issue_url = urlparse(issue_url).geturl()
+ context['issue_url'] = issue_url
return context
-
# Old build view redirects
+
def builds_redirect_list(request, project_slug): # pylint: disable=unused-argument
return HttpResponsePermanentRedirect(reverse('builds_project_list', args=[project_slug]))
diff --git a/readthedocs/templates/builds/build_detail.html b/readthedocs/templates/builds/build_detail.html
index 47c789f2150..db6e29fc1dd 100644
--- a/readthedocs/templates/builds/build_detail.html
+++ b/readthedocs/templates/builds/build_detail.html
@@ -163,15 +163,8 @@ {% trans "Error" %}
{{ build.error }}
- {% blocktrans with build_id=build.pk proj_name=build.project.name build_path=request.get_full_path user_name=request.user %}
- Report any build issues here.
+ {% blocktrans with url=issue_url %}
+ Report any build issues here.
{% endblocktrans %}