當前位置: 首頁>>代碼示例>>Python>>正文


Python EventForm.save方法代碼示例

本文整理匯總了Python中events.forms.EventForm.save方法的典型用法代碼示例。如果您正苦於以下問題:Python EventForm.save方法的具體用法?Python EventForm.save怎麽用?Python EventForm.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在events.forms.EventForm的用法示例。


在下文中一共展示了EventForm.save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: edit_event

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def edit_event(request, id):
    if request.method == 'POST':
        event = get_object_or_404(Event, id=id)
        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            form.save(commit=False)
            event.save()
            return HttpResponseRedirect(event.get_absolute_url())
    else:
        event = get_object_or_404(Event, id=id)
        form = EventForm(instance=event)
    return render_to_response('events/new_event.html', {'form': form, 'object': event}, context_instance=RequestContext(request))
開發者ID:sigurdga,項目名稱:nidarholm,代碼行數:14,代碼來源:views.py

示例2: event_create

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def event_create(request):
    if request.method == 'POST':
        eventform = EventForm(request.POST)
        if eventform.is_valid():
            eventform.save()
    else:
        eventform = EventForm()

    print eventform
    return render_to_response('events/event-create.html',
                              {'eventform': eventform},
                              context_instance=RequestContext(request)
                             )
開發者ID:bmease,項目名稱:thanksPearl,代碼行數:15,代碼來源:views.py

示例3: list_all_events_view

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def list_all_events_view(request):
    ''' A list view of all events.  Part of archives. '''
    page_name = "Archives - All Events"
    profile = UserProfile.objects.get(user=request.user)

    event_form = EventForm(
        request.POST if "post_event" in request.POST else None,
        profile=profile,
        )

    if event_form.is_valid():
        event_form.save()
        return HttpResponseRedirect(reverse('events:all'))

    # a pseudo-dictionary, actually a list with items of form (event, ongoing,
    # rsvpd, rsvp_form, already_past), where ongoing is a boolean of whether the
    # event is currently ongoing, rsvpd is a boolean of whether the user has
    # rsvp'd to the event
    events_dict = list()
    for event in Event.objects.all():
        rsvp_form = None
        if event.end_time > now():
            rsvp_form = RsvpForm(
                request.POST if "rsvp-{0}".format(event.pk) in request.POST else None,
                instance=event,
                profile=profile,
                )
            if rsvp_form.is_valid():
                rsvpd = rsvp_form.save()
                if rsvpd:
                    message = MESSAGES['RSVP_ADD'].format(event=event.title)
                else:
                    message = MESSAGES['RSVP_REMOVE'].format(event=event.title)
                messages.add_message(request, messages.SUCCESS, message)
                return HttpResponseRedirect(reverse('events:all'))

        ongoing = event.start_time <= now() and event.end_time >= now()
        rsvpd = profile in event.rsvps.all()
        events_dict.append(
            (event, ongoing, rsvpd, rsvp_form)
            )

    if request.method == "POST":
        messages.add_message(request, messages.ERROR, MESSAGES["EVENT_ERROR"])

    return render_to_response('list_events.html', {
        'page_name': page_name,
        'events_dict': events_dict,
        'now': now(),
        'event_form': event_form,
        }, context_instance=RequestContext(request))
開發者ID:naderm,項目名稱:farnsworth,代碼行數:53,代碼來源:views.py

示例4: post

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
    def post(self, request):
        # Temporary part of the method to create tickets for test purposes
        if 'test_baseticket' in request.POST:
            response = create_test_baseticket()
            return response

        event_form = EventForm(request.POST)
        base_ticket_price_form = BaseTicketPriceForm(request.POST)
        upload_form = UploadBaseTicketNew(request.POST, request.FILES)

        if not(event_form.is_valid() and base_ticket_price_form.is_valid() and upload_form.is_valid()):
            return render(request, self.template_name,
                              {'upload_form': upload_form, 'event_form': event_form,
                               'base_ticket_price_form': base_ticket_price_form, 'pdf_exists': 'false'})

        # if the forms were valid
        pdf_file = request.FILES['pdf_file']
        price = request.POST.get('price')

        pdf_object = ProcessBaseTicket(pdf_file)

        if not pdf_object.successful:
            messages.add_message(request, messages.ERROR, pdf_object.message)
            return render(request, self.template_name,
                              {'upload_form': upload_form, 'event_form': event_form,
                               'base_ticket_price_form': base_ticket_price_form, 'pdf_exists': 'false'})

        event = event_form.save()
        self.create_base_ticket(pdf_object, event, price)

        messages.add_message(request, messages.SUCCESS, message_text.event_creation_successful)
        return redirect('buy_ticket:available_tickets', event.id)
