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 _log_error_difference_between_sent_values(part, value):
    msg = (
        "Theres a difference between bitcoin sent values. part id = %s,\n part price = %s,\n value sent = %s, \nissue = %s"
        % (part.id, part.price, value, part.payment.offer.issue.title)
    )
    mail_services.notify_admin("Theres a difference between bitcoin sent values", msg)
    logger.error(msg)
def _log_warning_sent_bitcoins_outside_fs(destination_address, transaction_hash, value):
    msg = 'Sent bitcoins outside FS. address = %s,\n value = %s,\n hash = %s' % (
        destination_address,
        value,
        transaction_hash)
    mail_services.notify_admin('Sent bitcoins outside FS', msg)
    logger.warning(msg)
def _log_error_difference_between_sent_values(part, value):
    msg = 'Theres a difference between bitcoin sent values. part id = %s,\n part price = %s,\n value sent = %s, \nissue = %s' % (
        part.id,
        part.price,
        value,
        part.payment.offer.issue.title)
    mail_services.notify_admin('Theres a difference between bitcoin sent values', msg)
    logger.error(msg)
def _create_project(issueInfo, createdByUser):
    project = Project.newProject(issueInfo.project_name, createdByUser, '', issueInfo.project_trackerURL)
    project.save()
    notify_admin("INFO: Project created from json view", "issue key: "+issueInfo.key+"\n<br>"+ \
        "issue key: "+issueInfo.key+"\n<br>"+ \
        "project : "+project.name+"\n<br>"+ \
        "project.trackerURL: "+project.trackerURL+"\n<br>")
    return project
Example #6
0
def _create_project(issueInfo, createdByUser):
    project = Project.newProject(issueInfo.project_name, createdByUser, '',
                                 issueInfo.project_trackerURL)
    project.save()
    notify_admin("INFO: Project created from json view", "issue key: "+issueInfo.key+"\n<br>"+ \
        "issue key: "+issueInfo.key+"\n<br>"+ \
        "project : "+project.name+"\n<br>"+ \
        "project.trackerURL: "+project.trackerURL+"\n<br>")
    return project
Example #7
0
def _log_error_ipn_receive_double_payment(payment, transaction_hash, value):
    msg = """payment id: %s
old txn hash: %s
old value: %s
new txn hash: %s
new value: %s""" % (payment.id, payment.bitcoin_transaction_hash,
                    payment.total_bitcoin_received, transaction_hash, value)
    mail_services.notify_admin('bitcoin IPN RECEIVE double payment', msg)
    logger.error(msg)
Example #8
0
def _log_info_active_receive_confirmation(address, amount_received, payment):
    if payment.status == Payment.CONFIRMED_TRN:
        msg = 'Actively Confirmed bitcoin full receive: %s/%s, addr: %s, payment_id: %s, issue: %s' % (
            amount_received, payment.total, address, payment.id,
            payment.offer.issue.title)
    else:
        msg = 'Actively Confirmed bitcoin underpay: %s/%s, addr: %s, payment_id: %s, issue: %s' % (
            amount_received, payment.total, address, payment.id,
            payment.offer.issue.title)
        mail_services.notify_admin('Received bitcoin underpay', msg)
    logger.info(msg)
def _notify_ipn_receive_double_payment(payment, transaction_hash, value):
        mail_services.notify_admin('bitcoin IPN RECEIVE double payment',
            """payment id: %s
old txn hash: %s
old value: %s
new txn hash: %s
new value: %s""" % (payment.id,
                    payment.bitcoin_transaction_hash,
                    payment.total_bitcoin_received,
                    transaction_hash,
                    value))
def addFeedback(request):
    dict = request.POST
    issue_title = dict['title']
    issue_description = dict['description']
    if not issue_title or not issue_description:
        raise BaseException(_('title and description are required'))
    issue = Issue.newIssueFeedback(issue_title, issue_description, request.user)
    issue.save()
    watch_services.watch_issue(request.user, issue.id, Watch.CREATED)
    notify_admin(_('new Feedback: %s') % issue_title, issue_description)
    return redirect('feedback')
