Skip to content
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

E-mail notification of prequel/sequel #4

Open
ethel-t-frog opened this issue Jan 12, 2017 · 8 comments
Open

E-mail notification of prequel/sequel #4

ethel-t-frog opened this issue Jan 12, 2017 · 8 comments
Assignees

Comments

@ethel-t-frog
Copy link
Contributor

System to send notification e-mail when someone adds a prequel or sequel to one of your stories (according to e-mail preferences, of course)

@HSAR
Copy link
Member

HSAR commented Jan 12, 2017

Can you assign this to me? While I'm in the group, I'm not listed as a contributor to the repo; thus I don't have admin rights on issues.

This issue is underway in engineering.

@stitzelj
Copy link
Contributor

stitzelj commented Mar 8, 2017

Per @HSAR's blessing, I worked his modifications for sequel/prequel email notifications into a branch in my own repo and added email notifications for entries into challenges. I'm going to add the necessary logic tomorrow to the profile view so that users can turn off those notifications if they wish, but after that this will be another piece ready to go.

@ethel-t-frog
Copy link
Contributor Author

Sounds great. Really sorry that I've not got round to do much Ficlatté in the last few weeks: I'm trying to organise two camps, paintballing and trips in gliders for the Scout troop, in addition to a major customer delivery at work and taking the kids to and from school.

I will do it, I promise. I beg patience.

@stitzelj
Copy link
Contributor

stitzelj commented Mar 8, 2017

lol, no worries. You've got your hands full. That's the great thing about branches -- I can keep working on stuff while I wait for the Pull Requests to catch up.

@stitzelj
Copy link
Contributor

stitzelj commented Mar 8, 2017

@ethel-t-frog, when you get a free moment, can you walk me through this bit of code and how it interacts with the Profiles and Subscriptions tables?

# E-mail preferences
eflags = 0
flag = 1
for i in range(Profile.NUM_EMAIL_FLAGS):
if 'ef_{}'.format(flag) in request.POST:
eflags = eflags | flag
flag *= 2
profile.email_flags = eflags

I'd built options into the user profile interface to automatically subscribe to prompts and challenges when they create or comment on them and then added similar options to auto-sub to stories when they're prequeled, sequeled, or entered into challenges. But I'm coming to find that the toggles don't behave as expected, and I'm guessing it has something to do with the way you initially built the autosubscribe portions of the Profile model. And I'm afraid I haven't been able to puzzle out the logic completely, so I can't modify it appropriately so it behaves as expected.

@stitzelj
Copy link
Contributor

stitzelj commented Mar 9, 2017

@ethel-t-frog, I actually think I may have figured out it out on my own. I have all the toggles working as expected now and the logic in the Profile model seems to fit my expectations. I'd be curious to hear your explanation, anyway, just to make sure I actually do understand what's happening in that block of code.

@ethel-t-frog
Copy link
Contributor Author

The email_flags field in the Profile table is a bitfield, so you set each bit in the number corresponds to a particular e-mail preference. The code you've cited loops through the labels in the POST structure looking for whether or not the user has ticked the relevant box. If they have, the current value of "flag" is ORred into eflags.

flags starts at 1 and is shifted right (doubled) each time around the loop, so flags is always set to the number that corresponds to the preference code we are currently testing. If the user has ticked that box, we have the value ready to include into eflags; if they have not, we move on.

Does that explanation make any sense?

@stitzelj
Copy link
Contributor

stitzelj commented Mar 9, 2017

Yup, that makes perfect sense and matches what I figured out. I think I must have spent two or three hours yesterday puzzling over that and eventually it just clicked into place. It's actually a pretty clever way of handling the checkbox section. Glad to have verification from you on how it works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants