Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.8.5'
Browse files Browse the repository at this point in the history
# Conflicts:
#	sourcemod/addons/sourcemod/plugins/hawthorne.smx
  • Loading branch information
indietyp committed Jun 8, 2018
2 parents 4897420 + 9d7850d commit d027080
Show file tree
Hide file tree
Showing 56 changed files with 719 additions and 1,214 deletions.
4 changes: 2 additions & 2 deletions ajax/views/ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from django.views.decorators.http import require_http_methods

from ajax.views import renderer
from core.models import Ban
from core.models import Punishment


@login_required(login_url='/login')
@permission_required('core.view_ban')
@require_http_methods(['POST'])
def user(request, page, *args, **kwargs):
obj = Ban.objects.filter(resolved=False).order_by('created_at')
obj = Punishment.objects.filter(resolved=False, is_banned=True).order_by('created_at')
return renderer(request, 'partials/ban/user.pug', obj, page)
7 changes: 5 additions & 2 deletions ajax/views/mutegag.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from django.contrib.auth.decorators import login_required, permission_required
from django.views.decorators.http import require_http_methods
from django.db.models import Q

from ajax.views import renderer
from core.models import Mutegag
from core.models import Punishment


@login_required(login_url='/login')
@permission_required('core.view_mutegag')
@require_http_methods(['POST'])
def user(request, page, *args, **kwargs):
obj = Mutegag.objects.filter(resolved=False).order_by('created_at')
obj = Punishment.objects.filter(resolved=False)\
.filter(Q(is_muted=True) | Q(is_gagged=True))\
.order_by('created_at')
return renderer(request, 'partials/mutegag/user.pug', obj, page)
72 changes: 34 additions & 38 deletions api/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,54 +45,45 @@
'role': {'type': 'uuid', 'default': None, 'nullable': True, 'required': False}},
'permission': ['core.delete_user']}
},
'ban': {
'punishment': {
'GET': {'parameters': {'server': {'type': 'uuid', 'nullable': True, 'default': None},
'resolved': {'type': 'boolean', 'nullable': True, 'default': None}},
'permission': ['core.view_ban']},
'resolved': {'type': 'boolean', 'nullable': True, 'default': None},
'banned': {'type': 'boolean', 'nullable': True, 'default': None},
'kicked': {'type': 'boolean', 'nullable': True, 'default': None},
'muted': {'type': 'boolean', 'nullable': True, 'default': None},
'gagged': {'type': 'boolean', 'nullable': True, 'default': None}},
'permission': ['core.view_punishment']},
'POST': {'parameters': {'server': {'type': 'uuid', 'required': True},
'resolved': {'type': 'boolean', 'nullable': True, 'default': None},
'reason': {'type': 'string', 'nullable': True, 'default': None},
'length': {'type': 'integer', 'nullable': True, 'default': None}},
'permission': ['core.change_ban']},
'length': {'type': 'integer', 'nullable': True, 'default': None},
'banned': {'type': 'boolean', 'nullable': True, 'default': None},
'kicked': {'type': 'boolean', 'nullable': True, 'default': None},
'muted': {'type': 'boolean', 'nullable': True, 'default': None},
'gagged': {'type': 'boolean', 'nullable': True, 'default': None}},
'permission': ['core.change_punishment']},
'PUT': {'parameters': {'server': {'type': 'uuid', 'required': False},
'reason': {'type': 'string', 'required': True},
'reason': {'type': 'string', 'required': True, 'default': 'Powered by Hawthorne'},
'length': {'type': 'integer', 'required': True},
'issuer': {'type': 'integer', 'default': None, 'nullable': True, 'required': False},
'plugin': {'type': 'boolean', 'default': True}},
'permission': ['core.add_ban']},
'DELETE': {'parameters': {'server': {'type': 'uuid', 'nullable': True, 'default': None}},
'permission': ['core.delete_ban']},
'plugin': {'type': 'boolean', 'default': True},
'muted': {'type': 'boolean', 'default': False},
'banned': {'type': 'boolean', 'default': False},
'kicked': {'type': 'boolean', 'default': False},
'gagged': {'type': 'boolean', 'default': False}},
'permission': ['core.add_punishment']},
'DELETE': {'parameters': {'server': {'type': 'uuid', 'nullable': True, 'default': None},
'length': {'type': 'integer', 'nullable': True, 'default': None},
'banned': {'type': 'boolean', 'nullable': True, 'default': None},
'kicked': {'type': 'boolean', 'nullable': True, 'default': None},
'muted': {'type': 'boolean', 'nullable': True, 'default': None},
'gagged': {'type': 'boolean', 'nullable': True, 'default': None},
'plugin': {'type': 'boolean', 'default': True}},
'permission': ['core.delete_punishment']},
},
'kick': {
'PUT': {'parameters': {'server': {'type': 'uuid', 'required': True}},
'permission': ['core.kick_user']},
},
'auth': {
'GET': {'parameters': {'password': {'type': 'string', 'required': True}},
'permission': ['core.view_user']},
},
'mutegag': {
'GET': {'parameters': {'server': {'type': 'uuid', 'nullable': True, 'default': None},
'resolved': {'type': 'boolean', 'nullable': True, 'default': None}},
'permission': ['core.view_mutegag']},
'POST': {'parameters': {'server': {'type': 'uuid', 'required': False},
'resolved': {'type': 'boolean', 'nullable': True, 'default': None},
'type': {'type': 'string', 'allowed': ['mute', 'gag', 'both'], 'default': 'both',
'coerce': utils.lower},
'reason': {'type': 'string', 'nullable': True, 'default': None},
'length': {'type': 'integer', 'nullable': True, 'default': None}},
'permission': ['core.change_mutegag']},
'PUT': {'parameters': {'server': {'type': 'uuid', 'required': False},
'reason': {'type': 'string', 'required': True},
'type': {'type': 'string', 'allowed': ['mute', 'gag', 'both'], 'default': 'both',
'coerce': utils.lower},
'length': {'type': 'integer', 'required': True},
'plugin': {'type': 'boolean', 'default': True}},
'permission': ['core.add_mutegag']},
'DELETE': {'parameters': {'server': {'type': 'uuid', 'nullable': True, 'default': None},
'plugin': {'type': 'boolean', 'default': True}},
'permission': ['core.delete_mutegag']},
}
},
'group': {
'list': {
Expand Down Expand Up @@ -212,7 +203,12 @@
'permission': ['core.view_token']},
'DELETE': {'parameters': {},
'permission': ['core.delete_token']},
}
},
'authentication': {
'POST': {'parameters': {'username': {'type': 'string', 'required': True},
'password': {'type': 'string', 'required': True}},
'permission': ['core.view_user']},
},
},
'steam': {
'search': {
Expand Down
8 changes: 4 additions & 4 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
path('users', user.list, name='user.list'),
path('users/<uuid:u>', user.detailed, name='user.detailed'),
path('users/<steamid:s>', user.detailed, name='user.detailed'),
path('users/<uuid:u>/auth', user.auth, name='user.auth'),
path('users/<uuid:u>/ban', user.ban, name='user.ban'),
path('users/<uuid:u>/kick', user.kick, name='user.kick'),
path('users/<uuid:u>/mutegag', user.mutegag, name='user.mutegag'),
path('users/<uuid:u>/punishment', user.punishment, name='user.punishment'),

# groups
path('groups', group.list, name='group.list'),
Expand All @@ -36,6 +33,9 @@
path('system/chat', system.chat, name='system.chat'),
path('system/tokens', system.token, name='system.token'),
path('system/tokens/<uuid:t>', system.token_detailed, name='system.token[detailed]'), # GET, DELETE
path('system/authentication', system.authentication, name='system.authentication'),
path('system/messages', system.chat, name='system.chat'),
path('system/logs', system.chat, name='system.chat'),

# steam
path('steam/search', steam.search, name='steam.search'),
Expand Down
15 changes: 15 additions & 0 deletions api/views/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,18 @@ def token_detailed(request, t=None, validated={}, *args, **kwargs):
}
else:
token.delete()


@csrf_exempt
@json_response
@authentication_required
@permission_required('system.authentication')
@validation('system.authentication')
@require_http_methods(['POST'])
def authentication(request, validated={}, *args, **kwargs):
from django.contrib.auth import authenticate
user = authenticate(username=validated['username'], password=validated['password'])
if user is not None:
return [], 200
else:
return [], 401
Loading

0 comments on commit d027080

Please sign in to comment.