Example #11
0
def addFeedback(request):
    dict = request.POST
    issue_title = dict['title']
    issue_description = dict['description']
    if not issue_title or not issue_description:
        raise BaseException(_('title and description are required'))
    issue = Issue.newIssueFeedback(issue_title, issue_description, request.user)
    issue.save()
    watch_services.watch_issue(request.user, issue.id, Watch.CREATED)
    notify_admin(_('new Feedback: %s') % issue_title, issue_description)
    return redirect('core.views.feedback_views.feedback')
def bitcoin_ipn_received(value, destination_address, transaction_hash, confirmations):
    receive_address = get_or_none(ReceiveAddress, address = destination_address)
    if not receive_address:
        mail_services.notify_admin('Received bitcoins outside FS', 'address = %s, value = %s' % (destination_address, value))
    else:
        payment = Payment.objects.get(bitcoin_receive_address__id = receive_address.id)
        double_payment = payment.bitcoin_transaction_hash and payment.bitcoin_transaction_hash != transaction_hash
        if not double_payment:
            payment.confirm_bitcoin_ipn(value, transaction_hash)
        else :
            _notify_ipn_receive_double_payment(payment, transaction_hash, value)
def addFeedback(request):
    dict = request.POST
    issue_title = dict["title"]
    issue_description = dict["description"]
    if not issue_title or not issue_description:
        raise BaseException(_("title and description are required"))
    issue = Issue.newIssueFeedback(issue_title, issue_description, request.user)
    issue.save()
    watch_services.watch_issue(request.user, issue.id, Watch.CREATED)
    notify_admin(_("new Feedback: %s") % issue_title, issue_description)
    return redirect("core.views.feedback_views.feedback")
Example #14
0
def deactivate_user(user):
    for solution in Solution.objects.filter(programmer=user, status=Solution.IN_PROGRESS):
        solution.abort()
    for offer in Offer.objects.filter(sponsor=user, status=Offer.OPEN):
        offer.revoke()
    Watch.objects.filter(user=user).delete()
    user.is_active = False
    user.save()
    mail_services.deactivated(user)
    subject = 'user deactivated: %s/%s' % (user.id, user.username)
    body = '<a href="http://freedomsponsors.org/user/%s">%s</a>' % (user.id, user.username)
    mail_services.notify_admin(subject, body)
def bitcoin_ipn_received(value, destination_address, transaction_hash, confirmations):
    receive_address = get_or_none(ReceiveAddress, address=destination_address)
    if receive_address:
        payment = Payment.objects.get(bitcoin_receive_address__id=receive_address.id)
        double_payment = payment.bitcoin_transaction_hash and payment.bitcoin_transaction_hash != transaction_hash
        if not double_payment:
            payment.confirm_bitcoin_ipn(value, transaction_hash)
            _log_info_ipn_receive_confirmation(payment)
        else :
            _log_error_ipn_receive_double_payment(payment, transaction_hash, value)
    else:
        mail_services.notify_admin('Received bitcoins outside FS', 'address = %s,\n value = %s,\n hash = %s' % (destination_address, value, transaction_hash))
def _log_error_ipn_receive_double_payment(payment, transaction_hash, value):
    msg = """payment id: %s
old txn hash: %s
old value: %s
new txn hash: %s
new value: %s""" % (
        payment.id,
        payment.bitcoin_transaction_hash,
        payment.total_bitcoin_received,
        transaction_hash,
        value,
    )
    mail_services.notify_admin("bitcoin IPN RECEIVE double payment", msg)
    logger.error(msg)
