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


Python Event.title方法代码示例

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


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

示例1: _save_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [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

示例2: events

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [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

示例3: storeEvent

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [as 别名]
def storeEvent(event):
  # logging.info(event)
  e = Event(id=event['id'])
  e.title = event.get('title')
  if event.get('venue'):
    e.venue = event['venue'].get('name')
  if event.get('groupings'):
    e.grouping = event['groupings'][0].get('name')
  if event.get('attributes'):
    e.primaryPerformer = event['attributes'][0].get('value')
    if len(event['attributes']) > 1:
      e.secondaryPerformer = event['attributes'][1].get('value')
  e.save()
  return e
开发者ID:tianfanw,项目名称:django_project,代码行数:16,代码来源:stubhub.py

示例4: make_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [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
开发者ID:tsoulcie,项目名称:nuxeo.org,代码行数:18,代码来源:plugins.py

示例5: save_imported_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [as 别名]
    def save_imported_event(project_key, start_time, end_time, event_title, event_description, billed, event_url=None):

        new_ev = Event(parent=project_key)
        new_ev.title = event_title

        new_ev.start_time = start_time
        new_ev.end_time = end_time
        total_seconds = (end_time - start_time).total_seconds()
        new_ev.elapsed_time = int(total_seconds // 60)

        new_ev.description = event_description
        new_ev.billed = billed
        if event_url:
            new_ev.url = event_url
        new_ev.put()

        return
开发者ID:giovamo,项目名称:Sar,代码行数:19,代码来源:profile.py

示例6: convert_to_entity

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [as 别名]
def convert_to_entity(vevent):
#     print vevent
    event_key = get_key(find_pattern(uid_pattern, vevent))
    event = Event(key=event_key)
    event.title = find_pattern(summary_pattern, vevent)
    event.content = find_pattern(content_pattern, vevent).replace('\r\n ', '')
    date = find_pattern(time_added_pattern, vevent) # 20150527T131225Z
    event.location = find_pattern(location_pattern, vevent)
    event.time_added = datetime.strptime(date, '%Y%m%dT%H%M%SZ')
    time = find_pattern(start_time_pattern, vevent) # 20150528T190000Z
    event.start_time = datetime.strptime(time, '%Y%m%dT%H%M%SZ')
    time = find_pattern(end_time_pattern, vevent) # 20150528T190000Z
    event.end_time = datetime.strptime(time, '%Y%m%dT%H%M%SZ')
    repeat = find_pattern(repeat_pattern, vevent)
    until = find_pattern(until_pattern, vevent, 2)
    seperator = ""
    if until is not None:
        seperator = ":"
    event.repeat = to_string(repeat) + seperator + to_string(until)
    return event
开发者ID:aapteedea,项目名称:shiloh-ranch,代码行数:22,代码来源:events.py

示例7: rest

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import title [as 别名]
def rest(request, event_id=None):
    
    if request.method == 'POST':
        title = request.POST['title']
        description = request.POST['description']
        date_start = request.POST['date_start']
        date_end = request.POST.get('date_end', None)
        lat = request.POST['lat']
        lng = request.POST['lng']
        #image = request.FILES['image']

        event = Event(title=title)
        event.last_update = datetime.datetime.now()
        event.description = description
        event.date_start =  datetime.datetime.strptime(date_start, '%d/%m/%Y %H:%M')
        if date_end:
            event.date_end =  datetime.datetime.strptime(date_end, '%d/%m/%Y %H:%M')
        event.location =  [float(lat),float(lng)]
        user_id = request.session.get('userid')
        user = Account.objects(id=user_id)[0]

        event.user = user
        event.user_going = [user]
        #im = Image.open(image)
        #event.image.put(open(im))
        event.save()
        Account.objects(id=user_id).update_one(push__event_going=event)

        data = json.dumps({'status':'ok'})

    elif event_id:
        user = Account.objects(id=request.session.get('userid'))[0]
        event = Event.objects(id=event_id, user=user)[0]

        if request.method == 'PUT':
            # update field values and save to mongo
            data = JSONParser().parse(request)
            title = data['title']
            description = data['description']
            date_start = data['date_start']
            date_end = data['date_end']
            lat = data['lat']
            lng = data['lng']
            #image = request.FILES['image']

            event.title = title
            event.last_update = datetime.datetime.now()
            event.description = description
            event.date_start =  datetime.datetime.strptime(date_start, '%d/%m/%Y %H:%M')
            if not date_end:
                event.date_end = None
            else:
                event.date_end =  datetime.datetime.strptime(date_end, '%d/%m/%Y %H:%M')
            event.location =  [float(lat),float(lng)]
            event.user = user
            #event.image = request.FILES['image']
            event.save()
            
            data = json.dumps({'status':'ok'})

        elif request.method == 'GET':

            data = {
                'id': str(event.id),
                'title': event.title,
                'description': event.description,
                'location': {
                    'lat': event.location[0],
                    'lng': event.location[1]
                },
                'date_start': str(event.date_start.strftime('%d/%m/%Y %H:%M')) if event.date_start else '',
                'date_end':  str(event.date_end.strftime('%d/%m/%Y %H:%M')) if event.date_end else ''
            } 
            data = json.dumps(data)

        elif request.method == 'DELETE':

            Account.objects().update(pull__event_going=event)
            Account.objects().update(pull__event_maybe=event)

            event.delete() 

            data = json.dumps({'status':'ok'})

    else:

        data = json.dumps({'status':'error'})


    return HttpResponse(data,content_type='application/json')
开发者ID:PauloDuarte43,项目名称:tomada-social,代码行数:92,代码来源:views.py


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