當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。