diff --git a/api/api.py b/api/api.py index eadc7dc..ab98156 100644 --- a/api/api.py +++ b/api/api.py @@ -64,22 +64,6 @@ def discord_notification(message='', embeds=None, ping=False): return None -def discord_webhook(webhook_name=None, message=None, embed=None, ping=False): - webhook = getattr(settings, 'DISCORD_{}_WEBHOOK'.format(webhook_name.upper()), getattr(settings, 'DISCORD_WEBHOOK', None)) - if webhook and (message or embed): - ping_list = getattr(settings, 'DISCORD_PING_LIST', []) - if ping and ping_list: - ping_list = ["<@&{0}>".format(ping) for ping in ping_list] - message = "{0}\n{1}".format(" ".join(ping_list), message) - data = {} - if message: - data['content'] = message - if embed: - data['embeds'] = embed - return requests.post(webhook, json=data) - return None - - def strip_format(message): return message.replace("§0", "").replace("§1", "").replace("§2", "").replace("§3", "").replace("§4", "") \ diff --git a/api/models.py b/api/models.py index 28948d8..5548bf1 100644 --- a/api/models.py +++ b/api/models.py @@ -2,6 +2,11 @@ from django.db import models from minecraft_manager.api.api import generate_password +class TokenManager(models.Manager): + def get_queryset(self): + return super(TokenManager, self).get_queryset().none() + + class Token(models.Model): key = models.CharField("Key", default=generate_password, max_length=50, unique=True) description = models.CharField("Description", max_length=200, blank=True) @@ -16,6 +21,8 @@ class Token(models.Model): model_post_permission = models.BooleanField("Model POST", default=False) stats_get_permission = models.BooleanField("Stats GET", default=False) stats_post_permission = models.BooleanField("Stats POST", default=False) + objects = models.Manager() + api = TokenManager() @property def display(self): diff --git a/docs/source/api.rst b/docs/source/api.rst index 3613d3a..f41d8a3 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -10,9 +10,9 @@ Model API --------- .. warning:: - You will need to pass the API password with any request in order for the API to respond. |br| - The API will only respond to an authenticated user or a request containing the correct API password. |br| - Send the password with the key ``api`` + You will need to pass a token with any request in order for the API to respond. |br| + The API will only respond to an authenticated user or a request containing a valid token. |br| + Send the token with the key ``api`` The model API is used to query any of the :ref:`models` and get back results in a JSON format. diff --git a/docs/source/models.rst b/docs/source/models.rst index 912d06d..757d221 100644 --- a/docs/source/models.rst +++ b/docs/source/models.rst @@ -153,11 +153,27 @@ Worlds ---- -Warning -------- +Ticket Note +----------- -Severity -~~~~~~~~ + +``author`` - User_ + +``ticket`` - Ticket_ + +``message`` - Text + +``last_update`` - DateTime + +``date`` - DateTime + +---- + +Note +---- + +Importance +~~~~~~~~~~ ``L`` - Low @@ -169,7 +185,7 @@ Severity ``message`` - Text -``severity`` - Severity_ +``importance`` - Importance_ ``staff`` - User_ @@ -197,28 +213,4 @@ Alert ``date`` - DateTime ----- - -Note ----- - -Notable -~~~~~~~ - - ``PL`` - Player Table - - ``TI`` - Ticket Table - - ``WA`` - Warning Table - -``author`` - User_ - -``ref_table`` - Notable_ - -``ref_id`` - Text (the ID of the row in the ``ref_table``) - -``message`` - Text - -``last_update`` - DateTime - -``date`` - DateTime \ No newline at end of file +---- \ No newline at end of file