diff options
author | 2018-07-29 09:53:01 +0000 | |
---|---|---|
committer | 2018-07-29 09:53:01 +0000 | |
commit | c3cbadf64c1d568e957274e331241691de356f7f (patch) | |
tree | 3c41f029f67adda015590ed6553b1dbf30c2aabf /pysite/views/main/bot/cleanlog.py | |
parent | Fix typo in infractions table definition (diff) | |
parent | Addressing gdude comments (diff) |
Merge branch 'clean_command' into 'master'
Clean command API and frontend
See merge request python-discord/projects/site!26
Diffstat (limited to 'pysite/views/main/bot/cleanlog.py')
-rw-r--r-- | pysite/views/main/bot/cleanlog.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pysite/views/main/bot/cleanlog.py b/pysite/views/main/bot/cleanlog.py new file mode 100644 index 00000000..9c719b3e --- /dev/null +++ b/pysite/views/main/bot/cleanlog.py @@ -0,0 +1,35 @@ +import logging + +from pysite.base_route import RouteView +from pysite.constants import ALL_STAFF_ROLES, DEVELOPERS_ROLE, ROLE_COLORS +from pysite.decorators import require_roles +from pysite.mixins import DBMixin, OAuthMixin + +log = logging.getLogger(__name__) + + +class CleanLogView(RouteView, DBMixin, OAuthMixin): + path = "/bot/clean_logs/<log_id>" + name = "bot.clean_logs" + + table_name = "clean_logs" + template = "main/bot/clean_logs.html" + + @require_roles(ALL_STAFF_ROLES) + def get(self, log_id): + """ + Get the requested clean log and spit it out + in a beautiful template. + """ + + data = self.db.get(self.table_name, log_id) + + if data is None: + return "ID could not be found in the database", 404 + + messages = data["log_data"] + + for message in messages: + message['color'] = ROLE_COLORS.get(message['role_id'], ROLE_COLORS[DEVELOPERS_ROLE]) + + return self.render(self.template, messages=messages) |