def _append_project_id_and_update_db_if_needed(issueInfo, trackerURL, user):
    issueInfo.project_id = ''
    project = None
    if(issueInfo.project_trackerURL):
        found_projects = Project.objects.filter(trackerURL__iexact=issueInfo.project_trackerURL)
        if(found_projects.count() > 1):
            notify_admin("WARNING: Database inconsistency", "more than one project found with url = %s"%issueInfo.project_trackerURL)
        elif(found_projects.count() == 1):
            project = found_projects[0]
            _update_project_name_if_needed(project, issueInfo.project_name)
        else:
            project = _create_project(issueInfo, user)
    if(project):
        issueInfo.project_id = project.id
        issueInfo.project_homeURL = project.homeURL
Example #18
0
def sponsor_existing_issue(issue_id, dict, user):
    issue = Issue.objects.get(pk=issue_id)
    _throwIfAlreadySponsoring(issue, user)
    offer = _buildOfferFromDictionary_and_issue(dict, user, issue)
    offer.save()
    notifyProgrammers_offeradded(offer)
    notifySponsors_offeradded(offer)
    msg = "offer: " + str(offer.price) + "\n<br>" +\
          "issue key: " + offer.issue.key + "\n<br>" +\
          "issue title: " + offer.issue.title + "\n<br>"
    if (offer.issue.project):
        msg += "project : " + offer.issue.project.name + "\n<br>" +\
               "project.trackerURL: " + offer.issue.project.trackerURL + "\n<br>"
    notify_admin("INFO: Existing issue sponsored", msg)
    return offer
def sponsor_existing_issue(issue_id, dict, user):
    issue = Issue.objects.get(pk=issue_id)
    _throwIfAlreadySponsoring(issue, user)
    offer = _buildOfferFromDictionary_and_issue(dict, user, issue);
    offer.save()
    notifyProgrammers_offeradded(offer)
    notifySponsors_offeradded(offer)
    msg = "offer: " + str(offer.price) + "\n<br>" +\
          "issue key: " + offer.issue.key + "\n<br>" +\
          "issue title: " + offer.issue.title + "\n<br>"
    if(offer.issue.project):
        msg += "project : " + offer.issue.project.name + "\n<br>" +\
               "project.trackerURL: " + offer.issue.project.trackerURL + "\n<br>"
    notify_admin("INFO: Existing issue sponsored", msg)
    return offer
Example #20
0
def fetchIssueInfo(issueURL):
    if (looks_like_github(issueURL)):
        info = retriveGithubInfo(issueURL)
    elif (looks_like_jira(issueURL)):
        info = retriveJIRAInfo(issueURL)
    elif (looks_like_bugzilla(issueURL)):
        info = retriveBugzillaInfo(issueURL)
    elif (looks_like_bitbucket(issueURL)):
        info = retrieveBitBucketInfo(issueURL)
    else:
        info = IssueInfo()
    if (info.error):
        print 'Error fetching info for: ' + issueURL + ' - ' + info.error
        notify_admin('Error fetching info for: ' + issueURL, info.error)
    return info
def bitcoin_ipn_received(value, destination_address, transaction_hash, confirmations):
    receive_address = get_or_none(ReceiveAddress, address=destination_address)
    if receive_address:
        payment = Payment.objects.get(bitcoin_receive_address__id=receive_address.id)
        double_payment = payment.bitcoin_transaction_hash and payment.bitcoin_transaction_hash != transaction_hash
        if not double_payment:
            payment.confirm_bitcoin_ipn(value, transaction_hash)
            _log_info_ipn_receive_confirmation(payment)
        else:
            _log_error_ipn_receive_double_payment(payment, transaction_hash, value)
    else:
        mail_services.notify_admin(
            "Received bitcoins outside FS",
            "address = %s,\n value = %s,\n hash = %s" % (destination_address, value, transaction_hash),
        )
