Switch to unified view

a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
...
...
144
    @h.vardec
144
    @h.vardec
145
    @expose()
145
    @expose()
146
    @validate(pass_validator, error_handler=index)
146
    @validate(pass_validator, error_handler=index)
147
    def post(self, **kw):
147
    def post(self, **kw):
148
        require(has_artifact_access('post', self.thread))
148
        require(has_artifact_access('post', self.thread))
149
        kw = self.W.edit_post.validate(kw, None)
149
        kw = self.W.edit_post.to_python(kw, None)
150
        file_info = kw.pop('file_info', None)
150
        file_info = kw.pop('file_info', None)
151
        p = self.thread.add_post(**kw)
151
        p = self.thread.add_post(**kw)
152
        if hasattr(file_info, 'file'):
152
        if hasattr(file_info, 'file'):
153
            self.M.Attachment.save_attachment(
153
            self.M.Attachment.save_attachment(
154
                file_info.filename, file_info.file, content_type=file_info.type,
154
                file_info.filename, file_info.file, content_type=file_info.type,
...
...
229
    @validate(pass_validator)
229
    @validate(pass_validator)
230
    def index(self, version=None, **kw):
230
    def index(self, version=None, **kw):
231
        c.post = self.W.post
231
        c.post = self.W.post
232
        if request.method == 'POST':
232
        if request.method == 'POST':
233
            require(has_artifact_access('moderate', self.post))
233
            require(has_artifact_access('moderate', self.post))
234
            post_fields = self.W.edit_post.validate(kw, None)
234
            post_fields = self.W.edit_post.to_python(kw, None)
235
            for k,v in post_fields.iteritems():
235
            for k,v in post_fields.iteritems():
236
                try:
236
                try:
237
                    setattr(self.post, k, v)
237
                    setattr(self.post, k, v)
238
                except AttributeError:
238
                except AttributeError:
239
                    continue
239
                    continue
...
...
260
    @h.vardec
260
    @h.vardec
261
    @expose()
261
    @expose()
262
    @validate(pass_validator, error_handler=index)
262
    @validate(pass_validator, error_handler=index)
263
    def reply(self, **kw):
263
    def reply(self, **kw):
264
        require(has_artifact_access('post', self.thread))
264
        require(has_artifact_access('post', self.thread))
265
        kw = self.W.edit_post.validate(kw, None)
265
        kw = self.W.edit_post.to_python(kw, None)
266
        self.thread.post(parent_id=self.post._id, **kw)
266
        self.thread.post(parent_id=self.post._id, **kw)
267
        self.thread.num_replies += 1
267
        self.thread.num_replies += 1
268
        redirect(request.referer)
268
        redirect(request.referer)
269
269
270
    @h.vardec
270
    @h.vardec
...
...
282
282
283
    @h.vardec
283
    @h.vardec
284
    @expose()
284
    @expose()
285
    @validate(pass_validator, error_handler=index)
285
    @validate(pass_validator, error_handler=index)
286
    def flag(self, **kw):
286
    def flag(self, **kw):
287
        self.W.flag_post.validate(kw, None)
287
        self.W.flag_post.to_python(kw, None)
288
        if c.user._id not in self.post.flagged_by:
288
        if c.user._id not in self.post.flagged_by:
289
            self.post.flagged_by.append(c.user._id)
289
            self.post.flagged_by.append(c.user._id)
290
            self.post.flags += 1
290
            self.post.flags += 1
291
        redirect(request.referer)
291
        redirect(request.referer)
292
292
...
...
336
336
337
    @h.vardec
337
    @h.vardec
338
    @expose('jinja:discussion/moderate.html')
338
    @expose('jinja:discussion/moderate.html')
339
    @validate(pass_validator)
339
    @validate(pass_validator)
340
    def index(self, **kw):
340
    def index(self, **kw):
341
        kw = WidgetConfig.post_filter.validate(kw, None)
341
        kw = WidgetConfig.post_filter.to_python(kw, None)
342
        page = kw.pop('page', 0)
342
        page = kw.pop('page', 0)
343
        limit = kw.pop('limit', 50)
343
        limit = kw.pop('limit', 50)
344
        status = kw.pop('status', '-')
344
        status = kw.pop('status', '-')
345
        flag = kw.pop('flag', None)
345
        flag = kw.pop('flag', None)
346
        c.post_filter = WidgetConfig.post_filter
346
        c.post_filter = WidgetConfig.post_filter
...
...
392
    @h.vardec
392
    @h.vardec
393
    @expose()
393
    @expose()
394
    @validate(pass_validator, error_handler=h.json_validation_error)
394
    @validate(pass_validator, error_handler=h.json_validation_error)
395
    def reply(self, **kw):
395
    def reply(self, **kw):
396
        require(has_artifact_access('post', self.thread))
396
        require(has_artifact_access('post', self.thread))
397
        kw = self.W.edit_post.validate(kw, None)
397
        kw = self.W.edit_post.to_python(kw, None)
398
        post = self.thread.post(parent_id=self.post._id, **kw)
398
        post = self.thread.post(parent_id=self.post._id, **kw)
399
        self.thread.num_replies += 1
399
        self.thread.num_replies += 1
400
        redirect(post.slug.split('/')[-1] + '/')
400
        redirect(post.slug.split('/')[-1] + '/')
401
401
402
class ThreadRestController(ThreadController):
402
class ThreadRestController(ThreadController):
...
...
408
    @h.vardec
408
    @h.vardec
409
    @expose()
409
    @expose()
410
    @validate(pass_validator, error_handler=h.json_validation_error)
410
    @validate(pass_validator, error_handler=h.json_validation_error)
411
    def new(self, **kw):
411
    def new(self, **kw):
412
        require(has_artifact_access('post', self.thread))
412
        require(has_artifact_access('post', self.thread))
413
        kw = self.W.edit_post.validate(kw, None)
413
        kw = self.W.edit_post.to_python(kw, None)
414
        p = self.thread.add_post(**kw)
414
        p = self.thread.add_post(**kw)
415
        redirect(p.slug + '/')
415
        redirect(p.slug + '/')
416
416
417
class AppDiscussionRestController(AppDiscussionController):
417
class AppDiscussionRestController(AppDiscussionController):
418
    ThreadController = ThreadRestController
418
    ThreadController = ThreadRestController