Updated docs

Created API filter for Token model
reminder
Etzelia 2018-12-13 15:37:07 -06:00
parent 02ab21aafc
commit 229bfffb58
4 changed files with 32 additions and 49 deletions

View File

@ -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", "") \

View File

@ -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):

View File

@ -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.

View File

@ -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
----