mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Issue reporter module has been refactored in MVC
This commit is contained in:
parent
ffeccbb3b6
commit
a513303a9a
@ -31,6 +31,7 @@ import trendingTopics
|
|||||||
import user
|
import user
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from long_tweets import twishort
|
from long_tweets import twishort
|
||||||
|
from issueReporter import issueReporter
|
||||||
|
|
||||||
log = logging.getLogger("mainController")
|
log = logging.getLogger("mainController")
|
||||||
|
|
||||||
@ -159,6 +160,7 @@ class Controller(object):
|
|||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_favs_timeline, self.view.favs)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_favs_timeline, self.view.favs)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_conversation, menuitem=self.view.view_conversation)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_conversation, menuitem=self.view.view_conversation)
|
||||||
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
|
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
|
||||||
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.report_error, self.view.reportError)
|
||||||
|
|
||||||
def set_systray_icon(self):
|
def set_systray_icon(self):
|
||||||
self.systrayIcon = sysTrayIcon.SysTrayIcon()
|
self.systrayIcon = sysTrayIcon.SysTrayIcon()
|
||||||
@ -445,8 +447,9 @@ class Controller(object):
|
|||||||
buff.session.settings.write()
|
buff.session.settings.write()
|
||||||
restart.restart_program()
|
restart.restart_program()
|
||||||
|
|
||||||
def report_error(self):
|
def report_error(self, *args, **kwargs):
|
||||||
pass
|
r = issueReporter.reportBug(self.get_best_buffer().session.db["user_name"])
|
||||||
|
|
||||||
|
|
||||||
def check_for_updates(self, *args, **kwargs):
|
def check_for_updates(self, *args, **kwargs):
|
||||||
update = updater.do_update()
|
update = updater.do_update()
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
############################################################
|
|
||||||
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
############################################################
|
|
||||||
import paths
|
|
||||||
import os
|
|
||||||
|
|
||||||
def get_logs_files():
|
|
||||||
files = {}
|
|
||||||
for i in os.listdir(paths.logs_path()):
|
|
||||||
if i == "debug.log": continue
|
|
||||||
f = open(paths.logs_path(i), "r")
|
|
||||||
files[i] = f.readlines()
|
|
||||||
f.close()
|
|
||||||
try: os.remove(paths.logs_path("tracebacks.log"))
|
|
||||||
except: pass
|
|
||||||
return files
|
|
||||||
|
|
64
src/issueReporter/issueReporter.py
Normal file
64
src/issueReporter/issueReporter.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
############################################################
|
||||||
|
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
import keys
|
||||||
|
import wx
|
||||||
|
import wx_ui
|
||||||
|
import widgetUtils
|
||||||
|
import application
|
||||||
|
from suds.client import Client
|
||||||
|
import constants
|
||||||
|
|
||||||
|
class reportBug(object):
|
||||||
|
def __init__(self, user_name):
|
||||||
|
self.user_name = user_name
|
||||||
|
self.categories = [_(u"General")]
|
||||||
|
self.reproducibilities = [_(u"always"), _(u"sometimes"), _(u"random"), _(u"have not tried"), _(u"unable to duplicate")]
|
||||||
|
self.severities = [_(u"block"), _(u"crash"), _(u"major"), _(u"minor"), _(u"tweak"), _(u"text"), _(u"trivial"), _(u"feature")]
|
||||||
|
self.dialog = wx_ui.reportBugDialog(self.categories, self.reproducibilities, self.severities)
|
||||||
|
widgetUtils.connect_event(self.dialog.ok, widgetUtils.BUTTON_PRESSED, self.send)
|
||||||
|
self.dialog.get_response()
|
||||||
|
|
||||||
|
def send(self, *args, **kwargs):
|
||||||
|
if self.dialog.get("summary") == "" or self.dialog.get("description") == "":
|
||||||
|
self.dialog.no_filled()
|
||||||
|
return
|
||||||
|
if self.dialog.get("agree") == False:
|
||||||
|
self.dialog.no_checkbox()
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
client = Client(application.report_bugs_url)
|
||||||
|
issue = client.factory.create('IssueData')
|
||||||
|
issue.project.name = "TWBlue"
|
||||||
|
issue.project.id = 0
|
||||||
|
issue.summary = self.dialog.get("summary"),
|
||||||
|
issue.description = "Reported by @%s\n\n" % (self.user_name) + self.dialog.get("description")
|
||||||
|
# to do: Create getters for category, severity and reproducibility in wx_UI.
|
||||||
|
issue.category = constants.categories[self.dialog.category.GetSelection()]
|
||||||
|
issue.reproducibility.name = constants.reproducibilities[self.dialog.reproducibility.GetSelection()]
|
||||||
|
issue.severity.name = constants.severities[self.dialog.severity.GetSelection()]
|
||||||
|
issue.priority.name = "normal"
|
||||||
|
issue.view_state.name = "public"
|
||||||
|
issue.resolution.name = "open"
|
||||||
|
issue.projection.name = "none"
|
||||||
|
issue.eta.name = "eta"
|
||||||
|
issue.status.name = "new"
|
||||||
|
id = client.service.mc_issue_add(keys.keyring.get("bts_user"), keys.keyring.get("bts_password"), issue)
|
||||||
|
self.dialog.success(id)
|
||||||
|
except:
|
||||||
|
self.dialog.error()
|
@ -17,26 +17,16 @@
|
|||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
import wx
|
import wx
|
||||||
import application
|
import widgetUtils
|
||||||
from suds.client import Client
|
|
||||||
import constants
|
|
||||||
|
|
||||||
class reportBug(wx.Dialog):
|
class reportBugDialog(widgetUtils.BaseDialog):
|
||||||
def __init__(self, user_name):
|
def __init__(self, categories, reproducibilities, severities):
|
||||||
self.user = "informador"
|
super(reportBugDialog, self).__init__(parent=None, id=wx.NewId())
|
||||||
self.user_name = user_name
|
|
||||||
self.password = "contrasena"
|
|
||||||
self.url = application.report_bugs_url
|
|
||||||
self.categories = [_(u"General")]
|
|
||||||
self.reproducibilities = [_(u"always"), _(u"sometimes"), _(u"random"), _(u"have not tried"), _(u"unable to duplicate")]
|
|
||||||
self.severities = [_(u"block"), _(u"crash"), _(u"major"), _(u"minor"), _(u"tweak"), _(u"text"), _(u"trivial"), _(u"feature")]
|
|
||||||
wx.Dialog.__init__(self, None, -1)
|
|
||||||
self.SetTitle(_(u"Report an error"))
|
self.SetTitle(_(u"Report an error"))
|
||||||
panel = wx.Panel(self)
|
panel = wx.Panel(self)
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
categoryLabel = wx.StaticText(panel, -1, _(u"Select a category"), size=wx.DefaultSize)
|
categoryLabel = wx.StaticText(panel, -1, _(u"Select a category"), size=wx.DefaultSize)
|
||||||
self.category = wx.ComboBox(panel, -1, choices=self.categories, style=wx.CB_READONLY)
|
self.category = wx.ComboBox(panel, -1, choices=categories, style=wx.CB_READONLY)
|
||||||
self.category.SetSize(self.category.GetBestSize())
|
|
||||||
self.category.SetSelection(0)
|
self.category.SetSelection(0)
|
||||||
categoryB = wx.BoxSizer(wx.HORIZONTAL)
|
categoryB = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
categoryB.Add(categoryLabel, 0, wx.ALL, 5)
|
categoryB.Add(categoryLabel, 0, wx.ALL, 5)
|
||||||
@ -48,7 +38,6 @@ class reportBug(wx.Dialog):
|
|||||||
dc = wx.WindowDC(self.summary)
|
dc = wx.WindowDC(self.summary)
|
||||||
dc.SetFont(self.summary.GetFont())
|
dc.SetFont(self.summary.GetFont())
|
||||||
self.summary.SetSize(dc.GetTextExtent("a"*80))
|
self.summary.SetSize(dc.GetTextExtent("a"*80))
|
||||||
# self.summary.SetFocus()
|
|
||||||
summaryB = wx.BoxSizer(wx.HORIZONTAL)
|
summaryB = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
summaryB.Add(summaryLabel, 0, wx.ALL, 5)
|
summaryB.Add(summaryLabel, 0, wx.ALL, 5)
|
||||||
summaryB.Add(self.summary, 0, wx.ALL, 5)
|
summaryB.Add(self.summary, 0, wx.ALL, 5)
|
||||||
@ -64,16 +53,14 @@ class reportBug(wx.Dialog):
|
|||||||
descBox.Add(self.description, 0, wx.ALL, 5)
|
descBox.Add(self.description, 0, wx.ALL, 5)
|
||||||
sizer.Add(descBox, 0, wx.ALL, 5)
|
sizer.Add(descBox, 0, wx.ALL, 5)
|
||||||
reproducibilityLabel = wx.StaticText(panel, -1, _(u"how often does this bug happen?"), size=wx.DefaultSize)
|
reproducibilityLabel = wx.StaticText(panel, -1, _(u"how often does this bug happen?"), size=wx.DefaultSize)
|
||||||
self.reproducibility = wx.ComboBox(panel, -1, choices=self.reproducibilities, style=wx.CB_READONLY)
|
self.reproducibility = wx.ComboBox(panel, -1, choices=reproducibilities, style=wx.CB_READONLY)
|
||||||
self.reproducibility.SetSelection(3)
|
self.reproducibility.SetSelection(3)
|
||||||
self.reproducibility.SetSize(self.reproducibility.GetBestSize())
|
|
||||||
reprB = wx.BoxSizer(wx.HORIZONTAL)
|
reprB = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
reprB.Add(reproducibilityLabel, 0, wx.ALL, 5)
|
reprB.Add(reproducibilityLabel, 0, wx.ALL, 5)
|
||||||
reprB.Add(self.reproducibility, 0, wx.ALL, 5)
|
reprB.Add(self.reproducibility, 0, wx.ALL, 5)
|
||||||
sizer.Add(reprB, 0, wx.ALL, 5)
|
sizer.Add(reprB, 0, wx.ALL, 5)
|
||||||
severityLabel = wx.StaticText(panel, -1, _(u"Select the importance that you think this bug has"))
|
severityLabel = wx.StaticText(panel, -1, _(u"Select the importance that you think this bug has"))
|
||||||
self.severity = wx.ComboBox(panel, -1, choices=self.severities, style=wx.CB_READONLY)
|
self.severity = wx.ComboBox(panel, -1, choices=severities, style=wx.CB_READONLY)
|
||||||
self.severity.SetSize(self.severity.GetBestSize())
|
|
||||||
self.severity.SetSelection(3)
|
self.severity.SetSelection(3)
|
||||||
severityB = wx.BoxSizer(wx.HORIZONTAL)
|
severityB = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
severityB.Add(severityLabel, 0, wx.ALL, 5)
|
severityB.Add(severityLabel, 0, wx.ALL, 5)
|
||||||
@ -82,43 +69,26 @@ class reportBug(wx.Dialog):
|
|||||||
self.agree = wx.CheckBox(panel, -1, _(u"I know that the TW Blue bug system will get my Twitter username to contact me and fix the bug quickly"))
|
self.agree = wx.CheckBox(panel, -1, _(u"I know that the TW Blue bug system will get my Twitter username to contact me and fix the bug quickly"))
|
||||||
self.agree.SetValue(False)
|
self.agree.SetValue(False)
|
||||||
sizer.Add(self.agree, 0, wx.ALL, 5)
|
sizer.Add(self.agree, 0, wx.ALL, 5)
|
||||||
ok = wx.Button(panel, wx.ID_OK, _(u"Send report"))
|
self.ok = wx.Button(panel, wx.ID_OK, _(u"Send report"))
|
||||||
ok.Bind(wx.EVT_BUTTON, self.onSend)
|
self.ok.SetDefault()
|
||||||
ok.SetDefault()
|
|
||||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
||||||
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
btnBox.Add(ok, 0, wx.ALL, 5)
|
btnBox.Add(self.ok, 0, wx.ALL, 5)
|
||||||
btnBox.Add(cancel, 0, wx.ALL, 5)
|
btnBox.Add(cancel, 0, wx.ALL, 5)
|
||||||
sizer.Add(btnBox, 0, wx.ALL, 5)
|
sizer.Add(btnBox, 0, wx.ALL, 5)
|
||||||
panel.SetSizer(sizer)
|
panel.SetSizer(sizer)
|
||||||
self.SetClientSize(sizer.CalcMin())
|
self.SetClientSize(sizer.CalcMin())
|
||||||
|
|
||||||
def onSend(self, ev):
|
def no_filled(self):
|
||||||
if self.summary.GetValue() == "" or self.description.GetValue() == "":
|
wx.MessageDialog(self, _(u"You must fill out both fields"), _(u"Error"), wx.OK|wx.ICON_ERROR).ShowModal()
|
||||||
wx.MessageDialog(self, _(u"You must fill out both fields"), _(u"Error"), wx.OK|wx.ICON_ERROR).ShowModal()
|
|
||||||
return
|
def no_checkbox(self):
|
||||||
if self.agree.GetValue() == False:
|
wx.MessageDialog(self, _(u"You need to mark the checkbox to provide us your twitter username to contact to you if is necessary."), _(u"Error"), wx.ICON_ERROR).ShowModal()
|
||||||
wx.MessageDialog(self, _(u"You need to mark the checkbox to provide us your twitter username to contact to you if is necessary."), _(u"Error"), wx.ICON_ERROR).ShowModal()
|
|
||||||
return
|
def success(self, id):
|
||||||
try:
|
wx.MessageDialog(self, _(u"Thanks for reporting this bug! In future versions, you may be able to find it in the changes list. You've reported the bug number %i") % (id), _(u"reported"), wx.OK).ShowModal()
|
||||||
client = Client(self.url)
|
self.EndModal(wx.ID_OK)
|
||||||
issue = client.factory.create('IssueData')
|
|
||||||
issue.project.name = "TW Blue"
|
def error(self):
|
||||||
issue.project.id = 0
|
wx.MessageDialog(self, _(u"Something unexpected occurred while trying to report the bug. Please, try again later"), _(u"Error while reporting"), wx.ICON_ERROR|wx.OK).ShowModal()
|
||||||
issue.summary = self.summary.GetValue(),
|
self.EndModal(wx.ID_CANCEL)
|
||||||
issue.description = "Reported by @%s\n\n" % (self.user_name) + self.description.GetValue()
|
|
||||||
issue.category = constants.categories[self.category.GetSelection()]
|
|
||||||
issue.reproducibility.name = constants.reproducibilities[self.reproducibility.GetSelection()]
|
|
||||||
issue.severity.name = constants.severities[self.severity.GetSelection()]
|
|
||||||
issue.priority.name = "normal"
|
|
||||||
issue.view_state.name = "public"
|
|
||||||
issue.resolution.name = "open"
|
|
||||||
issue.projection.name = "none"
|
|
||||||
issue.eta.name = "eta"
|
|
||||||
issue.status.name = "new"
|
|
||||||
id = client.service.mc_issue_add(self.user, self.password, issue)
|
|
||||||
wx.MessageDialog(self, _(u"Thanks for reporting this bug! In future versions, you may be able to find it in the changes list. You've reported the bug number %i") % (id), _(u"reported"), wx.OK).ShowModal()
|
|
||||||
self.EndModal(wx.ID_OK)
|
|
||||||
except:
|
|
||||||
wx.MessageDialog(self, _(u"Something unexpected occurred while trying to report the bug. Please, try again later"), _(u"Error while reporting"), wx.ICON_ERROR|wx.OK).ShowModal()
|
|
||||||
self.EndModal(wx.ID_CANCEL)
|
|
@ -74,7 +74,6 @@ class mainFrame(wx.Frame):
|
|||||||
self.changelog.Enable(False)
|
self.changelog.Enable(False)
|
||||||
self.check_for_updates = help.Append(wx.NewId(), _(u"&Check for updates"))
|
self.check_for_updates = help.Append(wx.NewId(), _(u"&Check for updates"))
|
||||||
self.reportError = help.Append(wx.NewId(), _(u"&Report an error"))
|
self.reportError = help.Append(wx.NewId(), _(u"&Report an error"))
|
||||||
self.reportError.Enable(False)
|
|
||||||
self.visit_website = help.Append(-1, _(u"TW Blue &website"))
|
self.visit_website = help.Append(-1, _(u"TW Blue &website"))
|
||||||
self.about = help.Append(-1, _(u"About &TW Blue"))
|
self.about = help.Append(-1, _(u"About &TW Blue"))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user