2010-11-26 15:07:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
from __future__ import division
|
|
|
|
import os.path
|
|
|
|
import re
|
|
|
|
from datetime import datetime
|
|
|
|
from urllib2 import unquote
|
|
|
|
import mimetypes
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from django.core.paginator import Paginator
|
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.db.models import Q, Avg, Count, Sum
|
|
|
|
from django.http import HttpResponse, Http404
|
|
|
|
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404, redirect
|
|
|
|
from django.template import RequestContext
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
from ox.utils import json
|
|
|
|
from ox.django.decorators import login_required_json
|
|
|
|
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
|
|
|
from ox.django.http import HttpFileResponse
|
|
|
|
import ox
|
|
|
|
|
|
|
|
import models
|
2010-12-22 07:45:37 +00:00
|
|
|
from api.actions import actions
|
2010-11-26 15:07:24 +00:00
|
|
|
|
|
|
|
@login_required_json
|
2010-12-22 07:45:37 +00:00
|
|
|
def addLayer(request):
|
2010-11-26 15:07:24 +00:00
|
|
|
'''
|
|
|
|
param data
|
|
|
|
{key: value}
|
|
|
|
return {'status': {'code': int, 'text': string},
|
|
|
|
'data': {}}
|
|
|
|
'''
|
|
|
|
response = {'status': {'code': 501, 'text': 'not implemented'}}
|
|
|
|
return render_to_json_response(response)
|
2010-12-22 07:45:37 +00:00
|
|
|
actions.register(addLayer)
|
2010-11-26 15:07:24 +00:00
|
|
|
|
|
|
|
@login_required_json
|
2010-12-22 07:45:37 +00:00
|
|
|
def removeLayer(request):
|
2010-11-26 15:07:24 +00:00
|
|
|
'''
|
|
|
|
param data
|
|
|
|
{key: value}
|
|
|
|
return {'status': {'code': int, 'text': string},
|
|
|
|
'data': {}}
|
|
|
|
'''
|
|
|
|
response = {'status': {'code': 501, 'text': 'not implemented'}}
|
|
|
|
return render_to_json_response(response)
|
2010-12-22 07:45:37 +00:00
|
|
|
actions.register(removeLayer)
|
2010-11-26 15:07:24 +00:00
|
|
|
|
|
|
|
@login_required_json
|
2010-12-22 07:45:37 +00:00
|
|
|
def editLayer(request):
|
2010-11-26 15:07:24 +00:00
|
|
|
'''
|
|
|
|
param data
|
|
|
|
{key: value}
|
|
|
|
return {'status': {'code': int, 'text': string},
|
|
|
|
'data': {}}
|
|
|
|
'''
|
|
|
|
response = json_response({})
|
|
|
|
data = json.loads(request.POST['data'])
|
|
|
|
layer = get_object_or_404_json(models.Layer, pk=data['id'])
|
|
|
|
if layer.editable(request.user):
|
|
|
|
response = json_response(status=501, text='not implemented')
|
|
|
|
else:
|
|
|
|
response = json_response(status=403, text='permission denied')
|
|
|
|
return render_to_json_response(response)
|
|
|
|
|
|
|
|
response = json_response(status=501, text='not implemented')
|
|
|
|
return render_to_json_response(response)
|
2010-12-22 07:45:37 +00:00
|
|
|
actions.register(editLayer)
|
2010-11-26 15:07:24 +00:00
|
|
|
|