def fetchIssueInfo(issueURL):
	if(looks_like_github(issueURL)):
		info = retriveGithubInfo(issueURL)
	elif(looks_like_jira(issueURL)):
		info = retriveJIRAInfo(issueURL)
	elif(looks_like_bugzilla(issueURL)):
		info = retriveBugzillaInfo(issueURL)
	elif(looks_like_bitbucket(issueURL)):
		info = retrieveBitBucketInfo(issueURL)
	else:
		info = IssueInfo()
	if(info.error):
		print 'Error fetching info for: '+issueURL+' - '+info.error
		notify_admin('Error fetching info for: '+issueURL, info.error)
	return info
Example #23
0
def payOfferForm(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    is_brazilian = offer.sponsor.getUserInfo().brazilianPaypal

    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()
    if not solutions_accepting_payments:
        messages.error(
            request, 'No developers are accepting payments for this issue yet')
        return redirect(offer.issue.get_view_link())

    solutions_dict = []
    for solution in solutions_accepting_payments:
        programmer_userinfo = solution.programmer.getUserInfo()
        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.issue.get_view_link())
        solutions_dict.append({
            'id':
            solution.id,
            'status':
            solution.status,
            'programmerUsername':
            solution.programmer.username,
            'acceptsPaypal':
            accepts_paypal,
            'acceptsBitcoin':
            True and programmer_userinfo.bitcoin_receive_address,
            'imglink':
            solution.programmer.gravatar_url_small()
        })
    currency_options = _currency_options(offer)
    return render_to_response(
        'core2/pay_offer_angular.html', {
            'offer': offer,
            'count': len(solutions_dict),
            'currency_options': currency_options,
            'currency_options_json': json.dumps(currency_options),
            'is_brazilian': is_brazilian,
            'solutions_json': json.dumps(solutions_dict)
        },
        context_instance=RequestContext(request))
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 paypalReturn(request):
    current_payment_id = request.session.get('current_payment_id')
    if current_payment_id:
        curr_payment, msg = paypal_services.payment_confirmed_web(current_payment_id)
        del request.session['current_payment_id']
        logger.info('CONFIRM_WEB successful for payment %s'%curr_payment.id)
        messages.warning(request, "Your payment is being processed. You'll receive an email when your payment is confirmed.")
        return redirect(curr_payment.offer.issue.get_view_link())
    else:
        subject = 'CONFIRM_WEB received while no payment in session. user = %s' % request.user.id
        msg = 'GET %s\nPOST %s' % (request.GET, request.POST)
        mail_services.notify_admin(subject, msg)
        logger.warn(subject)
        logger.warn(msg)
        messages.error(request, _('Session expired. Please check your offer status'))
        return redirect('/')
def _notify_payment_finished_if_applicable(payment_id):
    payment = Payment.objects.get(pk=payment_id)
    parts = PaymentPart.objects.filter(payment__id=payment.id)
    is_finished = True
    for part in parts:
        if part.money_sent.status != MoneySent.CONFIRMED_TRN:
            is_finished = False
            break
    if is_finished:
        payment.offer.paid()
        watches = watch_services.find_issue_and_offer_watches(payment.offer)
        mail_services.notify_payment_parties_and_watchers_paymentconfirmed(payment, watches)
        msg = 'payment_id=%s, value=%s, issue=%s' % (
            payment.id,
            payment.total_bitcoin_received,
            payment.offer.issue.title)
        mail_services.notify_admin('Bitcoin payment made - %s'%payment.total_bitcoin_received, msg)
def add_new_issue_and_offer(dict, user):
    offer = _buildOfferFromDictionary(dict, user)
    if(offer.issue.project):
        offer.issue.project.save()
        offer.issue.project = offer.issue.project
    if(not offer.issue.id):
        offer.issue.save()
        offer.issue = offer.issue
    offer.save()
    msg = "offer: " + str(offer.price) + "\n<br>" +\
          "issue key: " + offer.issue.key + "\n<br>" +\
          "issue title: " + offer.issue.title + "\n<br>"
    if(offer.issue.project):
        msg += "project : " + offer.issue.project.name + "\n<br>" +\
               "project.trackerURL: " + offer.issue.project.trackerURL + "\n<br>"
    notify_admin("INFO: New issue sponsored", msg)
    return offer
