Exemple #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'))
Exemple #2
0
def edit_party(request, party_id):
    party = get_object_or_404(Party, id = party_id, creator = request.user)
    
    if request.method == 'POST':
        form = PartyForm(request.POST, instance = party)
        if form.is_valid():
            party = form.save()
            if 'save_send' in request.POST:
                if party.invite_type == 'email':
                    return redirect('email_invite', party_id = party.id)
                else:
                    return redirect('sms_invite', party_id = party.id)  
            else:
                if 'sms_invite' in request.POST:
                    return redirect('sms_invite', party_id = party.id)
                elif 'email_invite' in request.POST:
                    return redirect('email_invite', party_id = party.id)
                else:
                    return redirect('list_party')
        else:
            
            return TemplateResponse(request, 'parties/edit_party.html', {'form': form, 'party': party})       
    else:
        if party.start_date:
            party.start_date = datetime.date.strftime(party.start_date, '%Y-%m-%d')
        if party.start_time:
            party.start_time = datetime.time.strftime(party.start_time, '%H:%M')
        form = PartyForm(instance = party)
        
    return TemplateResponse(request, 'parties/edit_party.html', {'form': form, 'party': party})
Exemple #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)
Exemple #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)
Exemple #5
0
def create_vendor_account(request):
    scenario = 'Create'
    party = Party()
    party.type = 'Supplier'
    for query in request.GET:
        setattr(party, query, request.GET[query])
    if request.POST:
        form = PartyForm(data=request.POST, instance=party)
        if form.is_valid():
            party = form.save(commit=False)
            party.company = request.company
            party.save()
            if request.is_ajax():
                return render(request, 'callback.html', {'obj': CashVendorSerializer(party.supplier_account).data})
            redirect('/ledger/parties')
    else:
        form = PartyForm(instance=party)
        form.fields['type'].widget = form.fields['type'].hidden_widget()
        form.fields['type'].label = ''
        form.hide_field(request)
    if request.is_ajax():
        base_template = 'modal.html'
    else:
        base_template = 'dashboard.html'
    return render(request, 'party_form.html', {
        'form': form,
        'scenario': scenario,
        'base_template': base_template,
    })
Exemple #6
0
def party_form(request, id=None):
    if id:
        scenario = 'Update'
        party = get_object_or_404(Party, id=id, company=request.company)
    else:
        scenario = 'Create'
        party = Party()
    for query in request.GET:
        setattr(party, query, request.GET[query])
    if request.POST:
        form = PartyForm(data=request.POST, instance=party)
        if form.is_valid():
            party = form.save(commit=False)
            party.company = request.company
            party.save()
            if request.is_ajax():
                return render(request, 'callback.html', {'obj': PartySerializer(party).data})
            redirect('/ledger/parties')
    else:
        form = PartyForm(instance=party)
        form.hide_field(request)
    if request.is_ajax():
        base_template = 'modal.html'
    else:
        base_template = 'dashboard.html'
    return render(request, 'party_form.html', {
        'form': form,
        'scenario': scenario,
        'base_template': base_template,
    })
Exemple #7
0
def create_party(request):
    if request.method == 'POST':
        form = PartyForm(request.POST)
        if form.is_valid():
            party = form.save(commit = False)
            party.creator = request.user
            party.save()
            
            if 'sms_invite' in request.POST:
                return redirect('sms_invite', party_id = party.id)
            elif 'email_invite' in request.POST:
                return redirect('email_invite', party_id = party.id)
            else:
                return redirect('list_party')
        else:
            
            return TemplateResponse(request, 'parties/create_party.html', {'form': form})   
                
    else:
        form = PartyForm()
    
    return TemplateResponse(request, 'parties/create_party.html', {'form': form})
Exemple #8
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'))