Changeset 585
- Timestamp:
- 02/06/12 12:04:50 (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r583 r585 1 2.5.0 2 * BLOG improvements by Thomas Moschny, closes #287,#235,#175: 3 - Tries to use the 'Date:' email header to set the date of the blog 4 post or comment. 5 - Allows overriding author and categories via subject parameters or 6 inline properties (see below). 7 - Does not add the 'blog_' prefix to the default (short-) name of a 8 blog entry anymore, as it would be rather redundant. 9 - Allows selecting a custom short name for the blog entry instead of 10 a default date-based short name. The custom short name may not 11 contain spaces. (Note that the TracFullBlogPlugin imposes 12 additional rules for valid short names.) 13 - Bugfix: Fixes crash wile processing mails with attachments (#175). 14 - Properly adds attachments to blog entries (#175). 15 16 Author: Thomas Moschny 17 Applied by: Bas van der Vlies 18 1 19 2.4.7 2 20 * Some blog improvements. Removes 'blog:' from subject line and honors the -
trunk/debian/changelog
r583 r585 1 email2trac (2.5.0-1) stable; urgency=low 2 3 * New release 2.5.0, see ChangeLog 4 5 -- Bas van der Vlies <basv@sara.nl> Mon, 06 Feb 2012 12:02:58 +0100 6 1 7 email2trac (2.4.7-1) stable; urgency=low 2 8 -
trunk/email2trac.py.in
r582 r585 1325 1325 if self.system == 'discussion': 1326 1326 att = attachment.Attachment(self.env, 'discussion', 'topic/%s' % (self.id,)) 1327 elif self.system == 'blog': 1328 att = attachment.Attachment(self.env, 'blog', '%s' % (self.id,)) 1327 1329 else: 1328 1330 s = 'Attach %s to ticket %d' %(filename, self.id) … … 1358 1360 ########## Fullblog functions ################################################# 1359 1361 1360 def blog(self, msg, subject, id ):1362 def blog(self, msg, subject, id, params): 1361 1363 """ 1362 1364 The blog create/update function … … 1372 1374 req = Mock(authname='anonymous', perm=MockPerm(), args={}) 1373 1375 1374 if id: 1375 1376 ## update blog 1377 # 1378 comment = BlogComment(self.env, id) 1379 comment.author = self.author 1380 1381 message_parts = self.get_message_parts(msg) 1376 ## parameters from the subject 1377 # 1378 params = self.str_to_dict((params or '').lstrip('?')) 1379 1380 ## preferably get the time from the email date header, or else 1381 # use current date and time 1382 date = email.Utils.parsedate_tz(msg.get('date')) 1383 if date: 1384 dt = util.datefmt.to_datetime(email.Utils.mktime_tz(date), util.datefmt.utc) 1385 else: 1386 self.logger.warn("No valid date header found") 1387 dt = util.datefmt.to_datetime(None, util.datefmt.utc) 1388 1389 ## blog entry affected 1390 # 1391 self.id = id or util.datefmt.format_datetime(dt, "%Y%m%d%H%M%S", util.datefmt.utc) 1392 1393 ## check wether a blog post exists 1394 # 1395 post = BlogPost(self.env, self.id) 1396 force_update = self.properties.get('update', params.get('update')) 1397 1398 ## message parts 1399 # 1400 message_parts = self.get_message_parts(msg) 1401 message_parts = self.unique_attachment_names(message_parts) 1402 1403 if post.get_versions() and not force_update: 1404 1405 ## add comment to blog entry 1406 # 1407 comment = BlogComment(self.env, self.id) 1408 comment.author = self.properties.get('author', params.get('author', self.author)) 1382 1409 comment.comment = self.get_body_text(message_parts) 1410 comment.time = dt 1383 1411 1384 1412 if self.parameters.dry_run: 1385 1413 self.logger.info('DRY-RUN: not adding comment for blog entry "%s"' % id) 1386 1414 return 1387 blog.create_comment(req, comment)1415 warnings = blog.create_comment(req, comment) 1388 1416 1389 1417 else: 1390 ## create blog 1391 # 1392 import time 1393 post = BlogPost(self.env, 'blog_'+time.strftime("%Y%m%d%H%M%S", time.gmtime())) 1394 1395 #post = BlogPost(self.env, blog._get_default_postname(self.env)) 1396 1397 post.author = self.author 1418 ## create or update blog entry 1419 # 1420 post.author = self.properties.get('author', params.get('author', self.author)) 1421 post.categories = self.properties.get('categories', params.get('categories', '')) 1398 1422 post.title = subject.strip() 1399 1400 message_parts = self.get_message_parts(msg) 1423 post.publish_time = dt 1401 1424 post.body = self.get_body_text(message_parts) 1402 1425 … … 1404 1427 self.logger.info('DRY-RUN: not creating blog entry "%s"' % post.title) 1405 1428 return 1406 blog.create_post(req, post, self.author, u'Created by email2trac', False) 1429 warnings = blog.create_post(req, post, self.author, u'Created by email2trac', False) 1430 1431 ## check for problems 1432 # 1433 if warnings: 1434 raise TracError(', '.join('blog:%s:%s' % (w[0], w[1]) for w in warnings)) 1435 1436 ## all seems well, attach attachments 1437 # 1438 self.attach_attachments(message_parts) 1407 1439 1408 1440 … … 1696 1728 self.logger.debug('Trac BLOG support enabled') 1697 1729 blog_enabled = True 1698 blog_regex = '''|(?P<blog>blog :(?P<blog_id>\w*))'''1730 blog_regex = '''|(?P<blog>blog(?P<blog_params>[?][^:]*)?:(?P<blog_id>\S*))''' 1699 1731 1700 1732 … … 1740 1772 if result.group('blog'): 1741 1773 self.system = 'blog' 1742 self.blog(m, subject[result.end('blog'):], result.group('blog_id') )1774 self.blog(m, subject[result.end('blog'):], result.group('blog_id'), result.group('blog_params')) 1743 1775 1744 1776 if discussion_enabled: … … 2146 2178 2147 2179 att = attachment.Attachment(self.env, 'discussion', 'ticket/%s' % (self.id,), filename) 2180 2181 elif self.system == 'blog': 2182 2183 att = attachment.Attachment(self.env, 'blog', '%s' % (self.id,), filename) 2148 2184 2149 2185 else:
Note: See TracChangeset
for help on using the changeset viewer.