Project

General

Profile

Download (744 Bytes) Statistics
| Branch: | Tag: | Revision:

root / wcsinst / wcsinstd / views.py @ b9613248

1 9668dad8 Frédéric Péters
import json
2 b9613248 Benjamin Dauvergne
import logging
3 9668dad8 Frédéric Péters
4
from django.views.decorators.csrf import csrf_exempt
5
from django.views.decorators.http import require_POST
6
7
from jsonresponse import to_json
8
9
from .deploy import DeployInstance
10
11 b9613248 Benjamin Dauvergne
logger = logging.getLogger(__name__)
12 9668dad8 Frédéric Péters
13
@csrf_exempt
14 b9613248 Benjamin Dauvergne
@to_json('plain')
15 9668dad8 Frédéric Péters
@require_POST
16
def create(request):
17
    data = json.loads(request.body)
18
    deploy = DeployInstance(**data)
19 f3093ed1 Benjamin Dauvergne
    deploy.make()
20 9668dad8 Frédéric Péters
    return {}
21
22
23
@csrf_exempt
24 b9613248 Benjamin Dauvergne
@to_json('plain')
25 9668dad8 Frédéric Péters
@require_POST
26
def update(request, instance):
27
    print 'updating instance:', instance
28
    data = json.loads(request.body)
29
    if data.get('domain') != instance:
30
        raise Exception('domain mismatch') # -> should remove/add ?
31
    deploy = DeployInstance(**data)
32 f3093ed1 Benjamin Dauvergne
    deploy.make()
33 9668dad8 Frédéric Péters
    return {}