Example #1
0
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)
Example #2
0
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)
Example #3
0
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')
Example #4
0
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)
Example #5
0
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) 
Example #6
0
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'))
Example #7
0
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)
Example #8
0
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)
Example #9
0
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))
Example #10
0
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)
Example #11
0
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)
Example #12
0
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))
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))
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))
Example #15
0
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})
Example #16
0
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)
Example #17
0
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})
Example #18
0
File: app.py Project: miku/evreg
def edit_event(event_id):
	event = Event.query.get(event_id)
	form = EventForm(obj=event)
	if form.validate_on_submit():
		event.name = unicode(form.name.data)
		event.description = unicode(form.description.data)
		event.registration_opens = form.registration_opens.data
		event.registration_closes = form.registration_closes.data
		db_session.add(event)
		db_session.commit()
		return redirect(url_for('show_event', event_id=event.id))
	return render_template("admin/edit_event.html", **locals()) 
Example #19
0
File: app.py Project: miku/evreg
def create_event():
	form = EventForm()
	if form.validate_on_submit():
		event = Event()
		event.name = unicode(form.name.data)
		event.description = unicode(form.description.data)
		event.registration_opens = form.registration_opens.data
		event.registration_closes = form.registration_closes.data
		db_session.add(event)
		db_session.commit()
		return redirect(url_for('dashboard'))
	return render_template("admin/create_event.html", form=form)
Example #20
0
def event_update(id):
    event = Event.query.get(id)
    form = EventForm(request.form, obj=event)
    if request.method == 'POST':
        if form.validate_on_submit():
            form.populate_obj(event)
            db.session.commit()
        
            flash(u'이벤트 정보를 수정하였습니다.', 'success')
            return redirect(url_for('event_list'))

    return render_template('event/update.html', form=form)
Example #21
0
def create_event():
    user = g.user
    if not user.is_admin():
        return redirect(url_for('dashboard')) 
    form = EventForm()
    event = Event() 
    if form.validate_on_submit():
        event = Event(user_id = user.id, name = request.form.get('name'), description = request.form.get('description'), starttime = request.form.get('starttime'), endtime = request.form.get('endtime'), location = request.form.get('location'), max_team = request.form.get('max_team'), max_member_per_team = request.form.get('max_member_per_team'), department = request.form.get('department'))
        sqldb.session.add(event)
        sqldb.session.commit()
        return redirect(url_for('event', event_id = event.id))
    return render_template("event.html", form = form, event = event)
Example #22
0
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'})
Example #23
0
def createEvent():
    form = EventForm()
    def add_event(name, category, time, location):
        event = Event(name=name, category=category, time=time, location=location)
        sqldb.session.add(event)
        sqldb.session.commit()
        return event.id
    if form.validate_on_submit():
        eventId = add_event(form.name.data, form.category.data, form.time.data, form.location.data)
        #flash('Event Created.' + " Event ID: " + str(eventId))
        return redirect("addStep/"+str(eventId))

    return render_template("createEvent.html", form=form)
Example #24
0
def family_group_add(fg_id):
	if request.method == 'GET':
		form = EventForm(request.args)
	else:
		form = EventForm(coerce=int)

	if form.validate_on_submit():
		event = SmallGroupEvent(name=form.name.data, description=form.description.data, weekNumber=form.week.data, quarter=form.quarter.data, small_group_id=fg_id)
		db.session.add(event)
		db.session.commit()
		flash(('Event added successfully.'))
		return redirect(url_for('family_group_leader_manage', fg_id=fg_id))

	return render_template("smallgroup/add.html", user=g.user, form=form, fg_id=fg_id)
Example #25
0
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}
Example #26
0
def create(request):
    template_name = 'events/create.html'
    context = {}
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.user = request.user
            event.save()
            next_url = event.get_absolute_url()
            return HttpResponseRedirect(next_url)
    else:
        form = EventForm()
    context['form'] = form
    return render(request, template_name, context)
Example #27
0
def edit(request, pk):
    template_name = 'events/edit.html'
    event = get_object_or_404(Event, pk=pk,
                              user=request.user)
    context = {}
    context['event'] = event
    if request.method == 'POST':
        form = EventForm(data=request.POST, instance=event)
        if form.is_valid():
            form.save()
            return redirect('events_my')
    else:
        form = EventForm(instance=event)
    context['form'] = form
    return render(request, template_name, context)
Example #28
0
def update_event(id):
    db_session = db.get_session()

    form = EventForm()
    event = db_session.query(Event).get(id)

    form.id.data = event.id
    form.populate_obj(event)

    if form.validate_on_submit():
        db_session.add(event)
        db_session.commit()
        return redirect('events')
    else:
        return render_template('events/edit.html', event=event, form=form)
Example #29
0
def create_event(request, calendar_id):
    if request.method == "POST":
        form = EventForm(request.POST)
        if form.is_valid():
            calendar = get_object_or_404(Calendar, pk=calendar_id)
            datetime = form.cleaned_data['datetime']
            name = form.cleaned_data['name']
            tags = form.cleaned_data['tags']
            event = Event.objects.create(calendar=calendar, datetime=datetime, name=name, tags=tags)
            event.save()
            return HttpResponseRedirect(reverse("view_calendar", args=[calendar.id]))
        else:
            return HttpResponse(form.errors)
    form = EventForm()
    return render(request, 'create_event.html', {'form': form, 'calendar_id': calendar_id})
Example #30
0
File: app.py Project: zardoru/becgi
def event_update(event_id):
    form = EventForm()
    if form.validate_on_submit():
        do_update_event(event_id, form)
        if form.token.data != database.Event(event_id).token:
            flash("Invalid token.")
            return redirect(url_for("event_admin", event_id=event_id))

        return redirect(url_for('event_index', event_id=event_id))
    else:
        flash("There's been errors validating your request. Look below for details.")
        #for field, errors in form.errors.items():
        #    for error in errors:
        #        flash(field + " " + error)
        return render_template("event_edit.html", event=database.Event(event_id), form=form)