当前位置: 首页>>代码示例>>Python>>正文


Python Location.name方法代码示例

本文整理汇总了Python中models.Location.name方法的典型用法代码示例。如果您正苦于以下问题:Python Location.name方法的具体用法?Python Location.name怎么用?Python Location.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Location的用法示例。


在下文中一共展示了Location.name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: location_list

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def location_list(request):
    if request.method == 'GET':
        return get_location_list()

    if request.method == 'POST':
        if not request.user.is_authenticated(request):
            return HttpResponse('Unauthorized', status=401)
        
        data = json.loads(request.body)
        l = None
        if not data.get('id'):
            l = Location(user=request.user, data=json.dumps(data), name=data['name'])
            l.save()
            data["id"] = l.id
            l.data = json.dumps(data)
            l.save()
        else:
            l = Location.objects.get(pk=int(data['id']))
            if (request.user.is_staff == False):
                if (l.user.pk != request.user.pk):
                    return HttpResponse(json.dumps({'error': 'not authorized'}), content_type="application/json")
            l.data = json.dumps(data)
            l.name = data['name']
            l.save()
        return HttpResponse(json.dumps(l.data), content_type="application/json")



    return HttpResponse(json.dumps({'error': 'must be get or post request'}), content_type="application/json")
开发者ID:fresk,项目名称:counties_api,代码行数:31,代码来源:views.py

示例2: take_suggestions

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def take_suggestions():
	if os.path.exists(LATESTFILE_SUG):
		fp = open(LATESTFILE_SUG)
		lastid = fp.read().strip()
		fp.close()
		
		if lastid == '':
			lastid = 0
	else:
		lastid = 0
		
	result = api.GetMentions(since_id = lastid)
	#No mention, no suggestion
	print lastid
	if len(result) == 0:
		print "No mention received"
		return []
	else :
		fp = open(LATESTFILE_SUG, 'w')
		fp.write(str(max([x.id for x in result])))
		fp.close()
		entry = History.query.descending('mongo_id').first()
		for x in result:
			print x.text
		#Somebody already suggested..
		if entry.next_location.name != entry.suggested_location.name :
			print "There already is a suggestion. Fitz is currently headed to "+entry.next_location.name
			return []
		else :
			candidates = {}
			#Walk through all the mentions we got here..
			
			for x in result :
				mention_entry = x.text.split(' ')
				s_user = x.user.screen_name
				#Locations have to be proposed in a form of "Check out ***"
				if mention_entry[1] == 'Check' and mention_entry[2] == 'out':
					s_key = s_user + ":" + ' '.join(mention_entry[3:])
					s_geo = geocoder(' '.join(mention_entry[3:]))
					distance = gcd(entry.next_location.geocode[0], entry.next_location.geocode[1], s_geo[1], s_geo[2])
					candidates[s_key] = distance
			#Got somethin' but no useful words
			if len(candidates) == 0:
				print "Got some words, but no suggestions.."
				return []
			#Got somewhere to go!
			else :
				next_move = min(candidates, key=candidates.get)
				print candidates[candidates.keys()[0]] > candidates[candidates.keys()[1]]
				print next_move		
				l = Location()
				l.name = next_move.split(':')[1]
				l.geocode = geocoder(next_move.split(':')[1])[1:]
				entry.suggested_location = l
				entry.suggested_by = next_move.split(':')[0]
				entry.save()
				user_sug = []
				user_sug.append(next_move.split(':')[0])
				user_sug.append(next_move.split(':')[1])
				return user_sug
开发者ID:soloture,项目名称:wanderer,代码行数:62,代码来源:bot.py

示例3: add_location

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def add_location(data, location_key=""):
    if location_key:
        location = Location.get_by_id(location_key)
    else:
        location_id = slugify(data["name"])
        temp_location_id = location_id
        while True:
            count = 1
            if Location.get_by_id(temp_location_id):
                temp_location_id = location_id + str(count)
                count += 1
            else:
                location = Location(id=temp_location_id)
                break

    if data["name"]:
        location.name = data["name"]

    if data["needs"]:
        location.needs = data["needs"]

    if data["centers"]:
        location.centers = data["centers"]

    if data["latlong"]:
        location.latlong = data["latlong"]

    if data["featured_photo"]:
        location.featured_photo = data["featured_photo"]

    if data["death_count"]:
        location.death_count = int(data["death_count"])

    if data["death_count_text"]:
        location.death_count_text = data["death_count_text"]

    if data["affected_count"]:
        location.affected_count = int(data["affected_count"])

    if data["affected_count_text"]:
        location.affected_count_text = data["affected_count_text"]

    if data["status_board"]:
        location.status_board = data["status_board"]

    if data["needs"]:
        location.needs = data["needs"]

    if data["status"]:
        location.status = data["status"]

    if data["images"]:
        location.images = data["images"]

    if data["hash_tag"]:
        location.hash_tag = data["hash_tag"]

    location.put()
    return location
开发者ID:rileonard15,项目名称:bangonph,代码行数:61,代码来源:functions.py

