comparison roundup/roundupdb.py @ 337:8cd545738d8e

Features: . [SF#467129] Lossage when username=e-mail-address . [SF#473123] Change message generation for author . MailGW now moves 'resolved' to 'chatting' on receiving e-mail for an issue.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 30 Oct 2001 00:54:45 +0000
parents e18dd7227780
children a1331423eb93
comparison
equal deleted inserted replaced
336:b3c103e536ed 337:8cd545738d8e
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: roundupdb.py,v 1.15 2001-10-23 01:00:18 richard Exp $ 18 # $Id: roundupdb.py,v 1.16 2001-10-30 00:54:45 richard Exp $
19 19
20 import re, os, smtplib, socket 20 import re, os, smtplib, socket
21 21
22 import hyperdb, date 22 import hyperdb, date
23 23
42 42
43 user is created if they don't exist in the db already 43 user is created if they don't exist in the db already
44 ''' 44 '''
45 (realname, address) = address 45 (realname, address) = address
46 users = self.user.stringFind(address=address) 46 users = self.user.stringFind(address=address)
47 if users: return users[0] 47 for dummy in range(2):
48 if len(users) > 1:
49 # make sure we don't match the anonymous or admin user
50 for user in users:
51 if user == '1': continue
52 if self.user.get(user, 'username') == 'anonymous': continue
53 # first valid match will do
54 return user
55 # well, I guess we have no choice
56 return user[0]
57 elif users:
58 return users[0]
59 # try to match the username to the address (for local
60 # submissions where the address is empty)
61 users = self.user.stringFind(username=address)
62
63 # couldn't match address or username, so create a new user
48 return self.user.create(username=address, address=address, 64 return self.user.create(username=address, address=address,
49 realname=realname) 65 realname=realname)
50 66
51 _marker = [] 67 _marker = []
52 # XXX: added the 'creator' faked attribute 68 # XXX: added the 'creator' faked attribute
198 d['content'] = hyperdb.String() 214 d['content'] = hyperdb.String()
199 return d 215 return d
200 216
201 # XXX deviation from spec - was called ItemClass 217 # XXX deviation from spec - was called ItemClass
202 class IssueClass(Class): 218 class IssueClass(Class):
219 # configuration
220 MESSAGES_TO_AUTHOR = 'no'
221
203 # Overridden methods: 222 # Overridden methods:
204 223
205 def __init__(self, db, classname, **properties): 224 def __init__(self, db, classname, **properties):
206 """The newly-created class automatically includes the "messages", 225 """The newly-created class automatically includes the "messages",
207 "files", "nosy", and "superseder" properties. If the 'properties' 226 "files", "nosy", and "superseder" properties. If the 'properties'
245 # figure the recipient ids 264 # figure the recipient ids
246 recipients = self.db.msg.get(msgid, 'recipients') 265 recipients = self.db.msg.get(msgid, 'recipients')
247 r = {} 266 r = {}
248 for recipid in recipients: 267 for recipid in recipients:
249 r[recipid] = 1 268 r[recipid] = 1
269
270 # figure the author's id, and indicate they've received the message
250 authid = self.db.msg.get(msgid, 'author') 271 authid = self.db.msg.get(msgid, 'author')
251 r[authid] = 1 272 r[authid] = 1
252 273
274 sendto = []
275 # ... but duplicate the message to the author as long as it's not
276 # the anonymous user
277 if (self.MESSAGES_TO_AUTHOR == 'yes' and
278 self.db.user.get(authid, 'username') != 'anonymous'):
279 sendto.append(authid)
280
253 # now figure the nosy people who weren't recipients 281 # now figure the nosy people who weren't recipients
254 sendto = []
255 nosy = self.get(nodeid, 'nosy') 282 nosy = self.get(nodeid, 'nosy')
256 for nosyid in nosy: 283 for nosyid in nosy:
284 # Don't send nosy mail to the anonymous user (that user
285 # shouldn't appear in the nosy list, but just in case they
286 # do...)
287 if self.db.user.get(nosyid, 'username') == 'anonymous': continue
257 if not r.has_key(nosyid): 288 if not r.has_key(nosyid):
258 sendto.append(nosyid) 289 sendto.append(nosyid)
259 recipients.append(nosyid) 290 recipients.append(nosyid)
260 291
261 if sendto: 292 if sendto:
276 else: 307 else:
277 authaddr = '' 308 authaddr = ''
278 # TODO attachments 309 # TODO attachments
279 m = ['Subject: [%s%s] %s'%(cn, nodeid, title)] 310 m = ['Subject: [%s%s] %s'%(cn, nodeid, title)]
280 m.append('To: %s'%', '.join(sendto)) 311 m.append('To: %s'%', '.join(sendto))
312 m.append('From: %s'%self.ISSUE_TRACKER_EMAIL)
281 m.append('Reply-To: %s'%self.ISSUE_TRACKER_EMAIL) 313 m.append('Reply-To: %s'%self.ISSUE_TRACKER_EMAIL)
282 m.append('') 314 m.append('')
283 # add author information 315 # add author information
284 m.append("%s %sadded the comment:"%(authname, authaddr)) 316 m.append("%s %sadded the comment:"%(authname, authaddr))
285 m.append('') 317 m.append('')
305 %s 337 %s
306 '''%('_'*len(web), self.ISSUE_TRACKER_EMAIL, web) 338 '''%('_'*len(web), self.ISSUE_TRACKER_EMAIL, web)
307 339
308 # 340 #
309 # $Log: not supported by cvs2svn $ 341 # $Log: not supported by cvs2svn $
342 # Revision 1.15 2001/10/23 01:00:18 richard
343 # Re-enabled login and registration access after lopping them off via
344 # disabling access for anonymous users.
345 # Major re-org of the htmltemplate code, cleaning it up significantly. Fixed
346 # a couple of bugs while I was there. Probably introduced a couple, but
347 # things seem to work OK at the moment.
348 #
310 # Revision 1.14 2001/10/21 07:26:35 richard 349 # Revision 1.14 2001/10/21 07:26:35 richard
311 # feature #473127: Filenames. I modified the file.index and htmltemplate 350 # feature #473127: Filenames. I modified the file.index and htmltemplate
312 # source so that the filename is used in the link and the creation 351 # source so that the filename is used in the link and the creation
313 # information is displayed. 352 # information is displayed.
314 # 353 #

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