def _log_info_active_receive_confirmation(address, amount_received, payment):
    if payment.status == Payment.CONFIRMED_TRN:
        msg = 'Actively Confirmed bitcoin full receive: %s/%s, addr: %s, payment_id: %s, issue: %s' % (
            amount_received,
            payment.total,
            address,
            payment.id,
            payment.offer.issue.title)
    else:
        msg = 'Actively Confirmed bitcoin underpay: %s/%s, addr: %s, payment_id: %s, issue: %s' % (
            amount_received,
            payment.total,
            address,
            payment.id,
            payment.offer.issue.title)
        mail_services.notify_admin('Received bitcoin underpay', msg)
    logger.info(msg)
def is_verified_account(email):
    try:
        response = paypal.pay(
            actionType = 'PAY',
            cancelUrl = settings.PAYPAL_CANCEL_URL,
            currencyCode = 'USD',
            feesPayer = 'SENDER',
            receiverList = { 'receiver': { 'amount' : '10.00', 'email' : email } },
            returnUrl = settings.PAYPAL_RETURN_URL,
            ipnNotificationUrl = settings.PAYPAL_IPNNOTIFY_URL
        )
        return True
    except PaypalError as e:
        if e.code != '520009':
            msg = 'email:%s, error:%s' % (email, e)
            mail_services.notify_admin("Unexpected error from Paypal when trying to see if account exists", msg)
        return False
Example #30
0
def change_username(user, new_username):
    can_change = user.getUserInfo().can_change_username
    if not can_change:
        raise FSException('You cannot change your username anymore.')
    if not is_valid_username(new_username):
        raise FSException('Sorry, this username is invalid (usernames must not contain special characters).')
    if not is_username_available(new_username):
        raise FSException('Sorry, that username is already taken.')
    old_username = user.username
    user.username = new_username
    user.save()
    userinfo = user.getUserInfo()
    userinfo.can_change_username = False
    userinfo.save()
    subject = 'user %s changed username %s --> %s' % (user.id, old_username, new_username)
    body = '<a href="http://freedomsponsors.org/user/%s">%s</a>' % (user.id, new_username)
    mail_services.notify_admin(subject, body)
Example #31
0
def add_new_issue_and_offer(dict, user):
    offer = _buildOfferFromDictionary(dict, user)
    if (offer.issue.project):
        offer.issue.project.save()
        offer.issue.project = offer.issue.project
    if (not offer.issue.id):
        offer.issue.save()
        offer.issue = offer.issue
    offer.save()
    msg = "offer: " + str(offer.price) + "\n<br>" +\
          "issue key: " + offer.issue.key + "\n<br>" +\
          "issue title: " + offer.issue.title + "\n<br>"
    if (offer.issue.project):
        msg += "project : " + offer.issue.project.name + "\n<br>" +\
               "project.trackerURL: " + offer.issue.project.trackerURL + "\n<br>"
    notify_admin("INFO: New issue sponsored", msg)
    return offer
def process_ipn_return(paykey, status, tracking_id):
    if status == 'COMPLETED':
        payment = get_or_none(Payment, paykey=paykey, confirm_key=tracking_id)
        if not payment:
            raise BaseException('payment not found ' + paykey)
        if payment.status == Payment.CONFIRMED_IPN:
            return  # double notification, nothing to do
        payment.confirm_ipn()
        payment.offer.paid()
        payment.offer.issue.touch()
        watches = watch_services.find_issue_and_offer_watches(payment.offer)
        notify_payment_parties_and_watchers_paymentconfirmed(payment, watches)
        notify_admin_payment_confirmed(payment)
    else:
        subject = 'received a payment confirmation with status = %s' % status
        msg = 'paykey = %s\nconfirm_key=%s' % (paykey, tracking_id)
        mail_services.notify_admin(subject, msg)
        logger.warn(subject)
        logger.warn(msg)
