|
a/Allura/allura/model/discuss.py |
|
b/Allura/allura/model/discuss.py |
|
... |
|
... |
218 |
if limit is None:
|
218 |
if limit is None:
|
219 |
limit = 25
|
219 |
limit = 25
|
220 |
limit = int(limit)
|
220 |
limit = int(limit)
|
221 |
if timestamp:
|
221 |
if timestamp:
|
222 |
terms = dict(discussion_id=self.discussion_id, thread_id=self._id,
|
222 |
terms = dict(discussion_id=self.discussion_id, thread_id=self._id,
|
223 |
status='ok', timestamp=timestamp)
|
223 |
status={'$in': ['ok', 'pending']}, timestamp=timestamp)
|
224 |
else:
|
224 |
else:
|
225 |
terms = dict(discussion_id=self.discussion_id, thread_id=self._id,
|
225 |
terms = dict(discussion_id=self.discussion_id, thread_id=self._id,
|
226 |
status='ok')
|
226 |
status={'$in': ['ok', 'pending']})
|
227 |
q = self.post_class().query.find(terms)
|
227 |
q = self.post_class().query.find(terms)
|
228 |
if style == 'threaded':
|
228 |
if style == 'threaded':
|
229 |
q = q.sort('full_slug')
|
229 |
q = q.sort('full_slug')
|
230 |
else:
|
230 |
else:
|
231 |
q = q.sort('timestamp')
|
231 |
q = q.sort('timestamp')
|
|
... |
|
... |
269 |
else:
|
269 |
else:
|
270 |
self.subscriptions.pop(str(c.user._id), None)
|
270 |
self.subscriptions.pop(str(c.user._id), None)
|
271 |
subscription=property(_get_subscription, _set_subscription)
|
271 |
subscription=property(_get_subscription, _set_subscription)
|
272 |
|
272 |
|
273 |
def delete(self):
|
273 |
def delete(self):
|
274 |
self.post_class().query.remove(dict(thread_id=self._id))
|
274 |
for p in self.post_class().query.find(dict(thread_id=self._id)):
|
|
|
275 |
p.delete()
|
275 |
self.attachment_class().remove(dict(thread_id=self._id))
|
276 |
self.attachment_class().remove(dict(thread_id=self._id))
|
276 |
super(Thread, self).delete()
|
277 |
super(Thread, self).delete()
|
|
|
278 |
|
|
|
279 |
def spam(self):
|
|
|
280 |
"""Mark this thread as spam."""
|
|
|
281 |
for p in self.post_class().query.find(dict(thread_id=self._id)):
|
|
|
282 |
p.spam()
|
277 |
|
283 |
|
278 |
class PostHistory(Snapshot):
|
284 |
class PostHistory(Snapshot):
|
279 |
class __mongometa__:
|
285 |
class __mongometa__:
|
280 |
name='post_history'
|
286 |
name='post_history'
|
281 |
|
287 |
|
|
... |
|
... |
415 |
return 'Re: ' +(self.subject or '(no subject)')
|
421 |
return 'Re: ' +(self.subject or '(no subject)')
|
416 |
|
422 |
|
417 |
def delete(self):
|
423 |
def delete(self):
|
418 |
self.attachment_class().remove(dict(post_id=self._id))
|
424 |
self.attachment_class().remove(dict(post_id=self._id))
|
419 |
super(Post, self).delete()
|
425 |
super(Post, self).delete()
|
|
|
426 |
self.thread.num_replies = max(0, self.thread.num_replies - 1)
|
420 |
|
427 |
|
421 |
def approve(self):
|
428 |
def approve(self):
|
422 |
from allura.model.notification import Notification
|
429 |
from allura.model.notification import Notification
|
423 |
if self.status == 'ok': return
|
430 |
if self.status == 'ok': return
|
424 |
self.status = 'ok'
|
431 |
self.status = 'ok'
|
|
... |
|
... |
443 |
self.thread.update_stats()
|
450 |
self.thread.update_stats()
|
444 |
self.discussion.update_stats()
|
451 |
self.discussion.update_stats()
|
445 |
|
452 |
|
446 |
def spam(self):
|
453 |
def spam(self):
|
447 |
self.status = 'spam'
|
454 |
self.status = 'spam'
|
|
|
455 |
self.thread.num_replies = max(0, self.thread.num_replies - 1)
|
448 |
g.post_event('spam', self.index_id())
|
456 |
g.post_event('spam', self.index_id())
|
449 |
|
457 |
|
450 |
class DiscussionAttachment(BaseAttachment):
|
458 |
class DiscussionAttachment(BaseAttachment):
|
451 |
DiscussionClass=Discussion
|
459 |
DiscussionClass=Discussion
|
452 |
ThreadClass=Thread
|
460 |
ThreadClass=Thread
|