|
15 | 15 | # '%(inacive_email)s' is 18, so just formatting naturally should come out |
16 | 16 | # pretty nicely in most cases. |
17 | 17 |
|
| 18 | + |
18 | 19 | email_template = """ |
19 | 20 | Hi, |
20 | 21 |
|
|
23 | 24 | in the active draft %(draft_name)s, was set to inactive. |
24 | 25 |
|
25 | 26 | As a consequence of this, it would not be receiving notifications related to |
26 | | -that draft. The notifications would instead have gone to <%(primary_email)s>. |
| 27 | +that draft, from the datatracker or through the draft aliases. The |
| 28 | +notifications and aliases would instead have used <%(primary_email)s>. |
27 | 29 |
|
28 | 30 | This most likely was not what you intended when you used <%(inactive_email)s> |
29 | | -in the draft, so that address has now been set to active. However, if you |
30 | | -have manually set the status for <%(inactive_email)s> to inactive, we |
31 | | -apologize for interfering and now having to ask you to go and set it to |
32 | | -inactive again, at https://datatracker.ietf.org/accounts/profile/ . |
| 31 | +in the draft, so that address has now been set to active. The datatracker and |
| 32 | +draft aliases will now use it. |
| 33 | +
|
| 34 | +If you have a datatracker account, and had manually set the status for |
| 35 | +<%(inactive_email)s> to inactive, we apologize for interfering. Please set it |
| 36 | +to inactive again, by using https://datatracker.ietf.org/accounts/profile/. We |
| 37 | +don't anticipate changing it automatically again. |
| 38 | +
|
| 39 | +If you don't have a datatracker account, then all should be good -- we've |
| 40 | +simply set things to be the way they were expected to be. |
| 41 | +
|
33 | 42 |
|
34 | 43 | Best regards, |
35 | 44 |
|
|
39 | 48 |
|
40 | 49 | def activate_draft_email(apps, schema_editor): |
41 | 50 | Document = apps.get_model("doc", "Document") |
42 | | - print("Setting email addresses to active ...") |
43 | | - count = 0 |
44 | | - for doc in Document.objects.filter(type__slug='draft', states__slug='active'): |
| 51 | + print("\nSetting email addresses to active ...") |
| 52 | + change_count = 0 |
| 53 | + notify_user_count = 0 |
| 54 | + for doc in Document.objects.filter(type__slug='draft', states__slug='active').order_by('-time'): |
45 | 55 | for email in doc.authors.all(): |
46 | 56 | if email.active == False: |
47 | | - primary = email.person.email_set.filter(active=True).order_by('-time').first() |
| 57 | + person = email.person |
| 58 | + primary = person.email_set.filter(active=True).order_by('-time').first() |
48 | 59 | email.active = True |
49 | 60 | email.save() |
50 | | - count += 1 |
| 61 | + change_count += 1 |
51 | 62 | # If there isn't a primary address, ther's no active |
52 | 63 | # addresses, and it can't be other than right to change the |
53 | 64 | # draft email address to active. Otherwise, notify the owner. |
54 | | - if primary and settings.SERVER_MODE == 'production': |
| 65 | + if primary: |
| 66 | + notify_user_count +=1 |
55 | 67 | primary_email = primary.address |
56 | 68 | inactive_email = email.address |
57 | | - context = dict( |
58 | | - primary_email=primary_email, |
59 | | - inactive_email=inactive_email, |
60 | | - draft_name=doc.name, |
| 69 | + if settings.SERVER_MODE == 'production': |
| 70 | + context = dict( |
| 71 | + primary_email=primary_email, |
| 72 | + inactive_email=inactive_email, |
| 73 | + draft_name=doc.name, |
| 74 | + ) |
| 75 | + send_mail_text( |
| 76 | + request=None, |
| 77 | + to=[ primary_email, inactive_email ], |
| 78 | + frm="Henrik Levkowetz <henrik@levkowetz.com>", |
| 79 | + subject="Changed email settings for you in the datatracker", |
| 80 | + txt= email_template % context, |
| 81 | + extra={"Reply-To": "Secretariat <ietf-action@ietf.org>"}, |
61 | 82 | ) |
62 | | - send_mail_text( |
63 | | - request=None, |
64 | | - to=[ primary_email, inactive_email ], |
65 | | - frm="Henrik Levkowetz <henrik@levkowetz.com>", |
66 | | - subject="Changed email settings for you in the datatracker", |
67 | | - txt= email_template % context, |
68 | | - extra={"Reply-To": "Secretariat <ietf-action@ietf.org>"}, |
69 | | - ) |
70 | | - print("Set %s email addresses to active" % count) |
| 83 | + print("Set %s email addresses to active" % change_count) |
| 84 | + print("Notified %s users, who had at least one other active email." % notify_user_count) |
71 | 85 |
|
72 | 86 | def deactivate_draft_email(apps, scema_editor): |
73 | 87 | """ |
74 | 88 | The backwards migration doesn't touch the active field of any email addresses. |
75 | 89 | We don't have the information to exactly undo what the forward migration did, |
76 | | - and on 08 Mar 2015, there were 1931 inactive email addresses coupled to active |
| 90 | + and on 08 Mar 2015, there were 1178 inactive email addresses coupled to active |
77 | 91 | drafts, and 4237 active addresses coupled to active drafts. The harm would |
78 | 92 | be substantial if those active addresses were set to inactive. |
79 | 93 | """ |
|
0 commit comments