Add problem report for CORE phone numbers too long
This commit is contained in:
parent
2af89f2cbf
commit
66d1cdd0a9
|
@ -62,6 +62,24 @@ class corepos_problems_invalid_person_numbers(ProblemReportEmail):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class corepos_problems_phone_numbers_too_long(ProblemReportEmail):
|
||||||
|
"""
|
||||||
|
Looks for `meminfo` records with phone number which is too long to
|
||||||
|
properly fit in the `Customers` table.
|
||||||
|
"""
|
||||||
|
default_subject = "Phone numbers too long"
|
||||||
|
abstract = False
|
||||||
|
|
||||||
|
def sample_data(self, request):
|
||||||
|
from corepos.db.office_op import model as corepos
|
||||||
|
|
||||||
|
member = corepos.MemberInfo(card_number=42,
|
||||||
|
phone='(800) 555-1234 ABCDEFGHIJKLMNOP')
|
||||||
|
return {
|
||||||
|
'problems': [member]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class rattail_export_corepos_updates(ImporterEmail):
|
class rattail_export_corepos_updates(ImporterEmail):
|
||||||
"""
|
"""
|
||||||
Sent when a Rattail -> CORE-POS API export involves data changes.
|
Sent when a Rattail -> CORE-POS API export involves data changes.
|
||||||
|
|
|
@ -56,3 +56,32 @@ class InvalidPersonNumbers(ProblemReport):
|
||||||
|
|
||||||
core_session.close()
|
core_session.close()
|
||||||
return problems
|
return problems
|
||||||
|
|
||||||
|
|
||||||
|
class PhoneNumbersTooLong(ProblemReport):
|
||||||
|
"""
|
||||||
|
Looks for ``meminfo`` records in CORE which have a phone number
|
||||||
|
value which is too long to fit into the corresponding
|
||||||
|
``Customers`` table column in CORE.
|
||||||
|
"""
|
||||||
|
system_key = 'corepos'
|
||||||
|
problem_key = 'phone_numbers_too_long'
|
||||||
|
problem_title = "Phone numbers too long"
|
||||||
|
|
||||||
|
def find_problems(self, **kwargs):
|
||||||
|
problems = []
|
||||||
|
core_session = CoreSession()
|
||||||
|
|
||||||
|
maxlen = self.app.maxlen(corepos.Customer.phone)
|
||||||
|
core_members = core_session.query(corepos.MemberInfo)\
|
||||||
|
.order_by(corepos.MemberInfo.card_number)\
|
||||||
|
.all()
|
||||||
|
|
||||||
|
def inspect(member, i):
|
||||||
|
if member.phone and len(member.phone) > maxlen:
|
||||||
|
problems.append(member)
|
||||||
|
|
||||||
|
self.progress_loop(inspect, core_members,
|
||||||
|
message="Looking for phone numbers too long")
|
||||||
|
core_session.close()
|
||||||
|
return problems
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/base_problems.html.mako" />
|
||||||
|
|
||||||
|
<%def name="summary()">
|
||||||
|
<p>
|
||||||
|
There are ${len(problems)} member records which have a phone
|
||||||
|
number that is too long to properly fit in the `Customers`
|
||||||
|
table. Please investigate and fix at your convenience.
|
||||||
|
</p>
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
<%def name="simple_row(member, i)">
|
||||||
|
<tr>
|
||||||
|
<td>${member.card_number}</td>
|
||||||
|
<td>${member.phone}</td>
|
||||||
|
</tr>
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
${self.simple_table(["Card #", "Phone Number"])}
|
Loading…
Reference in a new issue