Ejemplo n.º 1
0
def _generate_payment_entity(offer, dict):
    count = int(dict['count'])
    currency = dict['currency']
    payment = Payment.newPayment(offer, currency)
    parts = []
    sum = Decimal(0)
    btc_fee = Decimal(0)
    for i in range(count):
        pay_str = dict['pay_%s' % i]
        solution_id = int(dict['solutionId_%s' % i])
        if (pay_str):
            pay = Decimal(pay_str)
            if pay > 0:
                solution = Solution.objects.get(pk=solution_id)
                solution = Solution.objects.get(pk=solution_id)
                part = PaymentPart.newPart(payment, solution, pay)
                parts.append(part)
                sum += pay
                if currency == 'BTC':
                    btc_fee += settings.BITCOIN_FEE
    payment.fee = sum * settings.FS_FEE
    payment.total = sum
    payment.bitcoin_fee = btc_fee
    convert_twoplaces = currency == 'USD' or currency == 'BRL'
    if convert_twoplaces:
        payment.fee = twoplaces(payment.fee)
        payment.total = twoplaces(payment.total)
    payment.save()
    for part in parts:
        part.payment = payment
        if convert_twoplaces:
            part.price = twoplaces(part.price)
        part.save()
    return payment
def _generate_payment_entity(offer, receiver_count, dict, user):
    payment = Payment.newPayment(offer)
    parts = []
    sum = Decimal(0)
    for i in range(receiver_count):
        check = dict.has_key('check_%s' % i)
        if (check):
            pay = Decimal(dict['pay_%s' % i])
            if (pay > 0):
                solution = Solution.objects.get(pk=int(dict['solutionId_%s' %
                                                            i]))
                part = PaymentPart.newPart(payment, solution, pay)
                parts.append(part)
                sum += pay
    payment.fee = sum * settings.FS_FEE
    payment.total = sum
    convert_twoplaces = offer.currency == 'USD'
    if convert_twoplaces:
        payment.fee = twoplaces(payment.fee)
        payment.total = twoplaces(payment.total)
    payment.save()
    for part in parts:
        part.payment = payment
        if convert_twoplaces:
            part.price = twoplaces(part.price)
        part.save()
    return payment
Ejemplo n.º 3
0
def _generate_payment_entity(offer, dict):
    count = int(dict['count'])
    currency = dict['currency']
    payment = Payment.newPayment(offer, currency)
    parts = []
    sum = Decimal(0)
    btc_fee = Decimal(0)
    for i in range(count):
        pay_str = dict['pay_%s' % i]
        solution_id = int(dict['solutionId_%s' % i])
        if(pay_str):
            pay = Decimal(pay_str)
            if pay > 0:
                solution = Solution.objects.get(pk=solution_id)
                solution = Solution.objects.get(pk=solution_id)
                part = PaymentPart.newPart(payment, solution, pay)
                parts.append(part)
                sum += pay
                if currency == 'BTC':
                    btc_fee += settings.BITCOIN_FEE
    payment.fee = sum * settings.FS_FEE
    payment.total = sum
    payment.bitcoin_fee = btc_fee
    convert_twoplaces = currency == 'USD' or currency == 'BRL'
    if convert_twoplaces:
        payment.fee = twoplaces(payment.fee)
        payment.total = twoplaces(payment.total)
    payment.save()
    for part in parts:
        part.payment = payment
        if convert_twoplaces:
            part.price = twoplaces(part.price)
        part.save()
    return payment
def _generate_payment_entity(offer, receiver_count, dict, user):
    payment = Payment.newPayment(offer)
    parts = []
    sum = Decimal(0)
    realSum = Decimal(0)
    for i in range(receiver_count):
        check = dict.has_key('check_%s' % i)
        if(check):
            pay = Decimal(dict['pay_%s' % i])
            if(pay > 0):
                solution = Solution.objects.get(pk=int(dict['solutionId_%s' % i]))
                realPay = Decimal(pay * Decimal(1 - settings.FS_FEE)) #twoplaces
                part = PaymentPart.newPart(payment, solution, pay, realPay)
                parts.append(part)
                sum += pay
                realSum += realPay
    payment.fee = sum - realSum
    payment.total = sum
    convert_twoplaces = offer.currency == 'USD'
    if convert_twoplaces:
        payment.fee = twoplaces(payment.fee)
        payment.total = twoplaces(payment.total)
    payment.save()
    for part in parts:
        part.payment = payment
        if convert_twoplaces:
            part.price = twoplaces(part.price)
            part.realprice = twoplaces(part.realprice)
        part.save()
    return payment
