-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subscription: adds listener methods to create a subscription if needed #868
subscription: adds listener methods to create a subscription if needed #868
Conversation
6947836
to
bc5f6a8
Compare
bc5f6a8
to
6abf0b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest something like this:
def get_transactions_pids_for_patron(cls, patron_pid, status=None, count=False):
query = PatronTransactionsSearch()\
.filter("term", patron__pid=patron_pid)
if status:
query = query.filter("term", status=status)
if count:
return query.source("pid").count()
results = query.source("pid").scan()
for result in results:
yield result.pid
so you can replace get_number_of_open_transactions
by
get_transactions_pids_for_patron(self.pid, status="open", count=True)
This will address also the comment of Peter regarding the list and keep the nice function you have created to return the open
transactions for a patron
EDIT: (Renaud Michotte)
After testing, we can"t use yield and return in the same function. If Python found usage of yield in a function it always return a generator despite if yield is not reached.
I will create two separate functions
6abf0b5
to
56c7438
Compare
56c7438
to
85c0151
Compare
85c0151
to
aa4acf8
Compare
aa4acf8
to
d40a6cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are some typos, you can fix if you resend the commit. otherwise, it is acceptable.
tow_years_later -> two_years_later
linke -> link
d40a6cb
to
674288d
Compare
674288d
to
b9a1542
Compare
cff453e
to
fa99d3e
Compare
When a patron is create/updated, if the patron is linked to a patron type requiring a subscription, we need to create a subscription transaction if the patron doesn"t have any current one. This is the purpose of this PR. * Adds a listener method for patron signals : after_record_create, after_record_update * Adds unit tests Co-Authored-by: Renaud Michotte <[email protected]>
fa99d3e
to
26d3030
Compare
When a patron is create/updated, if the patron is linked to a patron type requiring a subscription,
we need to create a subscription transaction if the patron doesn"t have any current one.
This is the purpose of this PR.
How to test?
Edit a patron_type to have one with a yearly subscription
Create a new patron and assign it with this patron_type
Check the patron fee tabs, you should see a new subscription fee
Update this patron to assign it to a patron_type without subscription
Update again this patron to re-assign it the patron_type with a subscription
No new fee should be assign to the patron
Search for a patron previously linked to the patron_type with subscription
Edit this patron
Check this patron has now a subscription fee.
Code review check list