Skip to content

Commit

Permalink
Made support-email configurable, fixes #100
Browse files Browse the repository at this point in the history
 - needs testing,
 - is vulnerable to #63
  • Loading branch information
sedrubal committed Nov 22, 2015
1 parent 4a4d884 commit 7c528af
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
13 changes: 10 additions & 3 deletions FabLabKasse/UI/PayupCashDialogCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@

class PayupCashDialog(QtGui.QDialog, Ui_PayupCashDialog):

def __init__(self, parent, amount_total):
"""payment method dialog for automatic cash payin and payout"""
def __init__(self, parent, amount_total, cfg):
"""
payment method dialog for automatic cash payin and payout
:param cfg: config from ScriptHelper.getConfig()
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# maximize window - WORKAROUND because showMaximized() doesn't work
Expand All @@ -51,6 +54,7 @@ def __init__(self, parent, amount_total):
self.centsReceived = None
self.centsPaidOut = None
self.returnDonated = False
self.cfg = cfg
# The finish button doesn't print a receipt, only the "print receipt and finish" one.
# Sometimes the later logic still forces receipt printing (e.g. payment aborted, not everything paid back)
self.receipt_wanted = False
Expand Down Expand Up @@ -279,7 +283,10 @@ def update(self):
text = text + u" <p>Ein Rest von {} konnte leider nicht zurückgezahlt werden.</p>".format(PayupCashDialog.formatCent(self.centsToPayOut - self.centsPaidOut))
if self.centsToPay > 0: # payment not aborted
text += u"<p>Bitte das Aufräumen nicht vergessen!</p>"
text = text + u'<p style="font-size:14px"> Sollte etwas nicht stimmen, benachrichtige bitte sofort einen Betreuer und melde dich bei [email protected].</p></html>'
email = self.cfg.get('general', 'support_mail')
text += u'<p style="font-size:14px"> Sollte etwas nicht stimmen, ' + \
u'benachrichtige bitte sofort einen Betreuer und melde dich ' + \
u'bei {}.</p></html>'.format(email)
self.label_status.setText(text)
self.pushButton_finish.setVisible(True)
# only ask for receipt if something was paid
Expand Down
3 changes: 3 additions & 0 deletions FabLabKasse/config.ini.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[general]
; support mail will be displayed when error occur
support_mail = [email protected]

; Path to sqlite3 file
db_file = development.sqlite3

Expand Down
7 changes: 4 additions & 3 deletions FabLabKasse/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,10 @@ def askUser():
# TOOD show amount returned on receipt (needs some rework, because it is not yet stored in the order and so we cannot re-print receipts)
self.shoppingBackend.print_receipt(paymentmethod.receipt_order_id)
except PrinterError, e:
QtGui.QMessageBox.warning(self, "Quittung", "Drucker scheint offline zu sein." +
"\nFalls du wirklich eine Quittung brauchst, melde dich bei " +
"[email protected] mit Datum, Uhrzeit und Betrag.")
email = cfg.get('general', 'support_mail')
QtGui.QMessageBox.warning(self, "Quittung", u"Drucker scheint offline zu sein.\n"
u"Falls du wirklich eine Quittung brauchst, melde dich bei "
u"{} mit Datum, Uhrzeit und Betrag.".format(email))
logging.warning("printing receipt failed: {}".format(repr(e)))
if paymentmethod.successful:
paymentmethod.show_thankyou()
Expand Down
8 changes: 5 additions & 3 deletions FabLabKasse/scriptHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ def myNewExceptionHook(exctype, value, tb):
import datetime
# logging.exception()
try:
cfg = getConfig()
email = cfg.get('general', 'support_mail')
msgbox = QtGui.QMessageBox()
txt = u"Entschuldigung, das Programm wird wegen eines Fehlers beendet."
infotxt = u"Wenn dir Rückgeld entgangen ist, melde dich bei [email protected] und gebe " + \
u"neben einer Fehlerbeschreibung folgende Uhrzeit an: "
infotxt += u"\n{}.".format(str(datetime.datetime.today()))
infotxt = u"Wenn dir Rückgeld entgangen ist, melde dich bei {} und gebe " + \
u"neben einer Fehlerbeschreibung folgende Uhrzeit an: \n" + \
u"{}.".format(email, str(datetime.datetime.today()))
detailtxt = u"{}\n{}".format(str(datetime.datetime.today()), "".join(
traceback.format_exception(exctype, value, tb, limit=10)))
logging.fatal(txt)
Expand Down
23 changes: 12 additions & 11 deletions FabLabKasse/shopping/backend/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def format_money(amount):

class Category(object):
"""represents a category of Products"""

def __init__(self, categ_id, name, parent_id=None):
self.categ_id = categ_id
self.name = name
Expand All @@ -131,11 +131,11 @@ def __repr__(self):
class Product(object):

"""simple representation for a product
:param prod_id: numeric unique product ID
:type prod_id: int
:param categ_id: category ID of product, or None if the product is not directly visible
TODO hide these products from search, or a more explicit solution
:type categ_id: int | None
:param name: Name of product
Expand All @@ -158,7 +158,7 @@ class Product(object):
"""

def __init__(self, prod_id, name, price, unit, location, categ_id=None, qty_rounding=0, text_entry_required=False):

self.prod_id = prod_id
self.name = name
assert isinstance(price, (Decimal, int))
Expand Down Expand Up @@ -190,11 +190,11 @@ class OrderLine(object):
:param Decimal price_subtotal: price for ``qty`` * ``unit`` of this product
:param boolean delete_if_zero_qty: if the qty is zero and the user starts adding something else, then remove this line
[ usually True, set to False for products that also may as comment limes costing nothing ]
"""

def __init__(self, order_line_id, qty, unit, name, price_per_unit, price_subtotal, delete_if_zero_qty=True):

self.order_line_id = order_line_id
Expand Down Expand Up @@ -241,7 +241,7 @@ class AbstractShoppingBackend(object):
__metaclass__ = ABCMeta

def __init__(self, cfg):
"""cfg: config from ScriptHelper.getConfig()"""
""":param cfg: config from ScriptHelper.getConfig()"""
self.cfg = cfg

def format_money(self, amount):
Expand Down Expand Up @@ -447,12 +447,13 @@ def pay_order_on_client(self, client):
new_debt = debt + self.get_current_total()
debt_limit = client.get_debt_limit()
if new_debt > debt_limit:
email = self.cfg.get('general', 'support_mail')
raise DebtLimitExceeded(
u"Der Kontostand wäre mit dieser Buchung über seinem Limit.\n" +
u"Der Kontostand wäre mit dieser Buchung über seinem Limit.\n"
u"Aktuelles Guthaben: {:.2f}\n"
u"Schuldengrenze für dieses Konto: {:.2f}\n\n"
u"Bie Fragen bitte an [email protected] wenden."
.format(-debt, debt_limit))
u"Bie Fragen bitte an {} wenden."
.format(-debt, debt_limit, email))

self._pay_order_on_client_unchecked(client)

Expand Down

0 comments on commit 7c528af

Please sign in to comment.