Example #33
0
def fetchIssueInfo(issueURL):
    if looks_like_github(issueURL):
        info = retriveGithubInfo(issueURL)
    elif looks_like_jira(issueURL):
        info = retriveJIRAInfo(issueURL)
    elif looks_like_bugzilla(issueURL):
        info = retriveBugzillaInfo(issueURL)
    elif looks_like_bitbucket(issueURL):
        info = retrieveBitBucketInfo(issueURL)
    elif looks_like_google_code(issueURL):
        info = retrieveGoogleCodeInfo(issueURL)
    else:
        info = IssueInfo()
    if hasattr(info, 'description'):
        info.description = html2text.html2text(info.description)
    if info.error:
        print 'Error fetching info for: ' + issueURL + ' - ' + info.error
        notify_admin('Error fetching info for: ' + issueURL, info.error)
    return info
def fetchIssueInfo(issueURL):
    if looks_like_github(issueURL):
        info = retriveGithubInfo(issueURL)
    elif looks_like_jira(issueURL):
        info = retriveJIRAInfo(issueURL)
    elif looks_like_bugzilla(issueURL):
        info = retriveBugzillaInfo(issueURL)
    elif looks_like_bitbucket(issueURL):
        info = retrieveBitBucketInfo(issueURL)
    elif looks_like_google_code(issueURL):
        info = retrieveGoogleCodeInfo(issueURL)
    else:
        info = IssueInfo()
    if hasattr(info, 'description'):
        info.description = html2text.html2text(info.description)
    if info.error:
        print 'Error fetching info for: '+issueURL+' - '+info.error
        notify_admin('Error fetching info for: '+issueURL, info.error)
    return info
def process_ipn_return(paykey, status, tracking_id):
    if status == 'COMPLETED':
        payment = get_or_none(Payment, paykey=paykey, confirm_key=tracking_id)
        if not payment:
            raise BaseException('payment not found ' + paykey)
        if payment.status == Payment.CONFIRMED_IPN:
            return  # double notification, nothing to do
        payment.confirm_ipn()
        payment.offer.paid()
        payment.offer.issue.touch()
        watches = watch_services.find_issue_and_offer_watches(payment.offer)
        notify_payment_parties_and_watchers_paymentconfirmed(payment, watches)
        notify_admin_payment_confirmed(payment)
    else:
        subject = 'received a payment confirmation with status = %s' % status
        msg = 'paykey = %s\nconfirm_key=%s' % (paykey, tracking_id)
        mail_services.notify_admin(subject, msg)
        logger.warn(subject)
        logger.warn(msg)
Example #36
0
def _append_project_id_and_update_db_if_needed(issueInfo, trackerURL, user):
    issueInfo.project_id = ''
    project = None
    if (issueInfo.project_trackerURL):
        found_projects = Project.objects.filter(
            trackerURL__iexact=issueInfo.project_trackerURL)
        if (found_projects.count() > 1):
            notify_admin(
                "WARNING: Database inconsistency",
                "more than one project found with url = %s" %
                issueInfo.project_trackerURL)
        elif (found_projects.count() == 1):
            project = found_projects[0]
            _update_project_name_if_needed(project, issueInfo.project_name)
        else:
            project = _create_project(issueInfo, user)
    if (project):
        issueInfo.project_id = project.id
        issueInfo.project_homeURL = project.homeURL
