web: add 'report incident' button at the bottom of the welcome page
authorBrian Warner <warner@lothar.com>
Tue, 5 Aug 2008 19:09:21 +0000 (12:09 -0700)
committerBrian Warner <warner@lothar.com>
Tue, 5 Aug 2008 19:09:21 +0000 (12:09 -0700)
src/allmydata/web/root.py
src/allmydata/web/welcome.xhtml

index a110bc55a693c51f8cdf03986768335233609126..7326a17f9f57bd7421cfc90dc2445d2aed160596 100644 (file)
@@ -12,7 +12,7 @@ from formless import webform
 import allmydata # to display import path
 from allmydata import get_package_versions_string
 from allmydata import provisioning
-from allmydata.util import idlib
+from allmydata.util import idlib, log
 from allmydata.interfaces import IFileNode
 from allmydata.web import filenode, directory, unlinked, status
 from allmydata.web.common import abbreviate_size, IClient, getxmlfile, \
@@ -104,6 +104,15 @@ class FileHandler(rend.Page):
         raise WebError("/file must be followed by a file-cap and a name",
                        http.NOT_FOUND)
 
+class IncidentReporter(RenderMixin, rend.Page):
+    def render_POST(self, ctx):
+        req = IRequest(ctx)
+        log.msg(format="User reports incident through web page: %(details)s",
+                details=get_arg(req, "details", ""),
+                level=log.WEIRD)
+        req.setHeader("content-type", "text/plain")
+        return "Thank you for your report!"
+
 class Root(rend.Page):
 
     addSlash = True
@@ -122,6 +131,8 @@ class Root(rend.Page):
     child_helper_status = status.HelperStatus()
     child_statistics = status.Statistics()
 
+    child_report_incident = IncidentReporter()
+
     def data_version(self, ctx, data):
         return get_package_versions_string()
     def data_import_path(self, ctx, data):
@@ -279,3 +290,15 @@ class Root(rend.Page):
             ]]
         return T.div[form]
 
+    def render_incident_button(self, ctx, data):
+        # this button triggers a foolscap-logging "incident"
+        form = T.form(action="report_incident", method="post",
+                      enctype="multipart/form-data")[
+            T.fieldset[
+            T.legend(class_="freeform-form-label")["Report an Incident"],
+            T.input(type="hidden", name="t", value="report-incident"),
+            "What went wrong?: ",
+            T.input(type="text", name="details"), " ",
+            T.input(type="submit", value="Report!"),
+            ]]
+        return T.div[form]
index 874e0930c8fc120bf9a19d34f5e4dcb0da02ead4..d0acb1976a1da5472cac27140924beef4f2032ac 100644 (file)
 <h2>Other Resources</h2>
 
 <div>Please visit the <a href="http://allmydata.org">Tahoe home page</a> for
-  code updates and bug reporting.</div>
+code updates and bug reporting.</div>
 
-<div>The <a href="provisioning">provisioning
-    tool</a> may also be useful.</div>
+<div>The <a href="provisioning">provisioning tool</a> may also be useful.</div>
 
+<div n:render="incident_button" />
 
   </body>
 </html>