Example #1
0
 def post(self,
         request,
         user = '******',
         group = '@self',
         feature = None):
     group = group[:50]
     
     # load the json and validate format
     json_object = json.loads(request.body)
     user = get_user(request,
                     username = user)
     
     if user == None:
         return HttpResponseBadRequest('You need to create a session before creating features')
     
     elif user != request.user:
         return HttpResponseForbidden('You cannot create featues for other users')
     
     json_obj_response = {}
     
     new_feature = Feature(user = user,
                           group = group)
     new_feature.create(json_object)
     uri = "%s/%s/%s/%i" % (reverse('feat'),
                            user.username,
                            group,
                            new_feature.id)
     created_entity = json.dumps(new_feature.to_json())
     
     return HttpResponseCreated(uri, created_entity)
Example #2
0
 def post(self,
         request,
         user = '******',
         group = '@self',
         feature = None):
     group = group[:50]
     
     # load the json and validate format
     try:
         json_object = json.loads(request.body)
     except ValueError:
         send_error_mail(request,'This sould be json string but is not: %s\n\n' % request.body)
         return HttpResponseBadRequest('invalid json')
     user = get_user(request,
                     username = user)
     
     if user == None:
         return HttpResponseBadRequest('You need to create a session before creating features')
     
     elif user != request.user:
         return HttpResponseForbidden('You cannot create featues for other users')
     
     json_obj_response = {}
     
     new_feature = Feature(user = user,
                           group = group)
     new_feature.create(json_object)
     uri = "%s/%s/%s/%i" % (reverse('feat'),
                            user.username,
                            group,
                            new_feature.id)
     created_entity = new_feature.get_json_str()
     
     return HttpResponseCreated(uri, created_entity)
Example #3
0
from geonition_utils.models import JSON
from geonition_utils.models import TimeD

for key, value in data_dict.items():
    print key
    print value

    #create feature
    feature = value['feature']
    geometry = OGRGeometry(feature['geometry']).geos
    private = feature.get('private', True)
    user = User.objects.get(id = feature['user'])
    group = 'PP-perhela-perhelan-kortteli' #they are all put into the same group Jarvenpaa
    time = TimeD(create_time = feature['create_time'],
                 expire_time = feature['expire_time'])
    time.save()
    new_feature = Feature(geometry = geometry,
                          user = user,
                          group = group,
                          private = private,
                          time = time)
    new_feature.save()

    #create property
    timed = TimeD()
    timed.save()
    time = timed
    prop = Property()
    #self.properties.add(prop)