示例4: suggest

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def suggest():
	entry = History.query.descending('mongo_id').first()
	suggested_point = app.config['SUGGESTED_POINT']
	geocode = geocoder(suggested_point)
	location = Location()
	location.name = geocode[0]
	location.geocode = (geocode[1],geocode[2])
	entry.suggested_location = location
	entry.save()
	return suggested_point + " suggested!"
开发者ID:soloture,项目名称:wanderer,代码行数:12,代码来源:views.py

示例5: add_location

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def add_location(request, loc_type, map_source ="google-maps", visibility = "private"):
    location = Location(owner = users.get_current_user(), 
                            map_source =map_source, loc_type = loc_type)
    location.visibility = visibility
    
    if loc_type == "extent":
        location.name = request.get('loc-name')
        location.latitude = float(request.get('latitude'))
        location.longitude =float(request.get('longitude'))
        location.zoom = int(request.get('zoom'))
    elif loc_type == "point":
        location.name = request.get('point-name')
        location.latitude = float(request.get('latitude-point'))
        location.longitude =float(request.get('longitude-point'))
        location.zoom = int(request.get('zoom-point'))
    tkn = location.buildToken()
    location.token = tkn
        
    location.put()
    return location.toJSON()
开发者ID:luiscberrocal,项目名称:pygooglemaps,代码行数:22,代码来源:googlemaps.py

示例6: post

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
  def post(self, request_id):
    location = self.request.get('location')
    # Get request
    request = ndb.Key(urlsafe=request_id).get()
    location = location.split('^')

    # Check if location has been previously used
    existing_location = Location.query(Location.name == location[0], Location.address == location[1]).get()
    if existing_location is None:
      # Add new location
      categories = location[3].split(',')
      coordinates = location[4].split(' ')
      new_location = Location()
      new_location.name = location[0]
      new_location.address = location[1]
      new_location.image_url = location[2]
      for c in categories:
        new_location.categories.append(c)
      new_location.longitude = float(coordinates[0])
      new_location.latitude = float(coordinates[1])
      new_location.put()
      
    else:
      new_location = existing_location

    if request != None:
      # Check if already appended
      add = True
      if len(request.bidders) > 0:
        for bid in request.bidders:
          bid = bid.get()
          if bid.name == self.user_model.username:
            print "Already bid"
            add = False
      if add is True:
          print "Haven't bid"
          bidder = Bidder()
          bidder.sender = self.user_model.key
          bidder.location = new_location.key
          bidder.name = self.user_model.username
          bidder.bid_time = datetime.datetime.now() - datetime.timedelta(hours=8)
          bidder.price = request.price
          bidder.put()
          request.bidders.append(bidder.key)
          request.status = "pending"
          request.put()
    else:
      print "Already connected"

    self.redirect('/feed')
开发者ID:Qiwis,项目名称:foodie,代码行数:52,代码来源:foodie_requests.py

示例7: addlocation

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def addlocation(request):
    request.session.set_expiry(0)
    
    location = Location()
    location.name = request.POST['name']
    location.locationImg = request.POST['locationImg']
    location.description = request.POST['description']
    location.locationLink = request.POST['locationLink']
    location.longitude = request.POST['longitude']
    location.latitude = request.POST['latitude']
    user_id = request.POST['sel1']
    userUser = User.objects.get(id = user_id)
    user = User_Regular.objects.get(user = userUser)
    location.owner = user
    location.save() 

    return redirect('admin')
开发者ID:dkeske,项目名称:KutijaSajt,代码行数:19,代码来源:views.py

示例8: create_location

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
def create_location():
	form = LocationForm()
	if form.validate_on_submit():
		location = Location()
		location.name = form.name.data
		location.capacity = form.capacity.data
		location.country = form.country.data
		location.zipcode = form.zipcode.data
		location.city = form.city.data
		location.street = form.street.data
		
		location.address_additions = form.address_additions.data
		location.google_maps_url = form.google_maps_url.data
		
		db_session.add(location)
		db_session.commit()
		return redirect(url_for('list_locations'))
	return render_template("admin/create_location.html", form=form)
开发者ID:miku,项目名称:evreg,代码行数:20,代码来源:app.py

示例9: INTEREST

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import name [as 别名]
#
# POINTS OF INTEREST (YELP)
#

# we do just the normal points of interest first, not groceries/parks/etc

os.chdir(os.path.join(data_base, 'yelp'))

points_of_interest = []

with open('yelp_all_processed.json', 'r') as f:
	dct = json.load(f)

for i, e in enumerate(dct):
	l = Location()
	l.name = e['name']
	l.rank = i + 1
	l.rating = e['rating']
	l.review_count = e['review_count']
	l.address = e['address'][0]
	l.categories = e['categories']
	l.geom = 'POINT ({:.8f} {:.8f})'.format(e['longitude'], e['latitude'])
	points_of_interest.append(l)

db_session.add_all(points_of_interest)
db_session.commit()




开发者ID:rachaelk,项目名称:huawei-rachael,代码行数:28,代码来源:data_to_postgis.py


注:本文中的models.Location.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。