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


Python forms.EventForm类代码示例

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


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

示例1: add_event

def add_event():
    def _dup(l):
        return [(i, i) for i in l]

    session = create_session()
    form = EventForm(request.forms.decode())
    form.continent.choices = _dup(CONTINENTS)
    # countries = session.query(Country)  # XXX: why is countries never used?
    # form.country.choices = [(c.id, c.name) for c in countries.all()]
    # form.gender.choices = _dup(["male", "female", "all"])

    if form.validate():
        session = create_session()
        new_task = Event.from_form(form)
        try:
            for attachment in scan_attachments(request.files):
                print "saving attachment: ", attachment, attachment.filename
                new_task.attachments.append(Attachment(
                    file_path=save_file(attachment),
                    file_name=attachment.filename,
                    file_type=attachment.content_type))
            session.add(new_task)
            session.commit()
            return redirect("/")
        except InvalidFileUpload as e:
            form.errors['attachment'] = e.message

    print dict(request.forms)
    print form.errors
    print type(form.errors)
    return new(errors=form.errors)
开发者ID:steinnes,项目名称:judo-events,代码行数:31,代码来源:index.py

示例2: event_create

def event_create():
    form = EventForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            event = Event(
                title = form.title.data,
                title_cal = form.title_cal.data,
                content = form.content.data,
                host = form.host.data,
                category_char = form.category_char.data,
                category_host = form.category_host.data,
                date_start = form.date_start.data,
                date_end = form.date_end.data,
                location = form.location.data,
                link = form.link.data,
                poster = form.poster.data,
                contact = form.contact.data,
                contact_open = form.contact_open.data,
            )

            db.session.add(event)
            db.session.commit()

            flash(u'이벤트를 등록했습니다.', 'success')
            return redirect(url_for('event_list'))

    return render_template('event/create.html', form=form)
开发者ID:DongsikHan,项目名称:Calendar,代码行数:27,代码来源:views.py

示例3: createevent

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,代码行数:29,代码来源:views.py

示例4: edit_event

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,代码行数:27,代码来源:views.py

示例5: add_event

def add_event():
  if g.user is None:
    return redirect(url_for("index"))

  form = EventForm()
  if form.validate_on_submit():
    what = form.what.data
    where = form.where.data
    length = form.length.data
    wait_time = form.wait_time.data
    pre_delay = form.pre_delay.data
    required_people = form.required_people.data
    description = form.description.data
    if form.public.data:
      public = 1
    else:
      public = 0
    event = models.Event(what=what, where=where, length=length, wait_time=wait_time, pre_delay=pre_delay, required_people=required_people, description=description, public=public)
    db.session.add(event)
    db.session.commit()
    user = models.User.query.get(g.user['id'])
    event_req = models.EventSubscription(user=user, event=event)
    db.session.add(event_req)
    db.session.commit()
    flash("Event successfully created")
    return redirect(url_for("event", id=event.id))
  return render_template("add_event.html", app_id=FB_APP_ID, name=FB_APP_NAME, user = g.user, form=form) 
开发者ID:SebastianMerz,项目名称:together,代码行数:27,代码来源:views.py

示例6: create

def create():
    logging.info("create start")
    form = EventForm()

    if request.method == 'POST':
        logging.info("Method: POST")
        if form.validate_on_submit():
            event = Event(
                title = form.title.data,
                title_cal = form.title_cal.data,
                content = form.content.data,
                host = form.host.data,
                category_char = form.category_char.data,
                category_host = form.category_host.data,
                date_start = form.date_start.data,
                date_end = form.date_end.data,
                location = form.location.data,
                link = form.link.data,
                poster = form.poster.data,
                contact = form.contact.data,
                contact_open = form.contact_open.data,
            )
            print event
            logging.info("");    

            db.session.add(event)
            db.session.commit()
            
            print "11111111"
            logging.info("");  

            flash(u'이벤트를 등록했습니다.', 'success')

    return redirect(url_for('index'))
开发者ID:DongsikHan,项目名称:Calendar,代码行数:34,代码来源:views.py

