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


Python Event.get方法代码示例

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


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

示例1: edit_sub_event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def edit_sub_event( request ):
    if not users.is_current_user_admin():
        return HttpResponseRedirect('/')

    try:
        sekey = Key(request.POST['key'])
        se = Subevent.get(sekey)
        se.content = request.POST['content']
        pekey = memcache.get('event')
        pe = Event.get(pekey)
        # treat date from str to datetime type
        start_date = request.POST['start_date']
        li = start_date.split('-')
        se.start_date = datetime.date( int(li[0]),int(li[1]),int(li[2]))
       
        end_date = request.POST['end_date']
        li = end_date.split('-')
        se.end_date = datetime.date( int(li[0]),int(li[1]),int(li[2]))
        # adjust the parent event's start_date and end_date
        if se.start_date < pe.start_date:
            pe.start_date = se.start_date
        if se.end_date > pe.end_date:
            pe.end_date = se.end_date
        pe.put()
    except:
        return HttpResponse('error')
    
    if se.end_date < today():
        se.isexpired = True
    else:
        se.isexpired = False
    se.put()
    return HttpResponse( se.isexpired )
开发者ID:beachboysqq,项目名称:gansha,代码行数:35,代码来源:views.py

示例2: done_sub_event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def done_sub_event(request):
    if not users.is_current_user_admin():
        return HttpResponseRedirect('/')
    
    try:
        sekey = Key(request.POST['key'])
        pekey = memcache.get('event')
        is_done = request.POST['is_done']
    except:
        return HttpResponse('error')
    # update event,sub_event,history info
    se = Subevent.get(sekey)
    pe = Event.get(pekey)
    if is_done == 'true':
        se.is_done = True
        se.end_date = today()
        hi = History()
        hi.event = pe
        hi.content = "acomplished:"+se.content
        hi.put()
        #adjust parent event's progress
        pe.progress = pe.progress+100/pe.num_se
        if pe.progress == 100:
            pe.is_done = True
    else:
        se.is_done = False
        if pe.progress == 100:
            pe.is_done = False
        pe.progress = pe.progress-100/pe.num_se
    pe.put()
    se.put()   
    return HttpResponse( se.key() )
开发者ID:beachboysqq,项目名称:gansha,代码行数:34,代码来源:views.py

示例3: new_blog

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def new_blog(ekey,title,content,tags_str,is_public):
    blog = Blog()
    if ekey!='None':
        blog.event = Event.get(Key(ekey))
    blog.title = title
    blog.content = content
    blog.publish_time = now()
    blog.is_public = is_public 
    blog.put()
    add_tags( tags_str,blog )
    return blog
开发者ID:beachboysqq,项目名称:gansha,代码行数:13,代码来源:control.py

示例4: update_blog

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def update_blog( bkey,ekey,title,is_public,content,tags_str ):
    blog = Blog.get(Key(bkey))
    if ekey!='None':
        blog.event = Event.get(Key(ekey))
    
    blog.title = title
    blog.is_public = is_public
    blog.content = content
    blog.put()
        # update tags
    update_tags( blog,tags_str )
开发者ID:beachboysqq,项目名称:gansha,代码行数:13,代码来源:control.py

示例5: del_event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def del_event(request):
    if not users.is_current_user_admin():
        return HttpResponseRedirect('/')

    ekey = memcache.get('event')
    memcache.delete('event')
    event = Event.get(ekey)
    # delete sub events
    se_list = Subevent.gql("where event = :1",event)
    db.delete( se_list )
    
    event.delete()
    # delete relate history
    history_li = History.all().filter('event =',event)
    db.delete( history_li )
    
    return HttpResponse("deleted")
开发者ID:beachboysqq,项目名称:gansha,代码行数:19,代码来源:views.py

示例6: edit_event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def edit_event(request):
    if not users.is_current_user_admin():
        return HttpResponseRedirect('/')

    ekey = memcache.get('event')
    event = Event.get(ekey)
    
    if request.method == 'POST':
        event.is_public = request.POST['is_public'] =='1'
        event.title=request.POST['title'].strip()
        event.desc=request.POST['desc'].strip()
        event.put()
        return HttpResponseRedirect( '../event/?event=%s' % str(event.key()) )
    else:
        c = Context({
                  'logouturl':users.create_logout_url('/login'),
                  'is_admin':True,
                  'event':event,
                  })
        return render_to_response( 'newevent.htm',c )
