Skip to content

Commit f7a17fa

Browse files
author
Richard Jones
committed
support propety setting on message and file through web and email interface
1 parent e46f5bf commit f7a17fa

File tree

3 files changed

+226
-119
lines changed

3 files changed

+226
-119
lines changed

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

44
2003-??-?? 0.6.0 (?)
5-
- better hyperlinking
5+
- better hyperlinking in web message texts
6+
- support setting of properties on message and file through web and
7+
email interface (thanks John Rouillard)
8+
69

710
2003-01-10 0.5.4
811
- key the templates cache off full path, not filename

roundup/cgi/client.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.65 2003-01-08 04:39:36 richard Exp $
1+
# $Id: client.py,v 1.66 2003-01-11 23:52:28 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -1050,14 +1050,28 @@ def _handle_message(self):
10501050
files = []
10511051
if self.form.has_key(':file'):
10521052
file = self.form[':file']
1053+
1054+
# if there's a filename, then we create a file
10531055
if file.filename:
1056+
# see if there are any file properties we should set
1057+
file_props={};
1058+
if self.form.has_key(':file_fields'):
1059+
for field in self.form[':file_fields'].value.split(','):
1060+
if self.form.has_key(field):
1061+
if field.startswith("file_"):
1062+
file_props[field[5:]] = self.form[field].value
1063+
else :
1064+
file_props[field] = self.form[field].value
1065+
1066+
# try to determine the file content-type
10541067
filename = file.filename.split('\\')[-1]
10551068
mime_type = mimetypes.guess_type(filename)[0]
10561069
if not mime_type:
10571070
mime_type = "application/octet-stream"
1071+
10581072
# create the new file entry
10591073
files.append(self.db.file.create(type=mime_type,
1060-
name=filename, content=file.file.read()))
1074+
name=filename, content=file.file.read(), **file_props))
10611075

10621076
# we don't want to do a message if none of the following is true...
10631077
cn = self.classname
@@ -1092,11 +1106,21 @@ def _handle_message(self):
10921106
messageid = "<%s.%s.%s@%s>"%(time.time(), random.random(),
10931107
self.classname, self.instance.config.MAIL_DOMAIN)
10941108

1109+
# see if there are any message properties we should set
1110+
msg_props={};
1111+
if self.form.has_key(':msg_fields'):
1112+
for field in self.form[':msg_fields'].value.split(','):
1113+
if self.form.has_key(field):
1114+
if field.startswith("msg_"):
1115+
msg_props[field[4:]] = self.form[field].value
1116+
else :
1117+
msg_props[field] = self.form[field].value
1118+
10951119
# now create the message, attaching the files
10961120
content = '\n'.join(m)
10971121
message_id = self.db.msg.create(author=self.userid,
10981122
recipients=[], date=date.Date('.'), summary=summary,
1099-
content=content, files=files, messageid=messageid)
1123+
content=content, files=files, messageid=messageid, **msg_props)
11001124

11011125
# update the messages property
11021126
return message_id, files

0 commit comments

Comments
 (0)