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


Python Event.event_type方法代码示例

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


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

示例1: beer_gone

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import event_type [as 别名]
def beer_gone(request, beer_id):
    beer = get_object_or_404(Beer, pk=beer_id)

    if beer.current_state() == 6:
        messages.error(request, "This beer is already marked as 'gone'!")
        return redirect('beer-show', beer.id)

    # Create a new event marking this beer as gone
    event = Event()
    event.beer = beer
    event.date = datetime.datetime.now().date()
    event.event_type = 6    # Hard-coding this is kind of gross...
    event.completed = True
    event.save()

    tweet_event.delay(event)

    return redirect('beer-show', beer.id)
开发者ID:nickpegg,项目名称:home,代码行数:20,代码来源:views.py

示例2: addNewEvent

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import event_type [as 别名]
def addNewEvent(request):
    """
    Method that adds an event to the spatial database.
    """
    response = {'response':'ok'}
    try:
        #event_type and event_keywords come as names, not IDs. So we need first
        #to get their primary keys so we can save the Event properly.
        event_type_name = request.POST['event_type'].encode('utf-8').lower().strip()
        event_type, created = EventType.objects.get_or_create(name=event_type_name)
    
        event_keywords = request.POST['event_keywords'].encode('utf-8')
        event_keywords = event_keywords[1:-1].split(',')
        keywords = []
        for keyword in event_keywords:
            k, created = EventKeyword.objects.get_or_create(keyword=keyword.strip())
            keywords.append(k)

        #gets what is interesting about the Event and makes it compatible 
        #with the server's format.
        event_json = eval(request.POST['event'].encode('utf-8'))[0]['fields']

        geo_coord = event_json['geo_coord'].replace(',',' ')
        geo_coord = GEOSGeometry('POINT('+geo_coord+')')

        event = Event(title=event_json['title'],description=event_json['description'],
            pub_date=event_json['pub_date'],geo_coord=geo_coord)
        event.event_type = event_type
        event.save()
        for k in keywords:
            event.keywords.add(k)
        event.save()
        
        contextdata = generateContextData(request.POST['context_data'])
        contextdata.event = event
        contextdata.save()
        
        response['pk'] = event.pk
    except DeserializationError as error:
        response['response'] = str(error)
        
    #returns a json with an error or an ok and the primary key from the added event.
    return jsonhelper.json_response(response)
开发者ID:brunodea,项目名称:infocity_server,代码行数:45,代码来源:views.py

示例3: add_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import event_type [as 别名]
def add_event(request):
	date = request.POST.get('date')
	time = request.POST.get('time')
	event_type = request.POST.get('event_type')
	description = request.POST.get('description')
	dosage = request.POST.get('dosage')
	medication_id = int(request.POST.get('select_med'))
	user_id = request.user.pk
	datetime = str(date) + " " + time
	print "datetime", datetime
	new_event_entry = Event()
	new_event_entry.date = datetime
	new_event_entry.event_type = event_type
	new_event_entry.description = description
	new_event_entry.dosage = dosage
	new_event_entry.medication_id = medication_id
	new_event_entry.user_id = user_id
	new_event_entry.save()
	#return render(request, 'med_tracker_app/user_dash.html', { 'new_event' : "You added a new event." })
	return HttpResponseRedirect(reverse('med_tracker_app:user_dash'))
开发者ID:skomer,项目名称:med_tracker,代码行数:22,代码来源:views.py

示例4: beer_new

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import event_type [as 别名]
def beer_new(request):
    if not request.user.is_superuser:
        return redirect('brewhouse-display')

    if request.method == 'POST':
        form = AddBeerForm(request.POST)
        if form.is_valid():
            b = Beer()
            b.name = form.cleaned_data['name']
            b.style = form.cleaned_data['style']
            b.recipe_url = form.cleaned_data['recipe_url']
            b.save()

            # Create some basic events based on the brewed-on date
            # tuple is of (event_type, days_since_brew_date)
            brew_date = form.cleaned_data['brew_date']

            events = (
                (7, 0),     # brewing
                (1, 0),     # brewed
                (2, 0),     # primary fermentation
                (3, 7),     # secondary fermentation
                (4, 21),    # kegged
                (0, 28),    # ready!
            )

            for etype, num_days in events:
                event = Event()
                event.beer = b
                event.event_type = etype
                event.date = brew_date + datetime.timedelta(days=num_days)
                event.save()

            return redirect('beer-show', b.id)
        else:
            pass    # TODO set an error
    else:
        form = AddBeerForm()

    return render(request, 'brewhouse/new_beer.html', locals())
开发者ID:nickpegg,项目名称:home,代码行数:42,代码来源:views.py


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