def payOfferForm(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    is_brazilian = offer.sponsor.getUserInfo().brazilianPaypal

    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()
    if not solutions_accepting_payments:
        messages.error(request, "No developers are accepting payments for this issue yet")
        return redirect(offer.issue.get_view_link())

    solutions_dict = []
    for solution in solutions_accepting_payments:
        programmer_userinfo = solution.programmer.getUserInfo()
        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.issue.get_view_link())
        solutions_dict.append(
            {
                "id": solution.id,
                "status": solution.status,
                "programmerScreenName": programmer_userinfo.screenName,
                "acceptsPaypal": accepts_paypal,
                "acceptsBitcoin": True and programmer_userinfo.bitcoin_receive_address,
                "imglink": solution.programmer.gravatar_url_small(),
            }
        )
    currency_options = _currency_options(offer)
    return render_to_response(
        template_folder(request) + "pay_offer_angular.html",
        {
            "offer": offer,
            "count": len(solutions_dict),
            "currency_options": currency_options,
            "currency_options_json": json.dumps(currency_options),
            "is_brazilian": is_brazilian,
            "solutions_json": json.dumps(solutions_dict),
        },
        context_instance=RequestContext(request),
    )
Example #38
0
def is_verified_account(email):
    try:
        response = paypal.pay(
            actionType='PAY',
            cancelUrl=settings.PAYPAL_CANCEL_URL,
            currencyCode='USD',
            feesPayer='SENDER',
            receiverList={'receiver': {
                'amount': '10.00',
                'email': email
            }},
            returnUrl=settings.PAYPAL_RETURN_URL,
            ipnNotificationUrl=settings.PAYPAL_IPNNOTIFY_URL)
        return True
    except PaypalError as e:
        if e.code != '520009':
            msg = 'email:%s, error:%s' % (email, e)
            mail_services.notify_admin(
                "Unexpected error from Paypal when trying to see if account exists",
                msg)
        return False
Example #39
0
def paypalReturn(request):
    current_payment_id = request.session.get('current_payment_id')
    if current_payment_id:
        curr_payment, msg = paypal_services.payment_confirmed_web(
            current_payment_id)
        del request.session['current_payment_id']
        logger.info('CONFIRM_WEB successful for payment %s' % curr_payment.id)
        messages.warning(
            request,
            "Your payment is being processed. You'll receive an email when your payment is confirmed."
        )
        return redirect(curr_payment.offer.issue.get_view_link())
    else:
        subject = 'CONFIRM_WEB received while no payment in session. user = %s' % request.user.id
        msg = 'GET %s\nPOST %s' % (request.GET, request.POST)
        mail_services.notify_admin(subject, msg)
        logger.warn(subject)
        logger.warn(msg)
        messages.error(request,
                       _('Session expired. Please check your offer status'))
        return redirect('/')
def change_username(request):
    can_change = request.user.getUserInfo().can_change_username
    if request.method.lower() == 'post':
        if can_change:
            old_username = request.user.username
            new_username = request.POST['new_username']
            change_ok = user_services.change_username(request.user, new_username)
            if change_ok:
                messages.info(request, 'Your username has been changed')
                can_change = False
                subject = 'user %s changed username %s --> %s' % (request.user.id, old_username, new_username)
                body = '<a href="http://freedomsponsors.org/user/%s">%s</a>' % (request.user.id, new_username)
                mail_services.notify_admin(subject, body)
            else:
                messages.error(request, 'Sorry, that username is already taken')
        else:
            messages.warning(request, 'You cannot change your username anymore')
    return render_to_response(
        'core2/change_username.html',
        {'can_change': can_change},
        context_instance=RequestContext(request)
    )
