• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Révision6df449b5a97903d2fe31711f67b9afb49f369081 (tree)
l'heure2012-05-15 00:09:12
Auteurbolkimen <bolkimen@yaho...>
CommiterYaroslav Luzin

Message de Log

ticket:45 add file stats

Change Summary

Modification

--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -183,7 +183,7 @@ class ThreadController(BaseController):
183183 if not kw['text']:
184184 flash('Your post was not saved. You must provide content.', 'error')
185185 redirect(request.referer)
186- file_info = kw.pop('file_info', None)
186+ file_info = kw.get('file_info', None)
187187 p = self.thread.add_post(**kw)
188188 if hasattr(file_info, 'file'):
189189 p.attach(
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -194,7 +194,8 @@ class Thread(Artifact):
194194 post = self.post_class()(**kwargs)
195195 if ignore_security or has_access(self, 'unmoderated_post')():
196196 log.info('Auto-approving message from %s', c.user.username)
197- post.approve()
197+ file_info = kw.get('file_info', None)
198+ post.approve(file_info)
198199 else:
199200 self.notify_moderators(post)
200201 return post
@@ -461,7 +462,7 @@ class Post(Message, VersionedArtifact):
461462 super(Post, self).delete()
462463 self.thread.num_replies = max(0, self.thread.num_replies - 1)
463464
464- def approve(self):
465+ def approve(self, file_info=None):
465466 from allura.model.notification import Notification
466467 if self.status == 'ok': return
467468 self.status = 'ok'
@@ -478,7 +479,7 @@ class Post(Message, VersionedArtifact):
478479 self.acl, author.project_role()._id, 'unmoderated_post')
479480 g.post_event('discussion.new_post', self.thread_id, self._id)
480481 artifact = self.thread.artifact or self.thread
481- n = Notification.post(artifact, 'message', post=self)
482+ n = Notification.post(artifact, 'message', post=self, file_info=file_info)
482483 if hasattr(self.discussion,"monitoring_email") and self.discussion.monitoring_email:
483484 n.send_simple(self.discussion.monitoring_email)
484485 session(self).flush()
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -115,6 +115,17 @@ class Notification(MappedClass):
115115 c.project.shortname, c.app.config.options.mount_point)
116116 if topic == 'message':
117117 post = kwargs.pop('post')
118+ text = post.text
119+ file_info = kwargs.pop('file_info', None)
120+ if file_info is not None:
121+ MAX_READ = 1024 * 32
122+ bytecount= 0
123+ while 1:
124+ data = file_info.file.read(MAX_READ)
125+ if not data: break
126+ bytecount += len(data)
127+ text = "%s\n%s (%s bytes in %s)" % (text, file_info.filename, bytecount, file_info.type)
128+
118129 subject = post.subject or ''
119130 if post.parent_id and not subject.lower().startswith('re:'):
120131 subject = 'Re: ' + subject
@@ -125,7 +136,7 @@ class Notification(MappedClass):
125136 reply_to_address='"%s" <%s>' % (
126137 subject_prefix, getattr(artifact, 'email_address', 'noreply@in.sf.net')),
127138 subject=subject_prefix + subject,
128- text=post.text,
139+ text=text,
129140 in_reply_to=post.parent_id,
130141 author_id=author._id,
131142 pubdate=datetime.utcnow())