|
a/Allura/allura/app.py |
|
b/Allura/allura/app.py |
|
... |
|
... |
3 |
from cStringIO import StringIO
|
3 |
from cStringIO import StringIO
|
4 |
|
4 |
|
5 |
from tg import expose, redirect, flash
|
5 |
from tg import expose, redirect, flash
|
6 |
from tg.decorators import without_trailing_slash
|
6 |
from tg.decorators import without_trailing_slash
|
7 |
from pylons import c, g
|
7 |
from pylons import c, g
|
8 |
from pymongo.bson import ObjectId
|
8 |
from bson import ObjectId
|
9 |
|
9 |
|
10 |
from ming.orm import session
|
10 |
from ming.orm import session
|
11 |
|
11 |
|
12 |
from allura.lib.helpers import push_config
|
12 |
from allura.lib.helpers import push_config
|
13 |
from allura.lib.security import require, has_artifact_access
|
13 |
from allura.lib.security import require, has_artifact_access
|
|
... |
|
... |
200 |
parent_id = None
|
200 |
parent_id = None
|
201 |
thd = artifact.get_discussion_thread(data)
|
201 |
thd = artifact.get_discussion_thread(data)
|
202 |
# Handle attachments
|
202 |
# Handle attachments
|
203 |
message_id = data['message_id'][0]
|
203 |
message_id = data['message_id'][0]
|
204 |
if data.get('filename'):
|
204 |
if data.get('filename'):
|
|
|
205 |
# Special case - the actual post may not have been created yet
|
205 |
log.info('Saving attachment %s', data['filename'])
|
206 |
log.info('Saving attachment %s', data['filename'])
|
206 |
fp = StringIO(data['payload'])
|
207 |
fp = StringIO(data['payload'])
|
207 |
self.AttachmentClass.save_attachment(
|
208 |
self.AttachmentClass.save_attachment(
|
208 |
data['filename'], fp,
|
209 |
data['filename'], fp,
|
209 |
content_type=data.get('content_type', 'application/octet-stream'),
|
210 |
content_type=data.get('content_type', 'application/octet-stream'),
|
210 |
discussion_id=self.config.discussion_id,
|
211 |
discussion_id=self.config.discussion_id,
|
211 |
thread_id=thd._id,
|
212 |
thread_id=thd._id,
|
212 |
post_id=message_id)
|
213 |
post_id=message_id,
|
|
|
214 |
artifact_id=message_id)
|
213 |
return
|
215 |
return
|
214 |
# Handle duplicates
|
216 |
# Handle duplicates
|
215 |
original = self.PostClass.query.get(_id=message_id)
|
217 |
post = self.PostClass.query.get(_id=message_id)
|
216 |
if original:
|
218 |
if post:
|
217 |
log.info('Saving text attachment')
|
219 |
log.info('Saving text attachment')
|
218 |
self.AttachmentClass.save(
|
220 |
fp = StringIO(data['payload'])
|
|
|
221 |
post.attach(
|
219 |
'alternate',
|
222 |
'alternate', fp,
|
220 |
data.get('content_type', 'application/octet-stream'),
|
223 |
content_type=data.get('content_type', 'application/octet-stream'),
|
221 |
data['payload'],
|
|
|
222 |
discussion_id=self.config.discussion_id,
|
224 |
discussion_id=self.config.discussion_id,
|
223 |
thread_id=thd._id,
|
225 |
thread_id=thd._id,
|
224 |
post_id=message_id)
|
226 |
post_id=message_id)
|
225 |
return
|
227 |
else:
|
226 |
thd.post(
|
228 |
post = thd.post(
|
227 |
text=data['payload'] or '--no text body--',
|
229 |
text=data['payload'] or '--no text body--',
|
228 |
message_id=message_id,
|
230 |
message_id=message_id,
|
229 |
parent_id=parent_id,
|
231 |
parent_id=parent_id,
|
230 |
**kw)
|
232 |
**kw)
|
231 |
|
233 |
|
232 |
|
234 |
|
233 |
class DefaultAdminController(BaseController):
|
235 |
class DefaultAdminController(BaseController):
|
234 |
|
236 |
|
235 |
def __init__(self, app):
|
237 |
def __init__(self, app):
|