def admin(): auth.require(role='submit', fail_redirect='/sorry_page') context = {} username = auth.current_user.username if request.query.function == "install" and auth.current_user.role == "admin": import core.install if request.query.function == "backup": from core.admin_function import adFunction adFunction().archive() if request.query.function == "reset" and auth.current_user.role == "admin": from core.admin_function import adFunction adFunction().reset() if request.query.function == "Delete": start = int(request.query.start) if request.query.end == "": from core.admin_function import recordTools recordTools().removeRecord(start) logging.info('Record %s Deleted by %s', start, username) return "Record %s was succesfully removed" % (start) else: end = int(request.query.end) + 1 from core.admin_function import recordTools for delete in range(start, end): recordTools().removeRecord(delete) logging.info('Record %s Deleted by %s', delete, username) return "Record %s to %s was succesfully removed" % (start, end) if os.path.exists(os.path.join(MaildbRoot, "maildb.log")): logFile = open(os.path.join(MaildbRoot, "maildb.log")) else: logFile = "*" # Lazy fix for an empty Log File template = lookup.get_template("admin.html") return template.render(logFile=logFile, **context)
def export(): context = {} if request.query_string: msg_id = request.query.msg_id fileID = request.query.fileID from core.admin_function import recordTools recordTools().exportDir(msg_id, fileID) return static_file('Export.zip', root=os.path.join(MaildbRoot, "web", "static"), download='Export.zip')
def adminPost(): msg_id = request.forms.msg_id from core.admin_function import recordTools recordTools().removeRecord(msg_id) return "Task no %s was succesfully removed" % (msg_id)