def detail(self, id, archive=None, format=None): "return message detail" message = self._get_msg(id, archive) if not message: abort(404) msgstatus = Session.query(MessageStatus)\ .filter(MessageStatus.messageid==message.messageid)\ .all() show_trail = request.GET.get('t', None) c.form = ReleaseMsgForm(request.POST, csrf_context=session) if request.POST and c.form.validate(): job = dict(release=c.form.release.data, learn=c.form.learn.data, salearn_as=c.form.learnas.data, todelete=c.form.delete.data, use_alt=c.form.usealt.data, altrecipients=c.form.altrecipients.data, message_id=message.messageid, from_address=message.from_address, date=str(message.date), to_address=message.to_address, hostname=message.hostname, mid=message.id) try: task = process_quarantined_msg.apply_async( args=[job], queue=message.hostname) task.wait(30) if task.status == 'SUCCESS': # process response html = process_release_results( c, message, task.result, Session) self.invalidate = 1 message = self._get_msg(id, archive) flash(html) else: html = _('Processing the request failed') flash_alert(html) except (TimeoutError, QueueNotFound): html = _('Processing the request failed') flash_alert(html) if format == 'json': flash.pop_messages() response.headers['Content-Type'] = 'application/json' return json.dumps(dict(result=html)) elif request.POST and not c.form.validate(): flash_alert(_(', '.join([c.form.errors[err][0] for err in c.form.errors]))) if format == 'json': html = flash.pop_messages() response.headers['Content-Type'] = 'application/json' return json.dumps(dict(result=html)) if format == 'json': response.headers['Content-Type'] = 'application/json' return json.dumps(message.tojson) c.msg = message c.archived = archive c.show_trail = show_trail c.msgstatus = msgstatus return render('/messages/detail.html')
def detail(self, id, archive=None, format=None): "return message detail" message = self._get_msg(id, archive) if not message: abort(404) msgstatus = Session.query(MessageStatus)\ .filter(MessageStatus.messageid==message.messageid)\ .all() show_trail = request.GET.get('t', None) c.form = ReleaseMsgForm(request.POST, csrf_context=session) if request.POST and c.form.validate(): localtmz = config.get('baruwa.timezone', 'Africa/Johannesburg') job = dict(release=c.form.release.data, learn=c.form.learn.data, salearn_as=c.form.learnas.data, todelete=c.form.delete.data, use_alt=c.form.usealt.data, altrecipients=c.form.altrecipients.data, message_id=message.messageid, from_address=message.from_address, date=convert_date(message.timestamp, localtmz).strftime('%Y%m%d'), to_address=message.to_address, hostname=message.hostname, mid=message.id) try: task = process_quarantined_msg.apply_async( args=[job], queue=message.hostname) task.wait(30) if task.status == 'SUCCESS': # process response html = process_release_results( c, message, task.result, Session) self.invalidate = 1 message = self._get_msg(id, archive) flash(html) else: html = _('Processing the request failed') flash_alert(html) except (TimeoutError, QueueNotFound): html = _('Processing the request failed') flash_alert(html) if format == 'json': flash.pop_messages() response.headers['Content-Type'] = 'application/json' return json.dumps(dict(result=html)) elif request.POST and not c.form.validate(): flash_alert(_(u', '.join([unicode(c.form.errors[err][0]) for err in c.form.errors]))) if format == 'json': html = flash.pop_messages() response.headers['Content-Type'] = 'application/json' return json.dumps(dict(result=unicode(html[0]))) if format == 'json': response.headers['Content-Type'] = 'application/json' return json.dumps(message.tojson) c.msg = message c.archived = archive c.show_trail = show_trail c.msgstatus = msgstatus return render('/messages/detail.html')
def detail(self, msgid, archive=None, format=None): "return message detail" message = self._get_msg(msgid, archive) if not message: abort(404) msgstatus = Session.query(MessageStatus)\ .filter(MessageStatus.messageid == message.messageid)\ .all() show_trail = request.GET.get('t', None) c.form = ReleaseMsgForm(request.POST, csrf_context=session) if request.method == 'POST' and c.form.validate(): localtmz = config.get('baruwa.timezone', 'Africa/Johannesburg') job = dict(release=c.form.release.data, learn=c.form.learn.data, salearn_as=c.form.learnas.data, todelete=c.form.delete.data, use_alt=c.form.usealt.data, altrecipients=c.form.altrecipients.data, message_id=message.messageid, from_address=message.from_address, date=convert_date(message.timestamp, localtmz).strftime('%Y%m%d'), msgfiles=message.msgfiles, to_address=message.to_address, hostname=message.hostname, mid=message.id, issingle=True) try: task = process_quarantined_msg.apply_async( args=[job], routing_key=system_hostname() if asbool( config.get('ms.quarantine.shared', 'false')) else message.hostname) task.wait(30) if task.status == 'SUCCESS': # process response html = process_release_results(c, message, task.result, Session, self.render) self.invalidate = 1 message = self._get_msg(msgid, archive) flash(html) else: html = _('Processing the request failed') flash_alert(html) log.info(html) except (TimeoutError, QueueNotFound): html = _('Processing the request failed') flash_alert(html) log.info(html) if format == 'json': flash.pop_messages() response.headers['Content-Type'] = 'application/json' return json.dumps(dict(result=html)) elif request.method == 'POST' and not c.form.validate(): flash_alert( _(u', '.join([ unicode(c.form.errors[err][0]) for err in c.form.errors ]))) if format == 'json': html = flash.pop_messages() response.headers['Content-Type'] = 'application/json' return json.dumps(dict(result=unicode(html[0]))) if format == 'json': response.headers['Content-Type'] = 'application/json' return json.dumps(message.tojson) c.msg = message c.archived = archive c.show_trail = show_trail c.msgstatus = msgstatus return self.render('/messages/detail.html')