本文整理汇总了Python中models.Activity.put方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.put方法的具体用法?Python Activity.put怎么用?Python Activity.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import put [as 别名]
def get(self, *args):
respo = self.response.out.write
output = self.dbg
respo ("<html><head><title>Test</title></head><body>")
if (self.request.path.endswith('/clean')):
output ("Begin Clean Up")
self.cleanUp()
output ("Cleaning up done")
return
output("Now let's go")
billList = [('Cort', '75.5'), ('Balls', '15')]
output ("BillList: ", billList)
allacts = Activity.all()
for act in allacts:
bill = act.bill
for entry in bill:
output ("Entry:", entry, ",", lb = False)
output()
output ("acts:", act.key().id(), "Total Expense:", act.expense, "Expanse Bill: ", bill)
mem = Membership.all().get()
output ("New activity")
act = Activity(name = "test act", duration=2.0, organizer = mem.user, club = mem.club, bill = billList, expense = '100' )
output ("Expense:", act.expense)
output ("Bill:", act.bill)
output ("Now, put")
key = act.put()
output ("Act Saved: ", act.is_saved(), "Key is ", key, " Id is", key.id())
respo("</body></html>")
示例2: activities
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import put [as 别名]
def activities(request):
# Function to get all activities and handle POST request to add or edit
# an activity
response_params = {}
response_params['activities'] = models.Activity.all()
response_params['activity_form'] = ActivityForm()
# If the form is submitted
if request.method == "POST":
tags = request.POST['tags'].split(',')
tag_ids = []
for tag in tags:
if tag.strip() != '':
t = models.Tag.get_or_insert(key_name=tag)
tag_ids.append(t.key())
name = request.POST['name']
price = int(request.POST['price'])
duration_min = timedelta(seconds=floatToSeconds(float(request.POST['duration_min'])))
duration_max = timedelta(seconds=floatToSeconds(float(request.POST['duration_max'])))
# If we got an activity id from the request, we do an update instead of an add
if 'activity-id' in request.POST:
logging.info('edit an existing activity')
activity = Activity.get_by_id(int(request.POST['activity-id']))
activity.name = name
activity.price = price
activity.duration_min = duration_min
activity.duration_max = duration_max
activity.tags = tag_ids
activity.put()
else:
activity = Activity(name=name,price=price,duration_min=duration_min,duration_max=duration_max,tags=tag_ids)
activity.put()
return render_to_response('activities.html', response_params)