開發者ID:MGonen,項目名稱:ticket-exchange,代碼行數:34,代碼來源:views.py

示例5: edit

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def edit(request, id):
    instance = get(Event, pk=id)

    after_add = request.GET.get('after_add', None)

    pricing = instance.pricing_set.all()
    
    if request.method == 'POST':
        form = EventForm(request.POST, instance = instance)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('events'))
    else:
        form = EventForm(instance = instance)

    return render_to_response('event_edit.html', locals())
開發者ID:emperorcezar,項目名稱:OpenConnect,代碼行數:18,代碼來源:views.py

示例6: create

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def create(request):
    form = EventForm(request.POST or None)
    if form.is_valid():
        event = form.save(commit=False)
        event.creator = request.user
        g_d = None
        for  word in event.description.split():
            try:
                g_d = parse(word, fuzzy=True)
                break
            except :
                continue
        event.start_date = g_d
        event.save()

        #request.user.message_set.create(message="Event posted successfully.")

        if 'next' in request.POST:
            next = request.POST['next']
        else:
            next = reverse('ev_tonight')

        return HttpResponseRedirect(next)
    else:
        return render_to_response(
            'event/create.html',
            {'form':form},
            context_instance = RequestContext(request)
        )
開發者ID:jonycse,項目名稱:django_project,代碼行數:31,代碼來源:views.py

示例7: edit_event_view

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def edit_event_view(request, event_pk):
    ''' The view to edit an event. '''
    page_name = "Edit Event"
    profile = UserProfile.objects.get(user=request.user)
    event = get_object_or_404(Event, pk=event_pk)
    if event.owner != profile and not request.user.is_superuser:
        return HttpResponseRedirect(
            reverse('events:view', kwargs={"event_pk": event_pk}),
            )
    event_form = EventForm(
        request.POST or None,
        profile=profile,
        instance=event,
        )
    if event_form.is_valid():
        event = event_form.save()
        messages.add_message(
            request, messages.SUCCESS,
            MESSAGES['EVENT_UPDATED'].format(event=event.title),
            )
        return HttpResponseRedirect(
            reverse('events:view', kwargs={"event_pk": event_pk}),
            )
    return render_to_response('edit_event.html', {
        'page_name': page_name,
        'event_form': event_form,
        }, context_instance=RequestContext(request))
開發者ID:naderm,項目名稱:farnsworth,代碼行數:29,代碼來源:views.py

示例8: add

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def add(request, app_label, model_name, id):
    ''' Tag an event to another model object '''

    try:
        ct = ContentType.objects.get(\
                app_label = app_label,
                model = model_name)
        obj = ct.get_object_for_this_type( id=id )

    except:
        return HttpResponseNotFound()

    if request.method == 'POST':
        #request.POST.update( { 'owner':request.user.id, 'object_id':id,
        #        'content_type':ct.id, 'content_obj': obj, } )
        form = EventForm(request.POST)

        if form.is_valid():
            ev = form.save(commit=False)
            ev.owner = request.user
            ev.object_id = obj.id
            ev.content_type = ct
            ev.save()


            return HttpResponseRedirect(ev.get_absolute_url())

    else:
        form = EventForm()

    context = { 'form':form, 'object':obj, 'content_type':ct, }
    context.update(locals())

    return render_to_response('events/events_add.html', context,\
            context_instance = RequestContext(request))
開發者ID:skyl,項目名稱:django-eventpickrs,代碼行數:37,代碼來源:views.py

示例9: create

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def create(request):
	form = EventForm(request.POST or None)
	if form.is_valid():
		event = form.save(commit=False)
		event.creator = request.user
		guessed_date = None

		for word in event.description.split():
			try:
				guessed_date = parse(word)
				break
			except ValueError:
				continue
		event.start_date = guessed_date
		event.save()
		messages.success(request, "Your event was posted")
		if 'next' in request.POST:
			next = request.POST['next']
		else:
			next = reverse('ev_tonight')
		return HttpResponseRedirect(next)
	return render_to_response(
		'events/create.html',
		{'form':form},
		context_instance = RequestContext(request)
	)
開發者ID:KimHyoJin,項目名稱:startthedart_2013312621,代碼行數:28,代碼來源:views.py

