Skip to content

Commit 6227d82

Browse files
author
Richard Jones
committed
Alternate email addresses are now available for users.
See the MIGRATION file for info on how to activate the feature.
1 parent 4d9ad8f commit 6227d82

File tree

12 files changed

+228
-49
lines changed

12 files changed

+228
-49
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Feature:
66
. #503204 ] mailgw needs a default class
77
- partially done - the setting of additional properties can wait for a
88
better configuration system.
9+
. Alternate email addresses are now available for users. See the MIGRATION
10+
file for info on how to activate the feature.
11+
912

1013
Fixed:
1114
. Clean up mail handling, multipart handling.

MIGRATION.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,44 @@ ANONYMOUS_REGISTER_MAIL rather than overloading ANONYMOUS_REGISTER. If the
2222
variable doesn't exist, then ANONYMOUS_REGISTER is tested as before.
2323

2424

25+
Alternate E-Mail Addresses
26+
--------------------------
27+
28+
If you add the property "alternate_addresses" to your user class, your users
29+
will be able to register alternate email addresses that they may use to
30+
communicate with roundup as. All email from roundup will continue to be sent
31+
to their primary address.
32+
33+
If you have not edited the dbinit.py file in your instance home directory,
34+
you may simply copy the new dbinit.py file from the core code. If you used
35+
the classic schema, the interfaces file is in:
36+
37+
<roundup source>/roundup/templates/classic/dbinit.py
38+
39+
If you used the extended schema, the file is in:
40+
41+
<roundup source>/roundup/templates/extended/dbinit.py
42+
43+
If you have modified your dbinit.py file, you need to edit the dbinit.py
44+
file in your instance home directory. Find the lines which define the user
45+
class:
46+
47+
user = Class(db, "msg",
48+
username=String(), password=Password(),
49+
address=String(), realname=String(),
50+
phone=String(), organisation=String(),
51+
alternate_addresses=String())
52+
53+
You will also want to add the property to the user's details page. The
54+
template for this is the "user.item" file in your instance home "html"
55+
directory. Similar to above, you may copy the file from the roundup source if
56+
you haven't modified it. Otherwise, add the following to the template:
57+
58+
<display call="multiline('alternate_addresses')">
59+
60+
with appropriate labelling etc. See the standard template for an idea.
61+
62+
2563

2664
Migrating from 0.3.x to 0.4.x
2765
=============================

roundup/cgi_client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.101 2002-02-14 23:39:18 richard Exp $
18+
# $Id: cgi_client.py,v 1.102 2002-02-15 07:08:44 richard Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -778,7 +778,7 @@ def login(self, message=None, newuser_form=None, action='index'):
778778
return
779779
values = {'realname': '', 'organisation': '', 'address': '',
780780
'phone': '', 'username': '', 'password': '', 'confirm': '',
781-
'action': action}
781+
'action': action, 'alternate_addresses': ''}
782782
if newuser_form is not None:
783783
for key in newuser_form.keys():
784784
values[key] = newuser_form[key].value
@@ -789,11 +789,13 @@ def login(self, message=None, newuser_form=None, action='index'):
789789
<form onSubmit="return submit_once()" action="newuser_action" method=POST>
790790
<input type="hidden" name="__destination_url" value="%(action)s">
791791
<tr><td align=right><em>Name: </em></td>
792-
<td><input name="realname" value="%(realname)s"></td></tr>
792+
<td><input name="realname" value="%(realname)s" size=40></td></tr>
793793
<tr><td align=right><em>Organisation: </em></td>
794-
<td><input name="organisation" value="%(organisation)s"></td></tr>
794+
<td><input name="organisation" value="%(organisation)s" size=40></td></tr>
795795
<tr><td align=right>E-Mail Address: </td>
796-
<td><input name="address" value="%(address)s"></td></tr>
796+
<td><input name="address" value="%(address)s" size=40></td></tr>
797+
<tr><td align=right><em>Alternate E-mail Addresses: </em></td>
798+
<td><textarea name="alternate_addresses" rows=5 cols=40>%(alternate_addresses)s</textarea></td></tr>
797799
<tr><td align=right><em>Phone: </em></td>
798800
<td><input name="phone" value="%(phone)s"></td></tr>
799801
<tr><td align=right>Preferred Login name: </td>
@@ -1200,6 +1202,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
12001202

