Skip to content

Commit db71da1

Browse files
authored
Merge pull request #180 from rambo/examples
Improve examples
2 parents 8ce5477 + b8ee9c7 commit db71da1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

project/examples/handlers.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ def on_approved(self, application, member):
4343
msg = "on_approved called for %s" % application
4444
logger.info(msg)
4545
print(msg)
46-
mail = EmailMessage()
47-
mail.to = [member.email, ]
48-
mail.body = """Your membership has been approved, your member id is #%d""" % member.member_id
49-
mail.send()
5046

5147
# Auto-add the membership fee as recurring transaction
5248
membership_fee = env.float('MEMBEREXAMPLE_MEMBERSHIP_FEE', default=None)
@@ -73,6 +69,11 @@ def on_approved(self, application, member):
7369
mail.body = 'subscribe'
7470
mail.send()
7571

72+
mail = EmailMessage()
73+
mail.to = [member.email, ]
74+
mail.body = """Your membership has been approved, your member id is #%d""" % member.member_id
75+
mail.send()
76+
7677

7778
class TransactionHandler(BaseTransactionHandler):
7879

@@ -165,6 +166,10 @@ def import_generic_transaction(self, at, lt):
165166
return lt
166167

167168
def import_tmatch_transaction(self, at, lt):
169+
if len(at.reference) < 2: # To avoid indexerrors
170+
return None
171+
if at.reference[0:2] == "RF": # ISO references, our lookup won't work with them, even worse: there will be exceptions
172+
return None
168173
# In this example the last meaningful number (last number is checksum) of the reference is used to recognize the TransactionTag
169174
try:
170175
lt.tag = TransactionTag.objects.get(tmatch=at.reference[-2])

0 commit comments

Comments
 (0)