本文整理汇总了Python中models.Place类的典型用法代码示例。如果您正苦于以下问题:Python Place类的具体用法?Python Place怎么用?Python Place使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Place类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_polling_centers
def add_polling_centers(state, filename):
d = {}
with db.transaction():
for ac_code, px_code, pb_code, name in read_csv(filename):
print "adding polling center", state.id, ac_code, px_code
if (ac_code, px_code) not in d:
key = "{0}/{1}/{2}".format(state.key, ac_code, px_code)
if not db.select("places", where="type='PX' AND key=$key", vars=locals()):
pb_key = "{0}/{1}/{2}".format(state.key, ac_code, pb_code)
pb = Place.find(pb_key)
lazy_insert("places", key=key, name=name, type="PX",
code=key.split("/")[-1],
state_id=state.id,
region_id=pb.region_id,
pc_id=pb.pc_id,
ac_id=pb.ac_id,
ward_id=pb.ward_id)
d[ac_code, px_code] = 1
commit_lazy_inserts()
with db.transaction():
for ac_code, px_code, pb_code, name in read_csv(filename):
key = "{0}/{1}/{2}".format(state.key, ac_code, px_code)
px = Place.find(key)
pb_key = "{0}/{1}/{2}".format(state.key, ac_code, pb_code)
db.update("places", px_id=px.id, where="key=$pb_key", vars=locals())
开发者ID:anandology,项目名称:voternet,代码行数:26,代码来源:loaddata.py
示例2: home
def home():
if 'email' not in session:
return redirect(url_for('login'))
form = AddressForm()
places = []
my_coordinates = (50.45146, 30.52187) #37.4221 -122.0844
if request.method == 'POST':
if form.validate() == False:
return render_template("home.html", form=form)
else:
address = form.address.data
p = Place()
my_coordinates =p.address_to_latlng(address)
places = p.query(address)
return render_template("home.html",
form=form,
my_coordinates=my_coordinates,
places=places)
elif request.method == 'GET':
return render_template("home.html",
form=form,
my_coordinates=my_coordinates,
places=places)
return render_template("home.html")
开发者ID:phonxis,项目名称:learning-flask,代码行数:31,代码来源:routes.py
示例3: home
def home():
if 'email' not in session:
return redirect(url_for('login'))
form = AddressForm()
places = []
my_coordinates = (37.4221, -122.0844)
if request.method == "POST":
if form.validate() == False:
return render_template("home.html", form=form)
else:
# get the address
address = form.address.data
# query for addresses nearby
p = Place()
my_coordinates = p.address_to_latlng(address)
places = p.query(address)
# return those results
return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
elif request.method == "GET":
return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
开发者ID:hershalb,项目名称:learning-flask,代码行数:28,代码来源:routes.py
示例4: query
def query(request):
if request.method == 'POST':
latitude_pass = request.POST.get('lat', None)
longitude_pass = request.POST.get('long', None)
else:
latitude_pass = request.GET.get('lat', None)
longitude_pass = request.GET.get('long', None)
if latitude_pass and longitude_pass:
now = datetime.utcnow().replace(tzinfo=tz.tzutc())
# guess[0] = place name, guess[1] = place lat, guess[2] = place longitude
guess = searchPlaces(latitude_pass, longitude_pass)
places = [obj.name for obj in Place.objects.all()]
# use it from db if already exist, otherwise create a new one
if guess[0] not in places:
predict = Place(name=guess[0], latitude=guess[1], longitude=guess[2], time=now)
predict.save()
else:
predict = Place.objects.get(name=guess[0])
Track(
latitude = latitude_pass,
longitude = longitude_pass,
prediction=predict,
time=now
).save()
return HttpResponse('GET successful')
else:
return redirect('/')
开发者ID:yyl,项目名称:track-map,代码行数:28,代码来源:views.py
示例5: home
def home():
if 'email' not in session:
return redirect(url_for('login'))
form = AddressForm()
places = []
my_coordinates = (5.3109351,-1.9924259)
if request.method == 'POST':
if form.validate() == False:
return render_template('home.html', form=form)
else:
# get the address
address = form.address.data
# query for places around it
p = Place()
my_coordinates = p.address_to_latlng(address)
places = p.query(address)
# return those results
return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
elif request.method == 'GET':
return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
开发者ID:paajake,项目名称:FlaskTest,代码行数:26,代码来源:FlaskTest.py
示例6: POST
def POST(self, place):
data = json.loads(web.data())['data']
for row in data:
code = place.key + "/" + row['code']
pb = Place.find(code)
if row['ward'] and row['ward'].strip():
# Extract te group code from its name
key = place.key + "/" + row['ward'].split("-")[0].strip()
ward = Place.find(key)
if pb.ward_id != ward.id:
pb.set_ward(ward)
else:
pb.set_ward(None)
if row['px'] and row['px'].strip():
# Extract te group code from its name
key = place.key + "/" + row['px'].split("-")[0].strip()
px = Place.find(key)
if pb.px_id != px.id:
pb.set_px(px)
else:
pb.set_px(None)
web.header("content-type", "application/json")
return '{"result": "ok"}'
开发者ID:anandology,项目名称:voternet,代码行数:27,代码来源:webapp.py
示例7: test_good_google_location_and_yelp
def test_good_google_location_and_yelp(self):
place = Place()
place.name = "Whole Foods"
place.location = '1240 Yale St, Santa Monica, CA 90404'
place.save()
self.assertEqual(place.yelp_id, 'hdQJrF3Fw_KrEaDywC3tyg')
self.assertEqual(len(Place.objects.all()), 1)
开发者ID:jflinter,项目名称:paleomaps,代码行数:7,代码来源:tests.py
示例8: createentrycontinue
def createentrycontinue(request):
title = request.POST['title'].replace(" ", "_")
location = request.POST['location']
comments = request.POST['details']
p = Place(name = title, location=location, details=comments)
p.save()
return render_to_response('places/createpagecontinue.html', {"placename": p.name}, context_instance=RequestContext(request))
开发者ID:TandZ,项目名称:Crowd,代码行数:7,代码来源:views.py
示例9: setUp
def setUp(self):
self.p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
self.p1.save()
self.p2 = Place(name='Ace Hardware', address='1013 N. Ashland')
self.p2.save()
self.r = Restaurant(place=self.p1, serves_hot_dogs=True, serves_pizza=False)
self.r.save()
开发者ID:ssaltzman,项目名称:POET,代码行数:7,代码来源:tests.py
示例10: get
def get(self):
place = Place(
name='Google',
location=ndb.GeoPt(lat=1.279,lon=103.85)
)
place.put()
self.redirect('/')
开发者ID:JLtheking,项目名称:singgest,代码行数:7,代码来源:main.py
示例11: save_place
def save_place( self, name, geojson ):
owner = self.auth.user.auth_id
place = Place( name=name, owner=owner, geojson=geojson )
place.put()
key = str( place.key() )
self.session['current_place'] = key
return {
'key': str( place.key() )
}
开发者ID:geary,项目名称:claslite,代码行数:9,代码来源:handlers.py
示例12: createNew
def createNew(request):
if request.method == 'POST':
payload = json.loads(request.body)
thisx, thisy = payload.get('location', None).split(',')
pnt = GEOSGeometry('POINT(%s %s)' % (thisx, thisy))
this_place = Place(name = payload.get('name', None), location = pnt)
this_place.save()
return HttpResponse('Success')
else:
return HttpResponseBadRequest('Missing POST data')
开发者ID:artagnon,项目名称:irale,代码行数:10,代码来源:views.py
示例13: place_page
def place_page(place_id=None):
if request.method == 'POST':
p = Place.get_by_id(place_id)
# for add subscriber form
if 'email' in request.form:
email = request.form.get('email', '')
if email not in [u.email for u in User.all()]:
u = User(
email=email,
suscribed_at=datetime.datetime.now())
u.put()
else:
u = User.gql("WHERE email = '{0}'".format(email)).get()
up = UserPlace.all().filter('user =', u).filter('place =', p).get()
if up:
return "This user already exists in subscribers!"
else:
if u.places_subscribed.count() >= 4:
return "This user has maximum subscribing"
up = UserPlace(
user=u,
place=p
)
up.put()
# for add update form
elif 'update_link' in request.form and 'update_info' in request.form:
update_link = request.form.get('update_link', '')
update_info = request.form.get('update_info', '')
u = Update(
place=p,
link=update_link,
info=update_info
)
u.put()
# for add link form
elif 'link_link' in request.form and 'link_description' in request.form:
link_link = request.form.get('link_link', '')
link_description = request.form.get('link_description', '')
l = PlaceLink(
place=p,
link=link_link,
description=link_description
)
l.put()
p = Place.get_by_id(place_id)
updates = [update for update in p.place_updates.order('-added_at')]
links = [link for link in p.placelink_set.order('-added_at')]
return render_template('place.html', place=p, updates=updates, links=links)
开发者ID:gromadco,项目名称:locograph,代码行数:55,代码来源:main.py
示例14: place_delete
def place_delete(place_id, place_key_str):
try:
pkey = Place.make_key(place_id, place_key_str)
cluster_ratings = ClusterRating.get_list({'place': pkey.urlsafe()})
for cr in cluster_ratings:
ClusterRating.delete(cr.key)
user_ratings = Rating.get_list({'place': pkey.urlsafe()})
for r in user_ratings:
Rating.delete(r.key)
res = Place.delete(pkey)
except TypeError, e:
return None, str(e), 400
开发者ID:sphoebs,项目名称:rockshell,代码行数:12,代码来源:logic.py
示例15: fillConsumingPlaces
def fillConsumingPlaces(response):
places = []
for i in response["results"]:
place = Place()
ID = i["place_id"]
place = getDetailsForID(ID, place)
place.reward = ""
pointsToSpend = random.randint(0, 100)
place.offerPoints = str(pointsToSpend)
place.offerText = "Get our special offer for " + place.offerPoints + " points"
place.placeType = "consuming"
places.append(place)
return places
开发者ID:ebarakos,项目名称:trip-quest,代码行数:13,代码来源:utils.py
示例16: POST_update_pcs
def POST_update_pcs(self, place, data):
for row in data:
key = place.key + "/" + row['code']
pc = Place.find(key)
if row['region'] and row['region'].strip():
# Extract te group code from its name
key = place.key + "/" + row['region'].split("-")[0].strip()
region = Place.find(key)
if pc.region_id != region.id:
pc.set_parent("REGION", region)
else:
pc.set_parent("REGION", None)
web.header("content-type", "application/json")
return '{"result": "ok"}'
开发者ID:anandology,项目名称:voternet,代码行数:15,代码来源:webapp.py
示例17: savePlace
def savePlace(request):
tokenId = request.GET["token"]
voiceId = request.GET["voiceId"]
placeId = request.GET["placeId"]
lat = request.GET["lat"]
lon = request.GET["lon"]
user = User.objects.get(tokenHash=tokenId)
voice = Voice.objects.get(sender=user, id=voiceId)
place = Place(voice=voice, placeId=placeId, latitude=lat, longitude=lon);
place.save()
return JsonResponse({"success" : "1" })
开发者ID:tanlah,项目名称:echoesapp-backend,代码行数:15,代码来源:views.py
示例18: test_simple_place_creation
def test_simple_place_creation(self):
"""
Creates test place
"""
places = Place.objects.filter(name = "Test Place")
[place.delete() for place in places]
place = Place()
place.name = "Test Place"
place.capacity = 20
place.save()
place = Place.objects.filter(name = "Test Place")
print place
self.assertNotEqual(place, None)
开发者ID:RadoRado,项目名称:checkin-at-fmi,代码行数:15,代码来源:tests.py
示例19: add_places
def add_places(self, user):
# Add 10 Places
places = [
'the CN Tower',
'the Eiffel Tower',
'Athens Greece',
'the Great Pyramids',
'the Great Wall of China',
'the Louvre',
'the Palace of Versailles',
'Sydney Australia',
'the Grand Canyon',
'Bora Bora'
]
self.response.out.write('<hr/>Adding places to go<hr/>')
# Get all list items for the current user
query = UserListItems.gql('WHERE user = :user', user=user)
user_list_items = query.get()
if user_list_items is None:
user_list_items = UserListItems(user=user)
for name in places:
place = Place()
place.title = name
place.put()
# Add Reference to the Place from User
user_list_item = UserListItem()
user_list_item.user = user
user_list_item.list_item = place
# Update the list of items the user has
user_list_items.list_items.append(place.key())
# Add the specifics of the user list item linkage
user_list_item = UserListItem()
user_list_item.user = user
user_list_item.list_item = place
one_year = datetime.timedelta(days=365)
today = datetime.datetime.today()
user_list_item.date_due = today + one_year
user_list_item.put()
self.response.out.write('Added %s<br/>' % place)
开发者ID:mpurdon,项目名称:Buckets,代码行数:48,代码来源:reset.py
示例20: get
def get(self):
user_id = logic.get_current_userid(self.request.cookies.get('user'))
if user_id is None:
self.redirect('/')
return
user, status, errcode = logic.user_get(user_id, None)
if status != "OK":
self.render("error.html", {'error_code': errcode, 'error_string': status, 'lang': LANG})
return
get_values = self.request.GET
if not get_values:
if user.role != 'admin':
self.redirect('/error')
else:
self.render('restaurant_list_edit.html',{'user': user, 'lang' : LANG});
else:
place_key = get_values.get('id')
place, status, errcode = logic.place_get(None, place_key)
if status == 'OK':
try:
place = Place.to_json(place, None, None)
self.render('restaurant_edit.html', {'place': place, 'hours_string': json.dumps(place['hours']), 'closed': json.dumps(place['days_closed']), 'user': user, 'lang' : LANG });
except TypeError, e:
# TODO: handle error
self.render("error.html", {'error_code': 500, 'error_string': str(e), 'lang': LANG})
return
else:
开发者ID:sphoebs,项目名称:rockshell,代码行数:27,代码来源:main.py
注:本文中的models.Place类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论