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


Python Event.save方法代码示例

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


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

示例1: api_event_add

# 需要导入模块: from core.models import Event [as 别名]
# 或者: from core.models.Event import save [as 别名]
def api_event_add(request):
    response = {}
    header = request.POST['header']
    category = request.POST['category']
    plan_id = request.POST['plan_id']
    plan = Plan.objects.get(id=plan_id)
    new_event = Event()
    new_event.header = header
    new_event.category = category
    new_event.plan = plan
    new_event.order = len(plan.get_events())
    new_event.save()
    response['event_id'] = new_event.id
    response['collaborator_id'] = request.user.id
    return response, 201
开发者ID:elesant,项目名称:TripPlanner,代码行数:17,代码来源:views.py

示例2: save_event_to_db

# 需要导入模块: from core.models import Event [as 别名]
# 或者: from core.models.Event import save [as 别名]
def save_event_to_db(event):
    '''The function to save single event into DB (table: core_event)
    '''
    e = Event(
        categoryID             = parse_category_id(event['category_id']),
        datePosted             = parse_datetime(event['date_posted']),
        description            = event['description'],
        distance               = event['distance'],
        distanceUnits          = event['distance_units'],
        endDate                = parse_date(event['end_date']),
        endTime                = parse_time(event['end_time']),
        geoCodingAmbig         = event['geocoding_ambiguous'],
        geoCodingPrec          = event['geocoding_precision'],
        eventID                = event['id'],
        latitude               = event['latitude'],
        longitude              = event['longitude'],
        metroID                = event['metro_id'],
        name                   = event['name'],
        numFutureEvents        = event['num_future_events'],
        personal               = event['personal'],
        photoURL               = event['photo_url'],
        selfPromotion          = event['selfpromotion'],
        startDate              = parse_date(event['start_date']),
        startDateLastRendition = event['start_date_last_rendition'],
        startTime              = parse_time(event['start_time']),
        ticketFree             = parse_int(event['ticket_free']),
        ticketPrice            = event['ticket_price'],
        ticketURL              = event['ticket_url'],
        URL                    = event['url'],
        userID                 = event['user_id'],
        utcEnd                 = parse_datetime(event['utc_end']),
        utcStart               = parse_datetime(event['utc_start']),
        venueAddr              = event['venue_address'],
        venueCity              = event['venue_city'],
        venueCountryCode       = event['venue_country_code'],
        venueCountryID         = event['venue_country_id'],
        venueCountryName       = event['venue_country_name'],
        venueID                = event['venue_id'],
        venueName              = event['venue_name'],
        venueStateCode         = event['venue_state_code'],
        venueStateID           = event['venue_state_id'],
        venueStateName         = event['venue_state_name'],
        venueZip               = str(event['venue_zip']),
        watchListCount         = event['watchlist_count'])
    e.save()
开发者ID:JohnStuartRutledge,项目名称:django-insightfever,代码行数:47,代码来源:UpcomingCrawler.py

示例3: events

# 需要导入模块: from core.models import Event [as 别名]
# 或者: from core.models.Event import save [as 别名]
def events(request):
    if request.user.is_anonymous():
        return JsonResponse({'error': 'loggedOut'})

    if request.method == 'POST':
        event_data = convert_dict_keys_deep(json.loads(request.body))['event']
        if (not event_data['name'] or not event_data['date_from'] or not event_data['type'] or not event_data['color']):
            return JsonResponse({'error': 'badRequest'})

        if (not event_data['id']):
            event = Event(
                name=event_data['name'],
                date_from=event_data['date_from'],
                date_to=event_data['date_to'],
                type=event_data['type'],
                color=event_data['color'],
            )
            event.save()
            return JsonResponse({'event': serialize_event(event)})

    events = [serialize_event(event) for event in Event.objects.order_by('date_from').all()]
    return JsonResponse({'events': events})
开发者ID:briska,项目名称:bemyguest,代码行数:24,代码来源:api.py

示例4: checkout

# 需要导入模块: from core.models import Event [as 别名]
# 或者: from core.models.Event import save [as 别名]
def checkout(request):
	if not request.user.is_authenticated():
		return redirect('/user/login/')

	name = ''
	sumary = ''
	error_message = False
	total = 0
	currency = 'USD'
	cart = []
	if request.POST:
		name = request.POST['name']
		sumary = request.POST['sumary']
		if name and sumary:
			cart = request.session[settings.SHOPPING_CART_KEY]
			# Check client status
			client = Client.objects.filter(user__id = request.user.id)
			if client: # User is already registered as client
				client = client[0]
			else:
				client = Client(user=request.user, created=timezone.now())
				client.save()
			# Create story and events
			story = Story(
				client = client,
				name = name,
				sumary = sumary,
				created = timezone.now()
			)
			story.save()
			for ev in cart:
				place = Place.objects.get(pk=ev['place'])
				ev = complete_event(ev, place)
				event = Event(
					story = story,
					place = place,
					created = timezone.now(),
					start = ev['start'],
					end = ev['end']
				)
				event.save()
			del request.session[settings.SHOPPING_CART_KEY]
			return redirect('/story/' + str(story.id))

		else:
			error_message = 'Some fields are required.'

	if settings.SHOPPING_CART_KEY in request.session:
		cart = request.session[settings.SHOPPING_CART_KEY]
		i = 0
		for ev in cart:
			place = Place.objects.get(pk=ev['place'])
			ev['index'] = i
			ev = complete_event(ev, place)
			total += ev['price']
			i = i+1

	context = {
		'name'			: name,
		'sumary'		: sumary,
		'total'			: total,
		'currency'		: currency,
		'cart'			: cart,
		'error_message'	: error_message,
		'user'			: views.user_status(request),
		'shopping_cart'	: views.shopping_cart_status(request)
	}
	return render(request, 'story/checkout.html', context)
开发者ID:derkcris,项目名称:BunnyIncHackathon,代码行数:70,代码来源:story_views.py

示例5: __call__

# 需要导入模块: from core.models import Event [as 别名]
# 或者: from core.models.Event import save [as 别名]
	def __call__(self, *args):
		event = args[0]
		ev = Event(filename=os.path.join(event.path, event.name), type=event.mask)
		ev.save()
开发者ID:brian-l,项目名称:Freshen,代码行数:6,代码来源:watcher.py


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