12011203
#
12021204
# $Log: not supported by cvs2svn $
1205+
# Revision 1.101 2002/02/14 23:39:18 richard
1206+
# . All forms now have "double-submit" protection when Javascript is enabled
1207+
# on the client-side.
1208+
#
12031209
# Revision 1.100 2002/01/16 07:02:57 richard
12041210
# . lots of date/interval related changes:
12051211
# - more relaxed date format for input

roundup/htmltemplate.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: htmltemplate.py,v 1.72 2002-02-14 23:39:18 richard Exp $
18+
# $Id: htmltemplate.py,v 1.73 2002-02-15 07:08:44 richard Exp $
1919

2020
__doc__ = """
2121
Template engine.
@@ -216,6 +216,27 @@ def do_field(self, property, size=None, showid=0):
216216
s = _('Plain: bad propclass "%(propclass)s"')%locals()
217217
return s
218218

219+
def do_multiline(self, property, rows=5, cols=40):
220+
''' display a string property in a multiline text edit field
221+
'''
222+
if not self.nodeid and self.form is None and self.filterspec is None:
223+
return _('[Multiline: not called from item]')
224+
225+
propclass = self.properties[property]
226+
227+
# make sure this is a link property
228+
if not isinstance(propclass, hyperdb.String):
229+
return _('[Multiline: not a string]')
230+
231+
# get the value
232+
value = self.determine_value(property)
233+
if value is None:
234+
value = ''
235+
236+
# display
237+
return '<textarea name="%s" rows="%s" cols="%s">%s</textarea>'%(
238+
property, rows, cols, value)
239+
219240
def do_menu(self, property, size=None, height=None, showid=0):
220241
''' for a Link property, display a menu of the available choices
221242
'''
@@ -389,7 +410,7 @@ def do_download(self, property, **args):
389410
'''
390411
if not self.nodeid:
391412
return _('[Download: not called from item]')
392-
return self.do_link(property, is_download=1)
413+
return self.do_link(property, is_download=1)
393414

394415

395416
def do_checklist(self, property, **args):
@@ -1043,6 +1064,10 @@ def render(self, form):
10431064

10441065
#
10451066
# $Log: not supported by cvs2svn $
1067+
# Revision 1.72 2002/02/14 23:39:18 richard
1068+
# . All forms now have "double-submit" protection when Javascript is enabled
1069+
# on the client-side.
1070+
#
10461071
# Revision 1.71 2002/01/23 06:15:24 richard
10471072
# real (non-string, duh) sorting of lists by node id
10481073
#

roundup/hyperdb.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.53 2002-01-22 07:21:13 richard Exp $
18+
# $Id: hyperdb.py,v 1.54 2002-02-15 07:08:44 richard Exp $
1919

2020
__doc__ = """
2121
Hyperdatabase implementation, especially field types.
@@ -846,7 +846,7 @@ def filter(self, filterspec, sort, group, num_re = re.compile('^\d+$')):
846846
else:
847847
continue
848848
break
849-
elif t == 2 and not v.search(node[k]):
849+
elif t == 2 and node[k] is None or not v.search(node[k]):
850850
# RE search
851851
break
852852
elif t == 6 and node[k] != v:
@@ -1066,6 +1066,14 @@ def Choice(name, *options):
10661066

10671067
#
10681068
# $Log: not supported by cvs2svn $
1069+
# Revision 1.53 2002/01/22 07:21:13 richard
1070+
# . fixed back_bsddb so it passed the journal tests
1071+
#
1072+
# ... it didn't seem happy using the back_anydbm _open method, which is odd.
1073+
# Yet another occurrance of whichdb not being able to recognise older bsddb
1074+
# databases. Yadda yadda. Made the HYPERDBDEBUG stuff more sane in the
1075+
# process.
1076+
#
10691077
# Revision 1.52 2002/01/21 16:33:19 rochecompaan
10701078
# You can now use the roundup-admin tool to pack the database
10711079
#