def payOfferForm(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    is_brazilian = offer.sponsor.getUserInfo().brazilianPaypal

    solutions_accepting_payments = offer.issue.getSolutionsAcceptingPayments()
    if not solutions_accepting_payments:
        messages.error(request, 'No developers are accepting payments for this issue yet')
        return redirect(offer.get_view_link())

    solutions_dict = []
    for solution in solutions_accepting_payments:
        programmer_userinfo = solution.programmer.getUserInfo()
        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())
        solutions_dict.append({
            'id': solution.id,
            'status': solution.status,
            'programmerScreenName': programmer_userinfo.screenName,
            'acceptsPaypal': accepts_paypal,
            'acceptsBitcoin': True and programmer_userinfo.bitcoin_receive_address,
            'imglink': solution.programmer.gravatar_url_small()
        })
    currency_options = _currency_options(offer)
    return render_to_response(template_folder(request) + 'pay_offer_angular.html',
                              {
                                  'offer': offer,
                                  'count': len(solutions_dict),
                                  'currency_options': currency_options,
                                  'currency_options_json': json.dumps(currency_options),
                                  'is_brazilian': is_brazilian,
                                  'solutions_json': json.dumps(solutions_dict)
                              },
                              context_instance=RequestContext(request))
def payOffer(request, offer, payment):
    current_payment_id = dictOrEmpty(request.session, 'current_payment_id')
    if(current_payment_id):
        paypal_services.forget_payment(int(current_payment_id))

    try:
        paypal_adapter.generate_paypal_payment(payment)
    except BaseException as e:
        traceback.print_exc()
        messages.error(request, 'Error communicating with Paypal: %s' % e)
        mail_services.notify_admin('Error generating paypal payment', traceback.format_exc())
        return redirect(offer.get_view_link())
    payment.save()

    request.session['current_payment_id'] = payment.id

    if(settings.PAYPAL_USE_SANDBOX):
        # form_action = 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay'
        redirect_url = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=%s' % payment.paykey
    else:
        # form_action = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay'
        redirect_url = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey=%s' % payment.paykey
    return redirect(redirect_url)
Example #43
0
def payOffer(request, offer, payment):
    current_payment_id = request.session.get('current_payment_id')
    if (current_payment_id):
        paypal_services.forget_payment(int(current_payment_id))

    try:
        paypal_adapter.generate_paypal_payment(payment)
    except BaseException as e:
        traceback.print_exc()
        messages.error(request, 'Error communicating with Paypal: %s' % e)
        mail_services.notify_admin('Error generating paypal payment',
                                   traceback.format_exc())
        return redirect(offer.get_view_link())
    payment.save()

    request.session['current_payment_id'] = payment.id

    if settings.PAYPAL_USE_SANDBOX:
        # form_action = 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay'
        redirect_url = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=%s' % payment.paykey
    else:
        # form_action = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay'
        redirect_url = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey=%s' % payment.paykey
    return redirect(redirect_url)
def _log_error_transaction_doesnt_match_money_sent(merr, part):
    msg = 'Bitcoin transaction doesnt match money sent. partid = %s, \n merr = %s' % (
        part.id,
        merr)
    mail_services.notify_admin('Bitcoin transaction doesnt match money sent', msg)
    logger.error(msg)
def _log_error_invalid_payment_part_for_active_send_confirmation(part, verr):
    msg = 'invalid paymentpart for active send confirmation: %s / %s' % (part.id, verr)
    logger.error(msg)
    mail_services.notify_admin('invalid paymentpart for active send confirmation', msg)
def _log_error_invalid_paymentpart_for_sending_money(part, verr):
    msg = 'invalid paymentpart sending money: %s / %s' % (part.id, verr)
    mail_services.notify_admin('invalid paymentpart sending money', msg)
    logger.error(msg)
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))
Example #48
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())
def _notify_admin_new_user(user):
    mail_services.notify_admin(subject=_('New user registered: ')+user.username,
                               msg=settings.SITE_HOME+user.get_view_link())
Example #50
0
def _notify_admin_new_user(user):
    mail_services.notify_admin(subject=_('New user registered: ') +
                               user.getUserInfo().screenName,
                               msg=settings.SITE_HOME + user.get_view_link())
def _notify_admin_new_user(user):
    mail_services.notify_admin(subject='New user registered: '+user.getUserInfo().screenName,
        msg=settings.SITE_HOME+user.get_view_link())