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


Python EventForm.is_valid方法代码示例

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


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

示例1: edit_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def edit_event(request, event_name):
  try:
    event = Event.objects.get(name=event_name)
  except Event.DoesNotExist:
    raise Http404('Event does not exist')
  if request.method == 'POST':
    form = EventForm(request.POST, instance=event)
    if (form.is_valid()):
      e = form.save(commit=False)
      events = Event.objects.filter(name=e.name)
      # To allow editing the same event and keeping its short name.
      alreadyExists = False
      for ev in events:
        if ev != event:
          alreadyExists = True
          break
      if not alreadyExists:
        e.save()
        return redirect('feedback:index', e.name)
      messages.add_message(request, messages.WARNING, 'Event with that short name already exists.')
  else:
    form = EventForm(instance=event)
  context = {
      'form': form,
      'event_name': event_name,
  }
  return render(request, 'feedback/edit_event.html', context)
开发者ID:mcdermott-scholars,项目名称:mcdermott,代码行数:29,代码来源:views.py

示例2: createevent

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def createevent(request):
	#create form and enter into database
	if (request.user!=""):
		if request.method == 'POST':
			#print 'in request'
			#print request
			createevent_form=EventForm(request.POST,request.FILES)
			#print 'in request'
			print createevent_form
			if createevent_form.is_valid():
				print 'in request'
				createevent_form.save()
				return redirect('dashboard')
			#return render_to_response('wrongpage.html', {},{})
		else :
			
			s=User.objects.get(username=request.user)
			s1=Seek_User.objects.get(username=request.user)
			print s1.profilePhoto
			createevent_form={'createevent_form':EventForm({'username':request.user,'email':s.email,'status':'active','userid':s.id,'profilePhoto':s1.profilePhoto,'pubdate':timezone.now()})}
#			print createevent_form['createevent_form']
#			createevent_form['createevent_form'].update({'profilePhoto' = s1.profilePhoto})

			#createevent_form['createevent_form']['profilePhoto'] = s1.profilePhoto
			print createevent_form['createevent_form']['profilePhoto'].value()

			return render_to_response('CreateEvent.html',createevent_form,RequestContext(request))
	#return render_to_response('wrongpage.html', {},{})
	return HttpResponse('hello')
开发者ID:kushaga,项目名称:seekx,代码行数:31,代码来源:views.py

示例3: today

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def today(request):
    form = EventForm()
    today = get_begining(datetime.datetime.now())
    events = Event.objects.filter(author=request.user).filter(
            timestamp__gt=today)
    context = {
            'form': form,
            'events': events,
    }
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.author = request.user
            try:
                event.save()
                context['msgs'] = ['Event added successfully.',]
            except:
                context['msgs'] = ['Some error occured. Please enter \
                        valid data.',]
                context['form'] = form
        else:
            context['msgs'] = ['Error: You must enter a title.',]
            context['form'] = form
    return render_to_response('diary/today.html',
            RequestContext(request, context))
开发者ID:chromer,项目名称:CD-Library,代码行数:28,代码来源:views.py

示例4: create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def create(request):
	if request.POST: 
		form = EventForm(request.POST, request.FILES)

		if form.is_valid():
			Event = form.save(commit=False)
			Event.author = request.user
			Event.pub_date = datetime.datetime.now()
			Event = Event.save()
			form.save_m2m()

			return HttpResponseRedirect(reverse('event.views.home'))

	else:
		form = EventForm()


	eighthour_advanced = datetime.datetime.now()+timedelta(hours=8)
	d = eighthour_advanced.strftime("%Y-%m-%d %H:%M")

	return render_to_response('create_event.html', 
														{'form': form,
														'organizations': Organization.objects.order_by('title'),
														'categories': Category.objects.order_by('title'),
														'users': User.objects.order_by('username'),
														'time2': d },
														context_instance = RequestContext(request))
开发者ID:kevinchipotw,项目名称:URevents,代码行数:29,代码来源:views.py

示例5: add_or_edit_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def add_or_edit_event(request, event_pk=None, is_add=False):
	user = request.user
	event = None

	if not is_add:
		event = get_object_or_404(Event, pk=event_pk)
		if event.is_expired():
			user.message_set.create(message="You cannot edit an expired event.")
			return HttpResponseRedirect("/events/")
		if(not user == event.promoter):
			user.message_set.create(message="Only an event's promoter can edit it.")
			return HttpResponseRedirect(request.META.get('HTTP_REFERER', ''))

	if request.method == 'POST':
		if is_add:
			event = Event(promoter=user)
		elif event.promoter != user:
			return oops(request, "Only a event's promoter can edit it.")

		form = EventForm(request.POST, request.FILES)

		if form.is_valid():

			event.name = form.cleaned_data['name']
			if 'image' in request.FILES: 
				file = request.FILES['image']   
				file_content = ContentFile(request.FILES['image'].read())
				event.image.save(request.FILES['image'].name, file_content)
			event.start_date = form.cleaned_data['start_date']
			event.end_date = form.cleaned_data['end_date']
			event.description_markdown = form.cleaned_data['description']
			event.rsvp_link = form.cleaned_data['rsvp_link']
			tags = form.cleaned_data['tags']
			event.save()
			event.set_tags(tags)

			return HttpResponseRedirect(event.get_absolute_url())
	elif not is_add:

		form = EventForm(initial={
			'name':event.name,
			'description':event.description_markdown,
			'image':event.image,
			'start_date':event.start_date,
			'end_date':event.end_date,
			'tags':event.get_editable_tags,
			'rsvp_link':event.rsvp_link,
		})
	else:
		form = EventForm()

	return render_to_response('add_or_edit_event.html',
		{'form': form,
		'is_editing': not is_add,
		'page_title': (is_add and "Add" or "Edit") + " an Event",
		'event': event},
		context_instance=RequestContext(request))
