本文整理汇总了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))