コード例 #1
0
ファイル: views.py プロジェクト: AeonAxan/magnovite-2015
def success(req):
    if not test_checksum(req.POST):
        messages.error(req, 'Invalid Transaction, please contact support (Error: ES01)')
        mail_admins('S-Checksum Fail', str(req.POST) + '\n\n' + test_checksum(req.POST, debug=True))
        print(req.POST)
        return redirect('/profile/#help')

    invoice_id = int(req.POST.get('txnid', '').split('-')[-1])
    invoice = get_object_or_404(Invoice, id=invoice_id)

    # if already processed skip
    if invoice.pending == False:
        return redirect('/profile/#pack')

    return_val = process_invoice(req, invoice)

    # invalid invoice
    if return_val == None:
        messages.error(req, 'Transaction could not be completed, please contact support (Error: ES02)')
        return redirect('/profile/#help')
    else:
        # Success
        template_email(
            '*****@*****.**',
            (invoice.profile.active_email,),
            'Transaction Receipt',
            'payment_success',
            {
                'profile': invoice.profile,
                'invoice': invoice
            }
        )

        return return_val
コード例 #2
0
    def save(self, *args, **kwargs):
        # if we are adding a staff message then that thread
        # is no longer pending
        if self.is_staff:
            self.thread.is_pending = False
            self.thread.save()

        if self.should_email:
            template_email('*****@*****.**',
                           [self.thread.profile.active_email],
                           'Magnovite: Update on help request',
                           'admin_help_reply', {
                               'user': self.thread.profile,
                               'message': self
                           })

        super(Message, self).save(*args, **kwargs)
コード例 #3
0
    def save(self, *args, **kwargs):
        # if we are adding a staff message then that thread
        # is no longer pending
        if self.is_staff:
            self.thread.is_pending = False
            self.thread.save()

        if self.should_email:
            template_email(
                "*****@*****.**",
                [self.thread.profile.active_email],
                "Magnovite: Update on help request",
                "admin_help_reply",
                {"user": self.thread.profile, "message": self},
            )

        super(Message, self).save(*args, **kwargs)
コード例 #4
0
def success(req):
    if not test_checksum(req.POST):
        messages.error(
            req, 'Invalid Transaction, please contact support (Error: ES01)')
        mail_admins(
            'S-Checksum Fail',
            str(req.POST) + '\n\n' + test_checksum(req.POST, debug=True))
        print(req.POST)
        return redirect('/profile/#help')

    invoice_id = int(req.POST.get('txnid', '').split('-')[-1])
    invoice = get_object_or_404(Invoice, id=invoice_id)

    # if already processed skip
    if invoice.pending == False:
        return redirect('/profile/#pack')

    return_val = process_invoice(req, invoice)

    # invalid invoice
    if return_val == None:
        messages.error(
            req,
            'Transaction could not be completed, please contact support (Error: ES02)'
        )
        return redirect('/profile/#help')
    else:
        # Success
        template_email('*****@*****.**',
                       (invoice.profile.active_email, ), 'Transaction Receipt',
                       'payment_success', {
                           'profile': invoice.profile,
                           'invoice': invoice
                       })

        return return_val
コード例 #5
0
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
コード例 #6
0
ファイル: views.py プロジェクト: AeonAxan/magnovite-2015
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