Ejemplo n.º 5
0
def notify_payment_parties_and_watchers_paymentconfirmed(payment, watches):
    already_sent_to = {}
    for part in payment.getParts():
        _send_mail_to_user(
            user=part.programmer,
            subject=payment.offer.sponsor.username + " has made you a " +
            payment.get_currency_symbol() + " " + str(twoplaces(part.price)) +
            " payment",
            templateName='email/payment_received.html',
            contextData={
                "payment": payment,
                "part": part,
                "SITE_HOME": settings.SITE_HOME
            },
            whentrue=None,
            even_when_inactive=True,
        )
        already_sent_to[part.programmer.email] = True
    _send_mail_to_user(
        user=payment.offer.sponsor,
        subject="You have made a " + payment.get_currency_symbol() + " " +
        str(twoplaces(payment.total)) + " payment",
        templateName='email/payment_sent.html',
        contextData={
            "payment": payment,
            "SITE_HOME": settings.SITE_HOME
        },
        whentrue=None,
        even_when_inactive=True,
    )
    already_sent_to[payment.offer.sponsor.email] = True

    def send_func(watch):
        subject = "%s has paid his offer [%s %s / %s]" % (
            payment.offer.sponsor.username,
            payment.offer.get_currency_symbol(),
            str(twoplaces(payment.offer.price)), payment.offer.issue.title)
        contextData = {
            "you": watch.user,
            "issue": payment.offer.issue,
            "offer": payment.offer,
            "SITE_HOME": settings.SITE_HOME,
        }
        _send_mail_to_user(user=watch.user,
                           subject=subject,
                           templateName='email/payment_made.html',
                           contextData=contextData,
                           whentrue='receiveEmail_issue_payment')

    _notify_watchers(send_func, watches, already_sent_to)
def _payWithPaypalForm(request, offer):
    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()
    shared_price = None

    convert_rate = 1
    currency_symbol = "US$"
    alert_brazil = False
    if(offer.sponsor.getUserInfo().brazilianPaypal):
        convert_rate = paypal_services.usd_2_brl_convert_rate()
        currency_symbol = "R$"
        alert_brazil = True

    if(solutions_accepting_payments.count() > 0):
        shared_price = convert_rate * float(offer.price) / solutions_accepting_payments.count()
        shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response('core/pay_offer.html',
        {'offer':offer,
         'solutions_accepting_payments' : solutions_accepting_payments,
         'shared_price' : shared_price,
         'convert_rate' : convert_rate,
         'currency_symbol' : currency_symbol,
         'alert_brazil' : alert_brazil,
         },
        context_instance = RequestContext(request))
def notify_admin_payment_confirmed(payment):
    msg = 'payment confirmed: [%s %s / %s ]' % (
        payment.get_currency_symbol(),
        twoplaces(payment.total),
        payment.offer.issue.title
    )
    notify_admin(msg, payment.offer.get_view_link())
def notify_payment_parties_and_watchers_paymentconfirmed(payment, watches):
    already_sent_to = {}
    for part in payment.getParts():
        _send_mail_to_user(user = part.programmer, 
            subject = payment.offer.sponsor.getUserInfo().screenName+" has made you a "+payment.get_currency_symbol()+" "+str(twoplaces(part.price))+" payment",
            templateName = 'email/payment_received.html',
            contextData = {"payment" : payment,
            "part" : part,
            "SITE_HOME" : settings.SITE_HOME},
            whentrue=None)
        already_sent_to[part.programmer.email] = True
    _send_mail_to_user(user = payment.offer.sponsor,
        subject = "You have made a "+payment.get_currency_symbol()+" "+str(twoplaces(payment.total))+" payment",
        templateName = 'email/payment_sent.html',
        contextData = {"payment" : payment,
        "SITE_HOME" : settings.SITE_HOME},
        whentrue=None)
    already_sent_to[payment.offer.sponsor.email] = True
    def send_func(watch):
        subject = "%s has paid his offer [%s %s / %s]" % (
            payment.offer.sponsor.getUserInfo().screenName,
            payment.offer.get_currency_symbol(),
            str(twoplaces(payment.offer.price)),
            payment.offer.issue.title)
        contextData = {"you": watch.user,
                       "issue": payment.offer.issue,
                       "offer": payment.offer,
                       "SITE_HOME": settings.SITE_HOME,}
        _send_mail_to_user(user = watch.user,
            subject = subject,
            templateName = 'email/payment_made.html',
            contextData = contextData,
            whentrue='receiveEmail_issue_payment')
    _notify_watchers(send_func, watches, already_sent_to)
 def getTotalOffersPrice(self):
     offers = Offer.objects.filter(issue=self,status=Offer.OPEN)
     s = Decimal(0)
     for offer in offers:
         if (not offer.is_expired()):
             s = s + offer.price
     return twoplaces(s)
