annotate scripts/roundup-reminder @ 5548:fea11d05110e

Avoid errors from selecting "no selection" on multilink (issue2550722). As discussed in issue 2550722 there are various cases where selecting "no selection" on a multilink can result in inappropriate errors from Roundup: * If selecting "no selection" produces a null edit (a value was set in the multilink in an edit with an error, then removed again, along with all other changes, in the next form submission), so the page is rendered from the form contents including the "-<id>" value for "no selection" for the multilink. * If creating an item with a nonempty value for a multilink has an error, and the resubmission changes that multilink to "no selection" (and this in turn has subcases, according to whether the creation then succeeds or fails on the resubmission, which need fixes in different places in the Roundup code). All of these cases have in common that it is expected and OK to have a "-<id>" value for a submission for a multilink when <id> is not set in that multilink in the database (because the original attempt to set <id> in that multilink had an error), so the hyperdb.py logic to give an error in that case is thus removed. In the subcase of the second case where the resubmission with "no selection" has an error, the templating code tries to produce a menu entry for the "-<id>" multilink value, which also results in an error, hence the templating.py change to ignore such values in the list for a multilink.
author Joseph Myers <jsm@polyomino.org.uk>
date Thu, 27 Sep 2018 11:33:01 +0000
parents e124d76311e0
children 6348bd0690a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4041
5db2dfff85d8 Fix issue1891328
Stefan Seefeld <stefan@seefeld.name>
parents: 3817
diff changeset
1 #! /usr/bin/env python
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
2 # Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/)
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
3 #
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
5 # of this software and associated documentation files (the "Software"), to deal
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
6 # in the Software without restriction, including without limitation the rights
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
8 # copies of the Software, and to permit persons to whom the Software is
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
9 # furnished to do so, subject to the following conditions:
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
10 #
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
11 # The above copyright notice and this permission notice shall be included in
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
12 # all copies or substantial portions of the Software.
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
13 #
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
20 # SOFTWARE.
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
21
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
22 '''
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
23 Simple script that emails all users of a tracker with the issues that
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
24 are currently assigned to them.
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
25
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
26 TODO: introduce some structure ;)
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
27 TODO: possibly make this more general and configurable...
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
28 '''
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
29
5412
c75defc1c2f0 Python 3 preparation: miscellaneous Python scripts not named *.py.
Joseph Myers <jsm@polyomino.org.uk>
parents: 4658
diff changeset
30 from __future__ import print_function
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
31 import sys
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
32 from email.mime.multipart import MIMEMultipart
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
33 from email.utils import make_msgid
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
34 from roundup import instance, date
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
35 from roundup.mailer import Mailer
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
36
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
37 # open the instance
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
38 if len(sys.argv) != 2:
5412
c75defc1c2f0 Python 3 preparation: miscellaneous Python scripts not named *.py.
Joseph Myers <jsm@polyomino.org.uk>
parents: 4658
diff changeset
39 print('You need to specify an instance home dir')
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
40 instance_home = sys.argv[1]
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
41 instance = instance.open(instance_home)
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
42 db = instance.open('admin')
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
43
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
44 resolved_id = db.status.lookup('resolved')
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
45
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
46 class Reverse:
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
47 """Class reversing sort order."""
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
48
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
49 def __init__(self, val):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
50 self.val = val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
51
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
52 def __lt__(self, other):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
53 return other.val < self.val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
54 def __le__(self, other):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
55 return other.val <= self.val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
56 def __eq__(self, other):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
57 return other.val == self.val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
58 def __ne__(self, other):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
59 return other.val != self.val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
60 def __gt__(self, other):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
61 return other.val > self.val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
62 def __ge__(self, other):
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
63 return other.val >= self.val
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
64
5414
3fa026621f69 Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5412
diff changeset
65 def listKey(x):
3fa026621f69 Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5412
diff changeset
66 "key for tuples such that order is positive on [0] and negative on [1]"
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
67 return (x[0], Reverse(x[1]))
1999
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
68 return 0
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
69
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
70 # loop through all the users
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
71 for user_id in db.user.list():
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
72 # make sure we care aboue this user
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
73 name = db.user.get(user_id, 'realname')
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
74 if name is None:
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
75 name = db.user.get(user_id, 'username')
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
76 address = db.user.get(user_id, 'address')
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
77 if address is None:
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
78 continue
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
79
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
80 # extract this user's issues
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
81 l = []
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
82 for issue_id in db.issue.find(assignedto=user_id):
1999
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
83 if db.issue.get(issue_id, 'status') == resolved_id:
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
84 continue
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
85 order = db.priority.get(db.issue.get(issue_id, 'priority'), 'order')
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
86 l.append((order, db.issue.get(issue_id, 'activity'),
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
87 db.issue.get(issue_id, 'creation'), issue_id))
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
88
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
89 # sort the issues by timeliness and creation date
5414
3fa026621f69 Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5412
diff changeset
90 l.sort(key=listKey)
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
91 if not l:
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
92 continue
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
93
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
94 # generate the email message
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
95 mailer = Mailer(db.config)
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
96 message = MIMEMultipart('alternative')
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
97 mailer.set_message_attributes(
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
98 message,
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
99 [address],
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
100 'Your active %s issues'%db.config.TRACKER_NAME)
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
101 message['Reply-To'] = '%s <%s>'%(db.config.TRACKER_NAME,
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
102 db.config.ADMIN_EMAIL)
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
103 message['Message-Id'] = make_msgid()
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
104
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
105 # do the plain text bit
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
106 text_lines = []
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
107 text_lines.append('Created ID Activity Title')
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
108 text_lines.append('='*75)
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
109 # '2 months 213 immediate cc_daemon barfage
1999
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
110 old_priority = None
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
111 for priority_order, activity_date, creation_date, issue_id in l:
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
112 priority = db.issue.get(issue_id, 'priority')
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
113 if (priority != old_priority):
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
114 old_priority = priority
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
115 text_lines.append(' ' + db.priority.get(priority,'name'))
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
116 # pretty creation
3817
ce2c88d83eb6 Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents: 2001
diff changeset
117 creation = (creation_date - date.Date('.')).pretty()
ce2c88d83eb6 Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents: 2001
diff changeset
118 activity = (activity_date - date.Date('.')).pretty()
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
119 title = db.issue.get(issue_id, 'title')
1999
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
120 if len(title) > 42:
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
121 title = title[:38] + ' ...'
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
122 text_lines.append('%-11s %-4s %-9s %-42s'%(creation, issue_id,
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
123 activity, title))
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
124
711
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
125 # some help to finish off
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
126 text_lines.append('''
711
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
127 To view or respond to any of the issues listed above, visit the URL
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
128
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
129 %s
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
130
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
131 and click on "My Issues". Do NOT respond to this message.
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
132 '''%db.config.TRACKER_WEB)
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
133 text = '\n'.join(text_lines) + '\n'
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
134 part = mailer.get_text_message()
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
135 part.set_payload(text, part.get_charset())
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
136 message.attach(part)
711
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
137
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
138
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
139 # now the HTML one
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
140 html_lines = []
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
141 colours = {
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
142 'immediate': ' bgcolor="#ffcdcd"',
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
143 'day': ' bgcolor="#ffdecd"',
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
144 'week': ' bgcolor="#ffeecd"',
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
145 'month': ' bgcolor="#ffffcd"',
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
146 'whenever': ' bgcolor="#ffffff"',
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
147 }
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
148 html_lines.append('''<table border>
1999
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
149 <tr><th>Created</th> <th>ID</th> <th>Activity</th> <th>Title</th></tr>
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
150 ''')
1999
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
151 old_priority = None
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
152 for priority_order, activity_date, creation_date, issue_id in l:
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
153 priority = db.issue.get(issue_id,'priority')
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
154 if (priority != old_priority):
1b7f730e7037 fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents: 1612
diff changeset
155 old_priority = priority
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
156 html_lines.append('<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>'%db.priority.get(priority,'name'))
4658
838e0e0c5e9f Incorrect 'Created' value in round-reminder script (issue2550769)
John Kristensen <john@jerrykan.com>
parents: 4041
diff changeset
157 creation = (creation_date - date.Date('.')).pretty()
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
158 title = db.issue.get(issue_id, 'title')
1409
8dc60d87ab42 Fixed a backlog of bug reports, and worked on python 2.3 compatibility:
Richard Jones <richard@users.sourceforge.net>
parents: 1096
diff changeset
159 issue_id = '<a href="%sissue%s">%s</a>'%(db.config.TRACKER_WEB,
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
160 issue_id, issue_id)
3817
ce2c88d83eb6 Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents: 2001
diff changeset
161 activity = (activity_date - date.Date('.')).pretty()
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
162 html_lines.append('''<tr><td>%s</td><td>%s</td><td>%s</td>
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
163 <td>%s</td></tr>'''%(creation, issue_id, activity, title))
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
164 html_lines.append('</table>')
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
165
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
166 html_lines.append('''<p>To view or respond to any of the issues listed
711
9c76498f1ac3 Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents: 689
diff changeset
167 above, simply click on the issue ID. Do <b>not</b> respond to
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
168 this message.</p>''')
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
169 html = '\n'.join(html_lines) + '\n'
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
170 part = mailer.get_text_message('utf-8', 'html')
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
171 part.set_payload(html, part.get_charset())
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
172 message.attach(part)
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
173
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
174 # all done, send!
5541
e124d76311e0 Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5418
diff changeset
175 mailer.smtp_send([address], message.as_string())
689
456a1ed04650 Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
176
1092
e5826025eeb7 more Log removal
Richard Jones <richard@users.sourceforge.net>
parents: 711
diff changeset
177 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/