roundup/roundupdb.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.43 2002-02-14 22:33:15 richard Exp $
18+
# $Id: roundupdb.py,v 1.44 2002-02-15 07:08:44 richard Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -42,6 +42,23 @@ def splitDesignator(designator, dre=re.compile(r'([^\d]+)(\d+)')):
4242
return m.group(1), m.group(2)
4343

4444

45+
def extractUserFromList(users):
46+
'''Given a list of users, try to extract the first non-anonymous user
47+
and return that user, otherwise return None
48+
'''
49+
if len(users) > 1:
50+
# make sure we don't match the anonymous or admin user
51+
for user in users:
52+
if user == '1': continue
53+
if self.user.get(user, 'username') == 'anonymous': continue
54+
# first valid match will do
55+
return user
56+
# well, I guess we have no choice
57+
return user[0]
58+
elif users:
59+
return users[0]
60+
return None
61+
4562
class Database:
4663
def getuid(self):
4764
"""Return the id of the "user" node associated with the user
@@ -54,26 +71,25 @@ def uidFromAddress(self, address, create=1):
5471
user is created if they don't exist in the db already
5572
'''
5673
(realname, address) = address
57-
users = self.user.stringFind(address=address)
58-
for dummy in range(2):
59-
if len(users) > 1:
60-
# make sure we don't match the anonymous or admin user
61-
for user in users:
62-
if user == '1': continue
63-
if self.user.get(user, 'username') == 'anonymous': continue
64-
# first valid match will do
65-
return user
66-
# well, I guess we have no choice
67-
return user[0]
68-
elif users:
69-
return users[0]
70-
# try to match the username to the address (for local
71-
# submissions where the address is empty)
72-
users = self.user.stringFind(username=address)
74+
75+
# try a straight match of the address
76+
user = extractUserFromList(self.user.stringFind(address=address))
77+
if user is not None: return user
78+
79+
# try the user alternate addresses if possible
80+
props = self.user.getprops()
81+
if props.has_key('alternate_addresses'):
82+
users = self.user.filter({'alternate_addresses': address},
83+
[], [])
84+
user = extractUserFromList(users)
85+
if user is not None: return user
86+
87+
# try to match the username to the address (for local
88+
# submissions where the address is empty)
89+
user = extractUserFromList(self.user.stringFind(username=address))
7390

7491
# couldn't match address or username, so create a new user
7592
if create:
76-
print 'CREATING USER', address
7793
return self.user.create(username=address, address=address,
7894
realname=realname)
7995
else:
@@ -571,6 +587,9 @@ def generateChangeNote(self, nodeid, oldvalues):
571587

572588
#
573589
# $Log: not supported by cvs2svn $
590+
# Revision 1.43 2002/02/14 22:33:15 richard
591+
# . Added a uniquely Roundup header to email, "X-Roundup-Name"
592+
#
574593
# Revision 1.42 2002/01/21 09:55:14 rochecompaan
575594
# Properties in change note are now sorted
576595
#

roundup/templates/classic/dbinit.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: dbinit.py,v 1.14 2002-01-14 02:20:15 richard Exp $
18+
# $Id: dbinit.py,v 1.15 2002-02-15 07:08:44 richard Exp $
1919

2020
import os
2121

@@ -63,7 +63,8 @@ def open(name=None):
6363
user = Class(db, "user",
6464
username=String(), password=Password(),
6565
address=String(), realname=String(),
66-
phone=String(), organisation=String())
66+
phone=String(), organisation=String(),
67+
alternate_addresses=String())
6768
user.setkey("username")
6869

6970
msg = FileClass(db, "msg",
@@ -122,6 +123,15 @@ def init(adminpw):
122123

123124
#
124125
# $Log: not supported by cvs2svn $
126+
# Revision 1.14 2002/01/14 02:20:15 richard
127+
# . changed all config accesses so they access either the instance or the
128+
# config attriubute on the db. This means that all config is obtained from
129+
# instance_config instead of the mish-mash of classes. This will make
130+
# switching to a ConfigParser setup easier too, I hope.
131+
#
132+
# At a minimum, this makes migration a _little_ easier (a lot easier in the
133+
# 0.5.0 switch, I hope!)
134+
#
125135
# Revision 1.13 2002/01/02 02:31:38 richard
126136
# Sorry for the huge checkin message - I was only intending to implement #496356
127137
# but I found a number of places where things had been broken by transactions:

roundup/templates/classic/html/user.item

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: user.item,v 1.2 2001-07-29 04:07:37 richard Exp $-->
1+
<!-- $Id: user.item,v 1.3 2002-02-15 07:08:44 richard Exp $-->
22
<table border=0 cellspacing=0 cellpadding=2>
33

44
<tr class="strong-header">
@@ -29,6 +29,12 @@
2929
<td width=1% nowrap align=right><span class="form-label">E-mail address</span></td>
3030
<td class="form-text"><display call="field('address', size=40)"></td>
3131
</tr>
32+
<tr bgcolor="ffffea">
33+
<td width=1% nowrap align=right><span class="form-label">Alternate
34+
E-mail addresses</span><br>
35+
<span class="form-help">One address per line</span></td>
36+
<td class="form-text"><display call="multiline('alternate_addresses')"></td>
37+
</tr>
3238

3339
<tr bgcolor="ffffea">
3440
<td>&nbsp;</td>

roundup/templates/extended/dbinit.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: dbinit.py,v 1.19 2002-01-14 02:20:15 richard Exp $
18+
# $Id: dbinit.py,v 1.20 2002-02-15 07:08:44 richard Exp $
1919

2020
import os
2121

@@ -63,7 +63,8 @@ def open(name=None):
6363
user = Class(db, "user",
6464
username=String(), password=Password(),
6565
address=String(), realname=String(),
66-
phone=String(), organisation=String())
66+
phone=String(), organisation=String(),
67+
alternate_addresses=String())
6768
user.setkey("username")
6869

6970
msg = FileClass(db, "msg",
@@ -173,6 +174,15 @@ def init(adminpw):
173174

174175
#
175176
# $Log: not supported by cvs2svn $
177+
# Revision 1.19 2002/01/14 02:20:15 richard
178+
# . changed all config accesses so they access either the instance or the
179+
# config attriubute on the db. This means that all config is obtained from
180+
# instance_config instead of the mish-mash of classes. This will make
181+
# switching to a ConfigParser setup easier too, I hope.
182+
#
183+
# At a minimum, this makes migration a _little_ easier (a lot easier in the
184+
# 0.5.0 switch, I hope!)
185+
#
176186
# Revision 1.18 2002/01/02 02:31:38 richard
177187
# Sorry for the huge checkin message - I was only intending to implement #496356
178188
# but I found a number of places where things had been broken by transactions:

roundup/templates/extended/html/user.item

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: user.item,v 1.1 2001-07-23 04:21:20 richard Exp $-->
1+
<!-- $Id: user.item,v 1.2 2002-02-15 07:08:45 richard Exp $-->
22
<table border=0 cellspacing=0 cellpadding=2>
33

44
<tr class="strong-header">
@@ -29,6 +29,10 @@
2929
<td width=1% nowrap align=right><span class="form-label">E-mail address</span></td>
3030
<td class="form-text"><display call="field('address', size=40)"></td>
3131
</tr>
32+
<tr bgcolor="ffffea">
33+
<td width=1% nowrap align=right><span class="form-label">Alternate E-mail addresses</span></td>
34+
<td class="form-text"><display call="multiline('alternate_addresses')"></td>
35+
</tr>
3236

3337
<tr bgcolor="ffffea">
3438
<td>&nbsp;</td>

0 commit comments

Comments
 (0)