def process_invoice(req, invoice): """ This is not a view, rather a helper function which processes the invoices """ invoice.status = req.POST.get('status', '') invoice.success = True invoice.pending = False invoice.post_data = str(req.POST) invoice.save() if invoice.invoice_type in ('single', 'multiple', 'upgrade'): new_pack = invoice.invoice_type if new_pack == 'upgrade': new_pack = 'multiple' invoice.profile.pack = new_pack invoice.profile.save() messages.success(req, invoice.profile.get_pack_display() + ' has successfully been activated!') return redirect('/profile/#pack') elif invoice.invoice_type == 'team': team_id = generate_team_id(req.user.email, invoice.event) r = Registration() r.event = invoice.event r.profile = req.user.profile r.team_id = team_id r.is_owner = True r.save() messages.success(req, 'Scucessfully registered for ' + r.event.title) return redirect(r.event.get_absolute_url() + '#view-team') elif invoice.invoice_type == 'test': messages.success(req, 'Payment success!') return redirect('/profile/#pack') # invalid invoice return None
def process_invoice(req, invoice): """ This is not a view, rather a helper function which processes the invoices """ invoice.status = req.POST.get('status', '') invoice.success = True invoice.pending = False invoice.post_data = str(req.POST) invoice.save() if invoice.invoice_type in ('single', 'multiple', 'upgrade'): new_pack = invoice.invoice_type payment = 100 if new_pack == 'multiple': payment = 200 elif new_pack == 'upgrade': payment = 100 new_pack = 'multiple' invoice.profile.pack = new_pack invoice.profile.total_payment += payment invoice.profile.save() messages.success( req, invoice.profile.get_pack_display() + ' has successfully been activated!') return redirect('/profile/#pack') elif invoice.invoice_type == 'team': team_id = generate_team_id(req.user.email, invoice.event) invoice.profile.total_payment += 500 invoice.profile.save() r = Registration() r.event = invoice.event r.profile = req.user.profile r.team_id = team_id r.is_owner = True r.save() messages.success(req, 'Scucessfully registered for ' + r.event.title) return redirect(r.event.get_absolute_url() + '#view-team') elif invoice.invoice_type == 'workshop': invoice.profile.registered_workshops.add(invoice.workshop) invoice.profile.total_payment += invoice.workshop.price invoice.profile.save() messages.success( req, 'Successfully registered for ' + invoice.workshop.title) return redirect('/workshops/') elif invoice.invoice_type == 'test': messages.success(req, 'Payment success!') return redirect('/profile/#pack') elif invoice.invoice_type == 'hospitality': invoice.profile.total_payment += invoice.amount invoice.profile.hospitality_days = invoice.days invoice.profile.save() # Success template_email('*****@*****.**', settings.ACCOMODATION_INCHARGE, 'New Accomodation Request', 'accomodation_request', { 'profile': invoice.profile, }) messages.success( req, 'Successfully applied for ' + str(invoice.days) + ' day(s)') return redirect('/profile/#hospitality') # invalid invoice return None
def process_invoice(req, invoice): """ This is not a view, rather a helper function which processes the invoices """ invoice.status = req.POST.get('status', '') invoice.success = True invoice.pending = False invoice.post_data = str(req.POST) invoice.save() if invoice.invoice_type in ('single', 'multiple', 'upgrade'): new_pack = invoice.invoice_type payment = 100 if new_pack == 'multiple': payment = 200 elif new_pack == 'upgrade': payment = 100 new_pack = 'multiple' invoice.profile.pack = new_pack invoice.profile.total_payment += payment invoice.profile.save() messages.success(req, invoice.profile.get_pack_display() + ' has successfully been activated!') return redirect('/profile/#pack') elif invoice.invoice_type == 'team': team_id = generate_team_id(req.user.email, invoice.event) invoice.profile.total_payment += 500 invoice.profile.save() r = Registration() r.event = invoice.event r.profile = req.user.profile r.team_id = team_id r.is_owner = True r.save() messages.success(req, 'Scucessfully registered for ' + r.event.title) return redirect(r.event.get_absolute_url() + '#view-team') elif invoice.invoice_type == 'workshop': invoice.profile.registered_workshops.add(invoice.workshop) invoice.profile.total_payment += invoice.workshop.price invoice.profile.save() messages.success(req, 'Successfully registered for ' + invoice.workshop.title) return redirect('/workshops/') elif invoice.invoice_type == 'test': messages.success(req, 'Payment success!') return redirect('/profile/#pack') elif invoice.invoice_type == 'hospitality': invoice.profile.total_payment += invoice.amount invoice.profile.hospitality_days = invoice.days invoice.profile.save() # Success template_email( '*****@*****.**', settings.ACCOMODATION_INCHARGE, 'New Accomodation Request', 'accomodation_request', { 'profile': invoice.profile, } ) messages.success(req, 'Successfully applied for ' + str(invoice.days) + ' day(s)') return redirect('/profile/#hospitality') # invalid invoice return None