本文整理汇总了Python中models.Event.status方法的典型用法代码示例。如果您正苦于以下问题:Python Event.status方法的具体用法?Python Event.status怎么用?Python Event.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.status方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: events
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import status [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)
示例2: _save_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import status [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
示例3: FetchEvent
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import status [as 别名]
def FetchEvent(token):
consumer = oauth2.Consumer(consumer_key, consumer_secret)
client = oauth2.Client(consumer)
eventUrl = eventUrlTemplate % token
resp, content = client.request(eventUrl)
event = Event()
event.token = token
event.status = int(resp['status'])
if event.status == 200:
xmlDocument = minidom.parseString(content)
eventXml = EventXml(xmlDocument)
event.result = cgi.escape(xmlDocument.toprettyxml())
event.put()
return HandleEvent(eventXml)
else:
message = "HTTP response %d" % event.status
logging.error(message)
event.put()
return errorTemplate % ( "UNKNOWN_ERROR", message)