本文整理汇总了Python中models.Event.author方法的典型用法代码示例。如果您正苦于以下问题:Python Event.author方法的具体用法?Python Event.author怎么用?Python Event.author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.author方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _save_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import author [as 别名]
def _save_event(self, event):
"""Save the given event"""
uid = event['id']
try:
local_event = Event.objects.get(uid=uid)
except:
local_event = Event(uid=uid)
local_event.calendar = self.gcal
local_event.author = event['creator']
local_event.title = event['summary']
local_event.description = event.get('description', None)
local_event.location = event.get('location', None)
try:
local_event.start = parse(event['start']['dateTime'])
except:
local_event.start = parse(event['start']['date'])
try:
local_event.end = parse(event['end']['dateTime'])
except:
local_event.end = parse(event['end']['date'])
status = 'active'
if event['status'] == 'cancelled':
status = 'cancelled'
local_event.status = status
local_event.save()
return local_event
示例2: events
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import author [as 别名]
def events(id=None):
if id:
event = Event.objects.get(pk=id)
event.update_timezone()
add_form = EventForm(request.form, obj=event)
title_aside = u'Éditer l\'événement'
else:
event = Event()
add_form = EventForm()
title_aside = u'Créer un événement'
if add_form.organisations.data:
add_form.organisations.choices = make_choices(add_form.orgas_choices, selected=add_form.organisations.data, name='Organisations')
if add_form.places.data:
add_form.places.choices = make_choices(add_form.places_choices, selected=add_form.places.data, name='Lieux')
if add_form.validate_on_submit():
event.title = add_form.title.data
event.description = add_form.description.data
event.organisations = add_form.organisations.data
event.places = add_form.places.data
if not event.author:
event.author = current_user.to_dbref()
event.datetime_first = arrow.get(add_form.datetime_first.data).datetime
event.datetime_last = arrow.get(add_form.datetime_last.data).datetime
event.update_timezone()
if current_user.has_role('Administrateur') or current_user.has_role('Éditeur'):
event.status = 'published' if 'publish' in request.form else 'draft'
else:
event.status = 'validation' if 'publish' in request.form else 'draft'
event.save()
if id:
return redirect('/events')
# Filter the events for non-admin users
if not current_user.has_role('Administrateur'):
filter_role = {'organisations__in': current_user.associations}
else:
filter_role = {}
today = arrow.now().date()
events_draft = Event.objects(status='draft', **filter_role).order_by('datetime_first')
events_validation = Event.objects(status='validation', datetime_first__gte=today, **filter_role).order_by('datetime_first')
events_published = Event.objects(status='published', datetime_first__gte=today).order_by('datetime_first')
return render_template('events.html', events_draft=events_draft, events_validation=events_validation, events_published=events_published, add_form=add_form, title_aside=title_aside, icons=icons)
示例3: make_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import author [as 别名]
def make_event(self, entry):
event = Event()
event.type = self.type
event.title = entry.title
event.uid = entry.id
event.url = entry.link
event.created = time.mktime(entry.updated_parsed)
event.author = entry.get("author", "unknown")
if entry.has_key("content"):
event.content = entry.content[0].value
elif entry.has_key("summary"):
event.content = entry.summary
else:
event.content = ""
self.post_init(event, entry)
return event
示例4: add
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import author [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))