示例7: newEvent

def newEvent():
    '''
    Add an event, requires to be logged and makes the user the event owner.
    Fills the choices select field with all the available categories.
    Returns a redirect to show events after adding the event in case of POST
    or the add event html page in case of GET.
    '''
    form = EventForm(request.form)
    form.category_id.choices = ([
        (c.id, c.name) for c in Category.query.order_by(Category.name)])
    form.category_id.choices.insert(0, (0, 'select'))
    if request.method == 'POST' and form.validate():
        newEvent = Event(
            category_id=form.category_id.data,
            name=form.name.data,
            location=form.location.data,
            date=form.date.data,
            username=session['username']
        )
        db.session.add(newEvent)
        db.session.commit()
        flash('New event created')
        return redirect(url_for('showEvents'))
    else:
        return render_template('new_event.html', form=form)
开发者ID:manelromero,项目名称:catalog,代码行数:25,代码来源:views.py

示例8: event_new

def event_new():
    '''Add a new Event.'''
    user = g.user
    if user.is_director or user.is_admin:
        form = EventForm()
        bands = [(band.id, band.name) for band in Band.query.all()]
        event_types = [(typ.id, typ.name) for typ in EventType.query.all()]
        form.band_id.choices = bands
        form.event_type_id.choices = event_types

        if form.validate_on_submit():
            date = form.date.data
            time = form.calltime.data
            calltime = datetime(year=date.year,
                                month=date.month,
                                day=date.day,
                                hour=time.hour,
                                minute=time.minute)
            band_id = form.band_id.data
            event_type_id = form.event_type_id.data
            opponent = form.opponent.data
            event_id = add_event(date=date, calltime=calltime, band_id=band_id,
                                 event_type_id=event_type_id, opponent=opponent)
            return redirect(url_for('event', event_id=event_id))

        return render_template('event/create_update.html', form=form, user=user)
    abort(404)
开发者ID:kevana,项目名称:ummbNet,代码行数:27,代码来源:views.py

示例9: today

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,代码行数:26,代码来源:views.py

示例10: post_event

def post_event():
  form = EventForm()
  if 'email' not in session:
    flash("You need to login to post Events")
    return redirect(url_for('signin'))
  user = User.query.filter_by(email = session['email']).first()
  
  if user is None:
    return redirect(url_for())

  if request.method == 'POST':
    if form.validate() == False:
      flash("Fill all the fields")
      return render_template('post_events.html',form=form)
    else:
      
      newevent = Event(form.name.data, 
                      form.location.data, 
                      form.date.data, 
                      form.description.data)
      db.session.add(newevent)
      flash("Event successfully posted")
      db.session.commit()
      
      return redirect(url_for('index'))
  elif request.method == 'GET':
      return render_template('post_events.html',form=form)
开发者ID:essykings,项目名称:EventManager,代码行数:27,代码来源:views.py

示例11: event_examples

def event_examples():
    """List all events"""
    event = Event.query()
    form = EventForm()
    if form.validate_on_submit():
        event = Event(
            #event_id=
            title=form.title.data,
            day=form.day.data,
            location=form.location.data,
            description=form.descrtiption.data,
            anchor_amount=form.anchor_amount.data,
            amount_min=form.amount_min.data,
            max_attendees=form.max_attendees.data,
            registration_start=form.registration_start.data,
            registration_end=form.registration_end.data,
            added_by=users.get_current_user()
        )
        try:
            event.put()
            event_id = event.key.id()
            flash(u'Event %s successfully saved.' % event_id, 'success')
            return redirect(url_for('event_examples'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('event_examples'))
    return render_template('event_gae.html', event=event, form=form)
开发者ID:meyilmaz,项目名称:rsvplus,代码行数:27,代码来源:views.py

示例12: add_or_edit_event

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,代码行数:57,代码来源:views.py

示例13: create

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,代码行数:9,代码来源:views.py

示例14: edit

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,代码行数:9,代码来源:views.py

示例15: create

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,代码行数:9,代码来源:views.py


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