开发者ID:beachboysqq,项目名称:gansha,代码行数:22,代码来源:views.py

示例7: event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def event(request):
    try:
        ekey = request.GET['event']
        # record the current event for further useage
    except KeyError:
        ekey = memcache.get('event')
        if not ekey:
            raise Http404
    
    event = Event.get(Key(ekey))
    memcache.set('event',event.key())

    # get sub event of this event
    se_list = Subevent.gql("where event = :1 order by start_date,end_date",event) 
    # check up wheather sub event is expired
    for se in se_list:
        if se.isexpired==False and se.end_date < today():
            se.isexpired = True
            se.put()
    # get host's history operation on this event
    history_li = History.all().filter('event =',event).order('-publish_time')
    # get blogs about this event
    blog_li = Blog.all().filter('event =',event )
    # get myevents
    myevents = Event.all()
    
    c = Context({
            'logouturl':LOGOUT,
            'loginurl':LOGIN,
            'cur_user':CURUSER,
            'is_admin':users.is_current_user_admin(),
            'event':event,
            'myevents':myevents,
            'se_list':se_list,
            'num_se':se_list.count(20),
            'history_li':history_li,
            'num_history_records':history_li.count(10),
            'blog_li':blog_li,
            'num_blogs':blog_li.count(100),
            })
    return render_to_response('event.htm',c)
开发者ID:beachboysqq,项目名称:gansha,代码行数:43,代码来源:views.py

示例8: add_sub_event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def add_sub_event(request):
    if not users.is_current_user_admin():
        return HttpResponseRedirect('/')

    pekey = memcache.get('event')
    if not pekey:
        return render_to_response('error.htm',{'error':'No memcache find,please login again!'})
    pe = Event.get(pekey)
    
    if request.method == 'POST':
        se = Subevent( event=pe,content=request.POST['content'].strip() )
        # treat date from str to datetime type
        start_date = request.POST['start_date']
        li = start_date.split('-')
        se.start_date = datetime.date( int(li[0]),int(li[1]),int(li[2]))
        
        end_date = request.POST['end_date']
        li = end_date.split('-')
        se.end_date = datetime.date( int(li[0]),int(li[1]),int(li[2]))
        # adjust the parent event's start_date and end_date
        if se.start_date < pe.start_date:
            pe.start_date = se.start_date
        if se.end_date > pe.end_date:
            pe.end_date = se.end_date
        # adjust progress of parent event,mutipled by 100
        pe.num_se +=1
        pe.progress = pe.progress*(pe.num_se-1)/pe.num_se
        pe.put()
        
        if se.end_date < today():
            se.isexpired = True
        else:
            se.isexpired = False
        se.put()
        return HttpResponse( se.key() )
    else:
        return HttpResponse("error")
开发者ID:beachboysqq,项目名称:gansha,代码行数:39,代码来源:views.py

示例9: del_sub_event

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import get [as 别名]
def del_sub_event(request):
    if not users.is_current_user_admin():
        return HttpResponseRedirect('/')
    try:
        sekey = Key(request.POST['key'])
        pekey = memcache.get('event')
    except:
        return HttpResponse('error')
    
    se = Subevent.get(sekey)
    pe = Event.get(pekey)
    pe.num_se -=1
    if pe.num_se!=0:
        pe.progress = pe.progress*(pe.num_se+1)/pe.num_se
    else:
        pe.progress = 0
        
    if pe.start_date == se.start_date:
        pe.start_date = Subevent.all().order('start_date').get().start_date
    if pe.end_date == se.end_date:
        pe.end_date = Subevent.all().order('-end_date').get().end_date
    pe.put()
    se.delete()
    return HttpResponse( str(sekey) )
开发者ID:beachboysqq,项目名称:gansha,代码行数:26,代码来源:views.py


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