示例10: add

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def add(request):

    if request.method == "GET":
        form = EventForm()
    elif request.method == "POST":
        form = EventForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('events.views.index'))

    c = RequestContext(request)
    c.update({
        'form': form,
    })

    t = loader.get_template('events/add.html')
    return HttpResponse(t.render(c))
開發者ID:samluescher,項目名稱:DjangoTutorial,代碼行數:19,代碼來源:views.py

示例11: events_instance_edit

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def events_instance_edit(request, pk):
    event = Event.objects.get(pk=pk)
    if request.is_ajax():
        render_target = '_form.html'
    else:
        render_target = 'edit.html'
    if request.method == 'POST':
        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            form.save(commit=False)
            return redirect(event)
    else:
        form = EventForm(instance=event)
    return render_to_response('events/%s' % render_target,
                              {'object': event,
                               'form': form,
                               'editing': True},
                              context_instance=RequestContext(request))
開發者ID:Sagelt,項目名稱:DjangoFlock,代碼行數:20,代碼來源:views.py

示例12: add

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def add(request):
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save()
            return HttpResponseRedirect(reverse('event-edit', args=[event.id])+'?after_add=1')
    else:
        form = EventForm()

    return render_to_response('event_add.html', locals())
開發者ID:emperorcezar,項目名稱:OpenConnect,代碼行數:12,代碼來源:views.py

示例13: list_events_view

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def list_events_view(request):
    ''' A list view of upcoming events. '''
    page_name = "Upcoming Events"
    profile = UserProfile.objects.get(user=request.user)
    event_form = EventForm(
        request.POST if 'post_event' in request.POST else None,
        profile=profile,
        )
    now = datetime.datetime.utcnow().replace(tzinfo=utc)
    if event_form.is_valid():
        event_form.save()
        return HttpResponseRedirect(reverse('events:list'))
    # a pseudo-dictionary, actually a list with items of form (event, ongoing,
    # rsvpd, rsvp_form), where ongoing is a boolean of whether the event is
    # currently ongoing, rsvpd is a boolean of whether the user has rsvp'd to
    # the event
    events_dict = list()
    for event in Event.objects.filter(end_time__gte=now):
        rsvp_form = RsvpForm(
            request.POST if "rsvp-{0}".format(event.pk) in request.POST else None,
            instance=event,
            profile=profile,
            )
        if rsvp_form.is_valid():
            rsvpd = rsvp_form.save()
            if rsvpd:
                message = MESSAGES['RSVP_ADD'].format(event=event.title)
            else:
                message = MESSAGES['RSVP_REMOVE'].format(event=event.title)
            messages.add_message(request, messages.SUCCESS, message)
            return HttpResponseRedirect(reverse('events:list'))

        ongoing = ((event.start_time <= now) and (event.end_time >= now))
        rsvpd = (profile in event.rsvps.all())
        events_dict.append((event, ongoing, rsvpd, rsvp_form))

    return render_to_response('list_events.html', {
        'page_name': page_name,
        'events_dict': events_dict,
        'now': now,
        'event_form': event_form,
        }, context_instance=RequestContext(request))
開發者ID:nherson,項目名稱:farnsworth,代碼行數:44,代碼來源:views.py

示例14: edit

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def edit(request, object_id):
    try:
        event = Event.objects.get(pk=object_id)
    except Event.DoesNotExist:
        raise Http404()

    if request.method == "GET":
        form = EventForm(instance=event)
    elif request.method == "POST":
        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('events.views.index'))    

    c = RequestContext(request)
    c.update({
        'form': form,
    })

    return render_to_response('events/add.html', context_instance=c)    
開發者ID:samluescher,項目名稱:DjangoTutorial,代碼行數:22,代碼來源:views.py

示例15: create_event

# 需要導入模塊: from events.forms import EventForm [as 別名]
# 或者: from events.forms.EventForm import save [as 別名]
def create_event(request):
    """
        Creates an event.
    """
    form = EventForm()
    if request.method == "POST":
        form = EventForm(request.POST,request.FILES)
        if form.is_valid():
            event = form.save()
            return HttpResponseRedirect(reverse("event",args=(event.pk,)))
    return render_to_response("events/event_form.html",{"form":form},context_instance=RequestContext(request))
開發者ID:sanchitbareja,項目名稱:cetweb,代碼行數:13,代碼來源:views.py


注:本文中的events.forms.EventForm.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。