コード例 #1
0
ファイル: tests.py プロジェクト: sz-2013/sz
 def setUp(self):
     models.Place.objects.all().delete()
     self.user = models.User.objects.get_or_create(
         **get_full_user_data())[0]
     self.params = dict(latitude=LATITUDE, longitude=LONGITUDE,
                        radius=RADIUS, user=self.user)
     places = place_service.explore_in_venues(**self.params)
     [p.create_in_engine() for p in places]
コード例 #2
0
ファイル: places.py プロジェクト: beebikun/sz2013
 def get(self, request, format=None):
     params = self.validate_and_get_params(forms.PlaceExploreRequestForm,
                                           request.QUERY_PARAMS)
     params[u'creator'] = request.user.email  if not LEBOWSKI_MODE_TEST \
         else request.QUERY_PARAMS.get('email')
     place_response = map(self._serialize_item,
                          place_service.explore_in_venues(**params))
     data = dict(places=place_response)
     if place_response:
         #@TODO - change it when bl will be answer normal stuff
         engina_data = lebowski_places.PlacesCreate().create(place_response)
         if LEBOWSKI_MODE_TEST:
             data['bl'] = engina_data
             status = 200
         else:
             status = engina_data['status']
         return sz_api_response.Response(data, status=status)
     return sz_api_response.Response(data)
コード例 #3
0
ファイル: places.py プロジェクト: beebikun/sz2013
 def get(self, request,format=None):
 	params = self.validate_and_get_params(
         forms.PlaceExploreRequestForm, request.QUERY_PARAMS)
     params[u'creator'] = request.user.email  if not LEBOWSKI_MODE_TEST \
         else request.QUERY_PARAMS.get('email')        
     place_response =  map(self._serialize_item, 
         place_service.explore_in_venues(**params))
     data = dict(places = place_response)
     if place_response:
         #@TODO - change it when bl will be answer normal stuff
         engina_data = lebowski_places.PlacesCreate().create(place_response)            
         if LEBOWSKI_MODE_TEST:
             data['bl'] = engina_data
             status = 200
         else:
             status = engina_data['status']
         return sz_api_response.Response(data,status=status)
     return sz_api_response.Response(data)  
コード例 #4
0
ファイル: places.py プロジェクト: sz-2013/sz
 def get(self, request, format=None):
     params = self.validate_req_params(request.QUERY_PARAMS)
     creator = request.user
     params['user'] = creator
     places_list = place_service.explore_in_venues(**params)
     user_data = serializers.UserStandartDataShortSerializer(
         instance=creator).data
     places_len = len(places_list)
     code = status.HTTP_200_OK
     if places_len:
         places_len = 0
         bl_data = user_data
         bl_data['user_longitude'] = params.get('latitude')
         bl_data['user_latitude'] = params.get('longitude')
         places_list = map(
             lambda p: serializers.PlaceStandartDataSerializer(
                 instance=p).data,
             places_list)
         places_tuples = map(
             lambda data: (str(data.get('place_id')), data), places_list)
         bl_data['places'] = dict(places_tuples)
         engine_answer = posts.Place.create(bl_data)
         code = engine_answer.get("status")
         engine_data = engine_answer.get("data", {})
         if code != status.HTTP_201_CREATED:
             return sz_api_response(status=code, data=engine_data)
         user_data = engine_data.get("user")
         for p_id, p_data in engine_data.get('places', {}).iteritems():
             s = serializers.PlaceStandartDataSerializer(data=p_data)
             if s.is_valid():
                 s.object.create_in_engine(p_data)
                 places_len += 1
         gamemap_service.update_gamemap(params)
         # code = status.HTTP_201_CREATED
         # gamemap_service.update_gamemap(params)
     return sz_api_response(
         data=dict(user=user_data, places_explored=places_len), status=code)