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


Python Activity.put方法代码示例

本文整理汇总了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>")
开发者ID:cardmaster,项目名称:makeclub,代码行数:33,代码来源:test.py

示例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)
开发者ID:noio,项目名称:Plan-a-Date,代码行数:40,代码来源:views.py


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