开发者ID:alphaonelabs,项目名称:clusterify,代码行数:59,代码来源:views.py

示例6: create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def create(request):
    if request.method == "POST":
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save()
            return HttpResponseRedirect('/agenda/%i/details/' % event.pk)
    else:
        form = EventForm()
    return render(request, 'personal_calendar/event/create.html', {'form': form})
开发者ID:Tosta-Mixta,项目名称:Django_Agenda,代码行数:11,代码来源:views.py

示例7: create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def create(request):
    nav_selected = "events"
    form = EventForm(user=request.user, data=(request.POST or None))
    if form.is_valid():
        event = form.save()
        Record.objects.create_record(request.user, "event_create", event)
        messages.success(request, "%s has been created." % event)
        return redirect(event)
    return render_to_response("events/create.html", locals(), context_instance=RequestContext(request))
开发者ID:allianceforclimateprotection,项目名称:repowerathome,代码行数:11,代码来源:views.py

示例8: edit

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def edit(request, event_id):
    nav_selected = "events"
    event = get_object_or_404(Event, id=event_id)
    form = EventForm(user=request.user, instance=event, data=(request.POST or None))
    if form.is_valid():
        event = form.save()
        messages.success(request, "%s has been changed." % event)
        return redirect(event)
    return render_to_response("events/edit.html", locals(), context_instance=RequestContext(request))
开发者ID:allianceforclimateprotection,项目名称:repowerathome,代码行数:11,代码来源:views.py

示例9: create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def create(request):
    data = {}
    data["user"] = request.user
    form = EventForm(request.POST or None)
    data["form"] = form
    if form.is_valid():
        obj = form.save(commit=False)  # get an unbound object
        obj.save()
        return HttpResponseRedirect("/event/%s" % obj.id)
    return render_to_response("event/create.html", data)
开发者ID:taras1k,项目名称:twevent,代码行数:12,代码来源:views.py

示例10: new_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def new_event(request):
    from forms import EventForm
    if request.method == "POST":
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.save()
            return redirect('events', event.event_url)
    else:
        form = EventForm()
    return render(request, 'edit_event.html', {"form": form})
开发者ID:iamwithnail,项目名称:supperclub,代码行数:13,代码来源:views.py

示例11: create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def create(request):
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save()
            inset_one(event)
            return HttpResponseRedirect(reverse('administration_events_index'))
    else:
        form = EventForm()

    return render(request, 'events/administration/events_create.html',
                              {'form': form,
                               'active_module': 'events'})
开发者ID:isergey,项目名称:system,代码行数:15,代码来源:views.py

示例12: handle_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def handle_event(request):
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            request.session['arkistoija']['event'] = {
                'name': form.cleaned_data['name'],
                'date': form.cleaned_data['date'],
            }
            request.session.modified = True
            return HttpResponseRedirect('/arkistoija/p/2/')
    else:
        form = EventForm()
        
    return {'eventform': form}
开发者ID:maakuth,项目名称:Instanssi.org,代码行数:16,代码来源:views.py

示例13: main_list_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def main_list_event(request):
    e_list = Event.objects.all()
    if request.method == 'POST':
        e_form = EventForm(request.POST)
        if e_form.is_valid():
            event_data = e_form.save(commit=False)
            event_data.user = request.user
            event_data.save()            
    else:
        e_form = EventForm()

    return render(request, 'event-list-block.html', {
        'e_list': e_list,
        'e_form': e_form,
    })
开发者ID:gabelev,项目名称:people_we_meet,代码行数:17,代码来源:views.py

示例14: create_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def create_event(request):
	# Returns false on empty
	if request.POST:
		form = EventForm(request.POST)
		if form.is_valid():
			form.save()
		return HttpResponseRedirect('')
	else:
		form = EventForm

	## Page Context Arguments
	args = {}
	args.update(csrf(request))
	args['form'] = form
	return render(request, 'img_upload/create_event.html', args)
开发者ID:GleasonK,项目名称:BC-Billboard,代码行数:17,代码来源:views.py

示例15: edit

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import is_valid [as 别名]
def edit(request, event_id):
    event = get_object_or_404(Event, id=event_id)
    if request.method == 'POST':
        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            event = form.save()
            inset_one(event)
            return HttpResponseRedirect(reverse('administration_events_index'))
    else:

        form = EventForm(model_to_dict(event),instance=event)
    return render(request, 'events/administration/events_edit.html',
                              {'form': form,
                               'event':event,
                               'active_module': 'events'})
开发者ID:isergey,项目名称:system,代码行数:17,代码来源:views.py


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