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


Python Event.status方法代码示例

本文整理汇总了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)
开发者ID:cynddl,项目名称:federation-backend,代码行数:53,代码来源:views.py

示例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
开发者ID:ebrelsford,项目名称:596acres,代码行数:32,代码来源:loaders.py

示例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)
开发者ID:AppDirect,项目名称:Sample-Python-Application,代码行数:22,代码来源:events.py


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