Ejemplo n.º 10
0
 def getTotalOffersPrice_by_currency(self, currency):
     offers = Offer.objects.filter(issue=self, status=Offer.OPEN,currency=currency)
     s = Decimal(0)
     for offer in offers:
         if (not offer.is_expired()):
             s = s + offer.price
     return twoplaces(s)
def payOfferForm(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()
    shared_price = None

    convert_rate = 1
    currency_symbol = "US$"
    alert_brazil = False
    if offer.sponsor.getUserInfo().brazilianPaypal:
        convert_rate = payment_services.usd_2_brl_convert_rate()
        currency_symbol = "R$"
        alert_brazil = True

    if solutions_accepting_payments.count() > 0:
        shared_price = convert_rate * float(offer.price) / solutions_accepting_payments.count()
        shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response(
        "core/pay_offer.html",
        {
            "offer": offer,
            "solutions_accepting_payments": solutions_accepting_payments,
            "shared_price": shared_price,
            "convert_rate": convert_rate,
            "currency_symbol": currency_symbol,
            "alert_brazil": alert_brazil,
        },
        context_instance=RequestContext(request),
    )
def payOfferForm(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    solutions_done = offer.issue.getSolutionsDone()
    shared_price = None

    convert_rate = 1
    currency_symbol = "US$"
    alert_brazil = False
    if(offer.sponsor.getUserInfo().brazilianPaypal):
        convert_rate = payment_services.usd_2_brl_convert_rate()
        currency_symbol = "R$"
        alert_brazil = True

    if(solutions_done.count() > 0):
        shared_price = convert_rate * float(offer.price) / solutions_done.count()
        shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response('core/pay_offer.html',
        {'offer':offer,
         'solutions_done' : solutions_done,
         'shared_price' : shared_price,
         'convert_rate' : convert_rate,
         'currency_symbol' : currency_symbol,
         'alert_brazil' : alert_brazil,
         },
        context_instance = RequestContext(request))
Ejemplo n.º 13
0
 def _get_total_open_price_by_currency(self, currency):
     offers = Offer.objects.filter(issue=self, status=Offer.OPEN, currency=currency)
     s = Decimal(0)
     for offer in offers:
         if not offer.is_expired():
             s = s + offer.price
     return twoplaces(s)
 def send_func(watch):
     subject = "%s has paid his offer [US$ %s / %s]" % (
         payment.offer.sponsor.getUserInfo().screenName, str(twoplaces(payment.offer.price)), payment.offer.issue.title)
     contextData = {"you": watch.user,
                    "issue": payment.offer.issue,
                    "offer": payment.offer,
                    "SITE_HOME": settings.SITE_HOME,}
     _send_mail_to_user(watch.user, subject, 'email/payment_made.html', contextData)
Ejemplo n.º 15
0
 def _get_total_paid_price_by_currency(self, currency):
     payments = Payment.objects.filter(status__in=[Payment.CONFIRMED_IPN, Payment.CONFIRMED_TRN],
                                       offer__issue=self,
                                       currency=currency)
     s = Decimal(0)
     for payment in payments:
         s = s + payment.total
     return twoplaces(s)
Ejemplo n.º 16
0
 def getTotalPaidPrice_by_currency(self, currency):
     offers = Offer.objects.filter(issue=self,
                                   status=Offer.PAID,
                                   currency=currency)
     s = Decimal(0)
     for offer in offers:
         s = s + offer.price
     return twoplaces(s)
Ejemplo n.º 17
0
 def _get_total_paid_price_by_currency(self, currency):
     payments = Payment.objects.filter(
         status__in=[Payment.CONFIRMED_IPN, Payment.CONFIRMED_TRN],
         offer__issue=self,
         currency=currency)
     s = Decimal(0)
     for payment in payments:
         s = s + payment.total
     return twoplaces(s)
def _payWithBitcoinForm(request, offer):
    if not settings.BITCOIN_ENABLED:
        messages.error(request, 'Payments with bitcoin have been disabled')
        return redirect(offer.get_view_link())
    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()

    if len(solutions_accepting_payments) == 0:
        messages.error(
            request,
            'Currently no programmers are accepting payments for this issue.')
        return redirect(offer.get_view_link())

    solutions_with_bitcoin = []
    solutions_without_bitcoin = []
    for solution in solutions_accepting_payments:
        if solution.programmer.getUserInfo().bitcoin_receive_address:
            solutions_with_bitcoin.append(solution)
        else:
            solutions_without_bitcoin.append(solution)
    if len(solutions_with_bitcoin) == 0:
        messages.error(
            request,
            "The programmer(s) who solved this issue have not registered a Bitcoin address yet, so you cannot pay them at this time.\n"
            +
            "Please leave a comment for them, asking them to update this info on their profile page, then come back here again."
        )
        return redirect(offer.get_view_link())
    if len(solutions_without_bitcoin) > 0:
        names = ', '.join(
            map(lambda solution: solution.programmer.getUserInfo().screenName,
                solutions_without_bitcoin))
        messages.warning(
            request,
            "The following programmer(s) have not registered a Bitcoin address: %s\n"
            % names +
            "Therefore, you won't be able to make a payment to them at this time.\n"
            +
            "If you want, you can leave a comment for them, asking them to update this info on their profile page, then come back here again."
        )

    convert_rate = 1
    currency_symbol = "BTC"
    alert_brazil = False
    shared_price = convert_rate * float(
        offer.price) / len(solutions_with_bitcoin)
    shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response('core/pay_offer.html', {
        'offer': offer,
        'solutions_accepting_payments': solutions_with_bitcoin,
        'shared_price': shared_price,
        'convert_rate': convert_rate,
        'currency_symbol': currency_symbol,
        'alert_brazil': alert_brazil,
    },
                              context_instance=RequestContext(request))
 def send_func(watch):
     if(watch.user.id != comment.author.id):
         subject = "%s added a comment on offer [US$ %s / %s]" % (
             comment.author.getUserInfo().screenName, str(twoplaces(comment.offer.price)), comment.offer.issue.title)
         contextData = {"you": watch.user,
                        "issue": comment.offer.issue,
                        "offer": comment.offer,
                        "comment": comment,
                        "SITE_HOME": settings.SITE_HOME,
                        "type": "offer"}
         _send_mail_to_user(watch.user, subject, 'email/comment_added.html', contextData)
 def send_func(watch):
     subject = "%s has paid his offer [%s %s / %s]" % (
         payment.offer.sponsor.getUserInfo().screenName,
         payment.offer.get_currency_symbol(),
         str(twoplaces(payment.offer.price)),
         payment.offer.issue.title)
     contextData = {"you": watch.user,
                    "issue": payment.offer.issue,
                    "offer": payment.offer,
                    "SITE_HOME": settings.SITE_HOME,}
     _send_mail_to_user(user = watch.user,
         subject = subject,
         templateName = 'email/payment_made.html',
         contextData = contextData,
         whentrue='receiveEmail_issue_payment')
Ejemplo n.º 21
0
 def send_func(watch):
     if (watch.user.id != offer.sponsor.id):
         _send_mail_to_user(
             user=watch.user,
             subject="%s revoked his %s %s offer for issue [%s]" %
             (offer.sponsor.username, offer.get_currency_symbol(),
              str(twoplaces(offer.price)), offer.issue.title),
             templateName='email/offerrevoked.html',
             contextData={
                 "you": watch.user,
                 "offer": offer,
                 "SITE_HOME": settings.SITE_HOME,
                 "comment": comment
             },
             whentrue='receiveEmail_issue_offer')
 def send_func(watch):
     subject = "%s has paid his offer [%s %s / %s]" % (
         payment.offer.sponsor.username,
         payment.offer.get_currency_symbol(),
         str(twoplaces(payment.offer.price)),
         payment.offer.issue.title)
     contextData = {"you": watch.user,
                    "issue": payment.offer.issue,
                    "offer": payment.offer,
                    "SITE_HOME": settings.SITE_HOME,}
     _send_mail_to_user(user = watch.user,
         subject = subject,
         templateName = 'email/payment_made.html',
         contextData = contextData,
         whentrue='receiveEmail_issue_payment')
 def send_func(watch):
     if(watch.user.id != offer.sponsor.id):
         _send_mail_to_user(user = watch.user,
             subject = "%s revoked his %s %s offer for issue [%s]" % (
                 offer.sponsor.username,
                 offer.get_currency_symbol(),
                 str(twoplaces(offer.price)),
                 offer.issue.title
             ),
             templateName = 'email/offerrevoked.html',
             contextData = {"you" : watch.user,
                            "offer" : offer,
                            "SITE_HOME" : settings.SITE_HOME,
                            "comment" : comment},
             whentrue='receiveEmail_issue_offer')
def _payWithPaypalForm(request, offer):
    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()

    solutions_with_paypal = []
    solutions_without_paypal = []
    for solution in solutions_accepting_payments:
        try: 
            accepts_paypal = paypal_services.accepts_paypal_payments(solution.programmer)
        except BaseException as e:
            traceback.print_exc()
            messages.error(request, 'Error communicating with Paypal: %s' % e)
            mail_services.notify_admin('Error determining if user accepts paypal', traceback.format_exc())
            return redirect(offer.get_view_link())
        if accepts_paypal:
            solutions_with_paypal.append(solution)
        else:
            solutions_without_paypal.append(solution)

    if len(solutions_with_paypal) == 0:
        messages.error(request, "The programmer(s) who solved this issue do not have a verified Paypal account yet, so you cannot pay them at this time.\n"+
                                "Please leave a comment for them, asking them to update their profile page with an email of a verified Paypal account, then come back here again.")
        return redirect(offer.get_view_link())
    if len(solutions_without_paypal) > 0:
        names = ', '.join(map(lambda solution:solution.programmer.getUserInfo().screenName, solutions_without_paypal))
        messages.warning(request, "The following programmer(s) do not have a verified Paypal account yet: %s\n" % names+
                                  "Therefore, you won't be able to make a payment to them at this time.\n"+
                                  "If you want, you can leave a comment for them, asking them to update their profile page with an email of a verified Paypal account, then come back here again.")

    convert_rate = 1
    currency_symbol = "US$"
    alert_brazil = False
    if(offer.sponsor.getUserInfo().brazilianPaypal):
        convert_rate = paypal_services.usd_2_brl_convert_rate()
        currency_symbol = "R$"
        alert_brazil = True

    shared_price = convert_rate * float(offer.price) / len(solutions_with_paypal)
    shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response('core/pay_offer.html',
        {'offer':offer,
         'solutions_accepting_payments' : solutions_with_paypal,
         'shared_price' : shared_price,
         'convert_rate' : convert_rate,
         'currency_symbol' : currency_symbol,
         'alert_brazil' : alert_brazil,
         },
        context_instance = RequestContext(request))
Ejemplo n.º 25
0
 def send_func(watch):
     if (watch.user.id != new_offer.sponsor.id):
         _send_mail_to_user(
             user=watch.user,
             subject=old_offer.sponsor.username + " " + action +
             " the " + old_offer.get_currency_symbol() + " " +
             str(twoplaces(old_offer.price)) +
             " offer on issue [%s]" % old_offer.issue.title,
             templateName='email/offerchanged.html',
             contextData={
                 "you": watch.user,
                 "old_offer": old_offer,
                 "new_offer": new_offer,
                 "action": action,
                 "SITE_HOME": settings.SITE_HOME
             },
             whentrue='receiveEmail_issue_offer')
Ejemplo n.º 26
0
 def send_func(watch):
     if watch.user.id != comment.author.id:
         subject = "%s added a comment on offer [%s %s / %s]" % (
             comment.author.username, comment.offer.get_currency_symbol(),
             str(twoplaces(comment.offer.price)), comment.offer.issue.title)
         contextData = {
             "you": watch.user,
             "issue": comment.offer.issue,
             "offer": comment.offer,
             "comment": comment,
             "SITE_HOME": settings.SITE_HOME,
             "type": "offer"
         }
         _send_mail_to_user(user=watch.user,
                            subject=subject,
                            templateName='email/comment_added.html',
                            contextData=contextData,
                            whentrue='receiveEmail_issue_comments')
 def send_func(watch):
     if(watch.user.id != comment.author.id):
         subject = "%s added a comment on offer [%s %s / %s]" % (
             comment.author.getUserInfo().screenName,
             comment.offer.get_currency_symbol(),
             str(twoplaces(comment.offer.price)),
             comment.offer.issue.title)
         contextData = {"you": watch.user,
                        "issue": comment.offer.issue,
                        "offer": comment.offer,
                        "comment": comment,
                        "SITE_HOME": settings.SITE_HOME,
                        "type": "offer"}
         _send_mail_to_user(user = watch.user,
             subject = subject,
             templateName = 'email/comment_added.html',
             contextData = contextData,
             whentrue='receiveEmail_issue_comments')
def _payWithBitcoinForm(request, offer):
    if not settings.BITCOIN_ENABLED:
        messages.error(request, 'Payments with bitcoin have been disabled')
        return redirect(offer.get_view_link())
    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()

    if len(solutions_accepting_payments) == 0:
        messages.error(request, 'Currently no programmers are accepting payments for this issue.')
        return redirect(offer.get_view_link())

    solutions_with_bitcoin = []
    solutions_without_bitcoin = []
    for solution in solutions_accepting_payments:
        if solution.programmer.getUserInfo().bitcoin_receive_address:
            solutions_with_bitcoin.append(solution)
        else:
            solutions_without_bitcoin.append(solution)
    if len(solutions_with_bitcoin) == 0:
        messages.error(request, "The programmer(s) who solved this issue have not registered a Bitcoin address yet, so you cannot pay them at this time.\n"+
            "Please leave a comment for them, asking them to update this info on their profile page, then come back here again.")
        return redirect(offer.get_view_link())
    if len(solutions_without_bitcoin) > 0:
        names = ', '.join(map(lambda solution:solution.programmer.getUserInfo().screenName, solutions_without_bitcoin))
        messages.warning(request, "The following programmer(s) have not registered a Bitcoin address: %s\n" % names+
            "Therefore, you won't be able to make a payment to them at this time.\n"+
            "If you want, you can leave a comment for them, asking them to update this info on their profile page, then come back here again.")
            
    convert_rate = 1
    currency_symbol = "BTC"
    alert_brazil = False
    shared_price = convert_rate * float(offer.price) / len(solutions_with_bitcoin)
    shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response('core/pay_offer.html',
        {'offer':offer,
         'solutions_accepting_payments' : solutions_with_bitcoin,
         'shared_price' : shared_price,
         'convert_rate' : convert_rate,
         'currency_symbol' : currency_symbol,
         'alert_brazil' : alert_brazil,
         },
        context_instance = RequestContext(request))
Ejemplo n.º 29
0
 def getTotalPaidPrice_by_currency(self, currency):
     offers = Offer.objects.filter(issue=self, status=Offer.PAID, currency=currency)
     s = Decimal(0)
     for offer in offers:
         s = s + offer.price
     return twoplaces(s)
 def send_func(watch):
     if(watch.user.id != new_offer.sponsor.id):
         _send_mail_to_user(user = watch.user,
             subject = old_offer.sponsor.getUserInfo().screenName+" "+action+" the US$ "+str(twoplaces(old_offer.price))+" offer on issue [%s]"%old_offer.issue.title,
             templateName = 'email/offerchanged.html',
             contextData = {"you" : watch.user,
                            "old_offer" : old_offer,
                            "new_offer" : new_offer,
                            "action" : action,
                            "SITE_HOME" : settings.SITE_HOME})
def _payWithPaypalForm(request, offer):
    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()

    solutions_with_paypal = []
    solutions_without_paypal = []
    for solution in solutions_accepting_payments:
        try:
            accepts_paypal = paypal_services.accepts_paypal_payments(
                solution.programmer)
        except BaseException as e:
            traceback.print_exc()
            messages.error(request, 'Error communicating with Paypal: %s' % e)
            mail_services.notify_admin(
                'Error determining if user accepts paypal',
                traceback.format_exc())
            return redirect(offer.get_view_link())
        if accepts_paypal:
            solutions_with_paypal.append(solution)
        else:
            solutions_without_paypal.append(solution)

    if len(solutions_with_paypal) == 0:
        messages.error(
            request,
            "The programmer(s) who solved this issue do not have a verified Paypal account yet, so you cannot pay them at this time.\n"
            +
            "Please leave a comment for them, asking them to update their profile page with an email of a verified Paypal account, then come back here again."
        )
        return redirect(offer.get_view_link())
    if len(solutions_without_paypal) > 0:
        names = ', '.join(
            map(lambda solution: solution.programmer.getUserInfo().screenName,
                solutions_without_paypal))
        messages.warning(
            request,
            "The following programmer(s) do not have a verified Paypal account yet: %s\n"
            % names +
            "Therefore, you won't be able to make a payment to them at this time.\n"
            +
            "If you want, you can leave a comment for them, asking them to update their profile page with an email of a verified Paypal account, then come back here again."
        )

    convert_rate = 1
    currency_symbol = "US$"
    alert_brazil = False
    if (offer.sponsor.getUserInfo().brazilianPaypal):
        convert_rate = paypal_services.usd_2_brl_convert_rate()
        currency_symbol = "R$"
        alert_brazil = True

    shared_price = convert_rate * float(
        offer.price) / len(solutions_with_paypal)
    shared_price = twoplaces(Decimal(str(shared_price)))

    return render_to_response('core/pay_offer.html', {
        'offer': offer,
        'solutions_accepting_payments': solutions_with_paypal,
        'shared_price': shared_price,
        'convert_rate': convert_rate,
        'currency_symbol': currency_symbol,
        'alert_brazil': alert_brazil,
    },
                              context_instance=RequestContext(request))
 def send_func(watch):
     if(watch.user.id != offer.sponsor.id):
         _send_mail_to_user(user = watch.user,
             subject = offer.sponsor.getUserInfo().screenName+" revoked his US$ "+str(twoplaces(offer.price))+" offer for issue [%s]"%offer.issue.title,
             templateName = 'email/offerrevoked.html',
             contextData = {"you" : watch.user,
                            "offer" : offer,
                            "SITE_HOME" : settings.SITE_HOME,
                            "comment" : comment})
Ejemplo n.º 33
0
 def get_full_value_with_fee(self):
     v = self.total_with_fee()
     if self.currency != 'BTC':
         v = twoplaces(v)
     return '%s %s' % (self.get_currency_symbol(), v)
Ejemplo n.º 34
0
 def get_full_value(self):
     v = self.price
     if self.payment.currency != 'BTC':
         v = twoplaces(v)
     return '%s %s' % (self.payment.get_currency_symbol(), v)
 def send_func(watch):
     if(watch.user.id != new_offer.sponsor.id):
         _send_mail_to_user(
             user = watch.user,
             subject = old_offer.sponsor.username+" "+action+" the "+old_offer.get_currency_symbol()+" "+str(twoplaces(old_offer.price))+" offer on issue [%s]"%old_offer.issue.title,
             templateName = 'email/offerchanged.html',
             contextData = {"you" : watch.user,
                            "old_offer": old_offer,
                            "new_offer": new_offer,
                            "action": action,
                            "SITE_HOME": settings.SITE_HOME},
             whentrue='receiveEmail_issue_offer'
         )
Ejemplo n.º 36
0
 def price_2(self):
     return twoplaces(self.price)
Ejemplo n.º 37
0
def notify_admin_payment_confirmed(payment):
    msg = 'payment confirmed: [%s %s / %s ]' % (payment.get_currency_symbol(),
                                                twoplaces(payment.total),
                                                payment.offer.issue.title)
    notify_admin(msg, payment.offer.get_view_link())
Ejemplo n.º 38
0
 def get_full_value(self):
     v = self.price
     if self.payment.currency != 'BTC':
         v = twoplaces(v)
     return '%s %s' % (self.payment.get_currency_symbol(), v)
 def getTotalPaidPrice(self):
     offers = Offer.objects.filter(issue=self,status=Offer.PAID)
     s = Decimal(0)
     for offer in offers:
         s = s + offer.price
     return twoplaces(s)
Ejemplo n.º 40
0
 def get_full_value_with_fee(self):
     v = self.total_with_fee()
     if self.currency != 'BTC':
         v = twoplaces(v)
     return '%s %s' % (self.get_currency_symbol(), v)