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


Python Event.prologue方法代码示例

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


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

示例1: add

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import prologue [as 别名]
def add(request):

    context = {}
    context['mapHeight'] = 500
    context['mapWidth'] = 940
    context['mapCenterLat'] = 48.998465
    context['mapCenterLng'] = 21.239812
    context['mapZoomLevel'] = 13

    grounds = []
    for grnd in ground.objects.all():
        grounds.append(grnd)
        context['grounds'] = grounds

    saved = None

    user = User.objects.get(id=request.user.id)

    if request.method == 'POST':
        form = NewForm(request.POST, files=request.FILES)

        if form.is_valid():
            event = Event(title = form.cleaned_data['title'])

            startDate = form.cleaned_data['startOfActionDate']
            startTime = form.cleaned_data['startOfActionTime']
            splitStartDate = startDate.split(".")
            splitStartTime = startTime.split(":")
            event.startOfAction = datetime.datetime(int(splitStartDate[2]), int(splitStartDate[1]), int(splitStartDate[0]),
                                              int(splitStartTime[0]), int(splitStartTime[1]))

            event.published = datetime.datetime.now()
            event.numberOfPlayers = form.cleaned_data['numberOfPlayers']

            if form.data.get("loginCheckBox") == "on":
                event.login_since = datetime.datetime.now()
            else:
                loginDate = form.cleaned_data['login_sinceDate']
                loginTime = form.cleaned_data['login_sinceTime']
                splitLoginDate = loginDate.split(".")
                splitLoginTime = loginTime.split(":")
                event.login_since = datetime.datetime(int(splitLoginDate[2]), int(splitLoginDate[1]), int(splitLoginDate[0]),
                                                  int(splitLoginTime[0]), int(splitLoginTime[1]))

            event.prologue = form.cleaned_data['prologue']
            event.scenario = form.cleaned_data['scenario']
            event.organizationNotes = form.cleaned_data['organizationNotes']

            durationTime = form.cleaned_data['duration']
            splitDurationTime = durationTime.split(":")

            event.duration = datetime.time(int(splitDurationTime[0]), int(splitDurationTime[1]), 0)
            event.entryFee = form.cleaned_data['entryFee']
            event.author = user
            #event.ground = form.cleaned_data['ground']
            event.locationLat = form.data['Latitude']
            event.locationLng = form.data['Longitude']
            event.titleImage = form.cleaned_data['titleImage']
            event.published = datetime.datetime.now()
            groundId = int(form.data['groundId'])
            if (groundId > 0):
                event.ground = ground.objects.get(id=groundId)

            event.save()
            event.users.add(user.player)
            return HttpResponseRedirect('/events/detail/' + str(event.id))
        else:
            context['form'] = form
            context['fail'] = True
            return render_to_response('event/newEvent.html', context, context_instance=RequestContext(request))
    else:
        form = NewForm()
        context['form'] = form
        context['saved'] = saved
        return render_to_response('event/newEvent.html', context, context_instance=RequestContext(request))
开发者ID:petonet,项目名称:webove_technologie,代码行数:77,代码来源:views.py


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