Exemplo n.º 1
0
	def dispatch_request(self, party_id):
		Usr = users.get_current_user()
		if Usr.email() == '*****@*****.**' or Usr.email() == '*****@*****.**':
			party = Party.get_by_id(party_id)
			form = PartyForm(obj=party)
			form.street.data = party.address.street
			form.suite.data = party.address.suite
			form.city.data = party.address.city
			form.state.data = party.address.state
			form.zip.data = party.address.zip
			if request.method == "POST" and form.validate_on_submit():
				party.name = form.data.get('name')
				party.address.street = form.data.get('street')
				party.address.suite = form.data.get('suite')
				party.address.city = form.data.get('city')
				party.address.state = form.data.get('state')
				party.address.zip = form.data.get('zip')
				party.email = form.data.get('email')
				party.phone = form.data.get('phone')
				party.code = form.data.get('code')
				party.put()
				flash(u'Party %s successfully saved.' % party_id, 'success')
				return redirect(url_for('admin'))
			return render_template('edit_party.html', party=party, form=form)
		else:
			flash(u'Sorry, no admission!')
			return redirect(url_for('index'))
Exemplo n.º 2
0
	def dispatch_request(self):
		Usr = users.get_current_user()
		if Usr.email() == '*****@*****.**' or Usr.email() == '*****@*****.**':
			parties = Party.query()
			persons = Person.query()
			p = request.args.get('p', '')				
			if not p:
				form = PartyForm()
				if form.validate_on_submit():
					party = Party(name=form.name.data,code=gen_code(),email=form.email.data,
							phone=form.phone.data, address={ 'street':form.street.data, 'zip':form.zip.data,
							'suite': form.suite.data, 'city':form.city.data, 'state':form.state.data, } )
					party.put()
					p = party.key.id()
					#request.post(p=p)
					#return redirect(url_for('index'))
					return render_template('admin.html', pid=p,form=PersonForm(),parties=parties,persons=persons,
							Party=Party,Person=Person)
				return render_template('admin.html',pid=p,form=form,parties=parties,persons=persons,
						Party=Party,Person=Person)
			else:
				form = PersonForm()
				p = int(p)
				if form.validate_on_submit():
					person = Person(title=form.title.data,first=form.first.data,last=form.last.data,
							food=form.food.data, rsvp='a', party=form.party.data)
					person.put()
					ps = person.key.id()
					return redirect(url_for('admin', p=p))
					return render_template('admin.html',pid=p,form=form,parties=parties,
							persons=persons, Party=Party,Person=Person)
				return render_template('admin.html',pid=p,form=form,parties=parties,
							persons=persons, Party=Party,Person=Person)
		else:
			flash(u'Sorry, no admission!')
			return redirect(url_for('rsvp'))
Exemplo n.º 3
0
def party_create():
    form = PartyForm()

    if form.validate_on_submit():
        if current_user.get_id() == None:
            return redirect(url_for('.login_route'))
        party = Party(
            party_host = current_user.get_id(),
            party_name = form.partyname.data
        )
        db.session.add(party)
        db.session.commit()
        print "PARTY ADDED: \t SUCCESS!\n"
        return redirect(url_for('.party_route', party_id=party.get_id()))
    else:
        print form
        print form.errors
        return render_template("create_party.html", form=form, errors=form.errors)
    return render_template("create_party.html", form=form)
Exemplo n.º 4
0
def create_party():
    if not g.user:
        flash('You must log in for that', category='danger')
        return redirect('/login')
    form = PartyForm()
    if form.validate_on_submit():
        p = Party.create(name=form.name.data,
                         address=form.address.data,
                         city=form.city.data,
                         state=form.state.data,
                         zip_code=form.zip_code.data,
                         leader_id=g.user.id)
        if type(p) == str:
            flash(p, category='info')
        else:
            flash('Successfully added party', category='success')
            resturaunts = Resturaunt.get_resturaunts(party_id=p.id)
            if type(resturaunts) == str:
                flash(resturaunts, category='warning')
            return redirect('/')
    return render_template('/parties/create.html', form=form)