-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add condition to check user is current coordinator #406
Conversation
Thanks, this looks good! Do you feel confident writing a test for this behaviour? It would go below this one: https://github.com/WikipediaLibrary/TWLight/blob/master/TWLight/emails/tests.py#L165 You could base it on the ones above, piecing together the coordinator and commenting logic for a new test which checks that if a coordinator changes, the original coordinator doesn't receive an email. If you're struggling with this at all just let me know and I can provide some more guidance on how to create the test :) |
Okay, I will give an update soon :) |
Small doubt, I was thinking that if the coordinator is changed then the new coordinator should receive the comment notification mails now # T226369. Am I right? |
I have tried to write a test for this but it is failing currently. Need your insight on this. |
Hi lalit, that's a great question and it actually got us thinking about the desired behaviour here. We're going to chat about it and i'll get back to you after the weekend :) |
Okay cool :) |
Thanks for your patience - you highlighted an issue with this that we hadn't considered! So this is slightly confusing because we don't just have users in the coordinators group approving applications, staff also do so, but they're not linked directly to those publishers as the coordinator. As such, I think we want to replace this:
with
We want to check that the user is either the partner's coordinator, or that they're a staff member. |
The test is failing based on code layout, not because of the tests. You can reformat the code (after making the change above) with |
Hello @Samwalton9 I have gone through # T226369 again and having some more doubts After working on test database it looks like any If that is the case then I don't think we should add the condition like what if the coordinator who made the recent changes was not the one who is assigned to that Partner. (as there is a An alternate to solve the issue can be that we check for
|
That's not the case - So the only people who can evaluate an application are staff members and the coordinator assigned to that partner :) |
That's a great point! That sounds like a sensible way of handling this, nicely done! |
Thanks, I will make the discussed changes soon :) |
will fix this soon. |
Hello @Samwalton9 I have made the changes as we have discussed earlier.
I have tried to write the test for the behaviour. But the test is failing currently. whenever I try to access (1) (2) |
That's strange. Have you looked at |
Yes the first part of test written by me looks like Changes made by me in But it is failing in test written by me ( |
Can you commit your changes? It's hard for me to evaluate without seeing exactly what you've changed :) |
Oh, unless the latest commit is your latest local changes? |
Yes, I have no local changes currently. I have mentioned some of the things which I have noticed in Looks like Revisions are not being created on doing |
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've just spotted that my comment was pending so you hadn't seen it.
TWLight/emails/tests.py
Outdated
|
||
# Now the New Coordinator will receive the Email | ||
self.assertEqual(len(mail.outbox), 2) | ||
self.assertEqual(mail.outbox[1].to, [self.coordinator2.email]) |
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.
Have you checked that the order of emails in the outbox
is correct? Does the second email definitely get placed in the 2nd list position, and not get inserted at the start?
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.
Yes I have checked the order. I think 2nd email will get the 2nd position. Something similar is implemented in test_comment_email_sending_3
.
The problem is not with the order but here even after changing the coordinator both the mails are going to coordinator1
. I have left a comment earlier which may help you finding the reason behind this behaviour.
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.
Note, this feedback is just from a read through of the pr, I haven't fiddled with this locally yet.
@lalit97 the application revisions are constructed in a hinky way that differs from just about everything else, including the comments. The user for a revision represents a request user, so if you want that value set in your test revision, you need to post to the application with a client request, like in test_comment_email_sending_4
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.
if that doesn't clear things up for you, just let me know and I'll do a real review with more detailed feedback/advice.
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.
the application revisions are constructed in a hinky way that differs from just about everything else, including the comments. The user for a revision represents a request user, so if you want that value set in your test revision, you need to post to the application with a client request, like in
test_comment_email_sending_4
The test is passing somehow but I am stuck on couple of points. Need some help to fix these
(1) As you have suggested I have made a post
request after changing the coordinator
(somewhat like test_comment_email_sending_4
). But if I remove the post
request the test fails again. So I was thinking that ideally it should work only after doing partner.save()
and must not require an additional post
request to create revisions.
(2) I tried to print mail.outbox[2].to
and it is still showing that another mail is sent to the previous coordinator also. Which is occurring due to tasks.py#L288 I think. So due to this the issue mentioned at T226369 is still not resolved.
I rebased this so I can check it against our current code base and review. |
We should do a check before sending a comment notification email that the coordinator we're about to email is also the current coordinator of the partner. Bug: T226369
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.
LGTM! Thank you for your contribution!
thank you :) I think you missed my last comment #discussion_r464268579 |
@lalit97 Sorry I missed that comment. Can you pick up this task with a new PR? I can help you with any questions you have on this. |
We should do a check before sending a comment notification email that the coordinator we're about to email is also the current coordinator of the partner.
Bug: T226369