Now display the campaigns with three different types of transactions: ACTIVE, INCOMPLETE, COMPLETED on the campaign_admin view
parent
4e36892910
commit
75fceed7c5
|
@ -28,4 +28,41 @@
|
|||
</textarea>
|
||||
{% endif %}
|
||||
|
||||
<!-- Active transactions -->
|
||||
<p style="font-weight:bold">Campaigns with active transactions</p>
|
||||
{% if campaigns_with_active_transactions %}
|
||||
<ul>
|
||||
{% for campaign in campaigns_with_active_transactions %}
|
||||
<li>{{campaign.id}} | {{campaign.name}} </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>No campaigns with active transactions</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- incomplete transactions -->
|
||||
<p style="font-weight:bold">Campaigns with incomplete transactions</p>
|
||||
{% if campaigns_with_incomplete_transactions %}
|
||||
<ul>
|
||||
{% for campaign in campaigns_with_incomplete_transactions %}
|
||||
<li>{{campaign.id}} | {{campaign.name}} </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>No campaigns with incomplete transactions</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- completed transactions -->
|
||||
<p style="font-weight:bold">Campaigns with completed transactions</p>
|
||||
{% if campaigns_with_completed_transactions %}
|
||||
<ul>
|
||||
{% for campaign in campaigns_with_completed_transactions %}
|
||||
<li>{{campaign.id}} | {{campaign.name}} </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>No campaigns with completed transactions</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
|
@ -39,6 +39,7 @@ from regluit.frontend.forms import RightsHolderForm, UserClaimForm, LibraryThin
|
|||
from regluit.frontend.forms import ManageCampaignForm, DonateForm, CampaignAdminForm
|
||||
from regluit.payment.manager import PaymentManager
|
||||
from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN, TARGET_TYPE_DONATION
|
||||
from regluit.payment.paypal import Preapproval, IPN_PAY_STATUS_ACTIVE, IPN_PAY_STATUS_INCOMPLETE, IPN_PAY_STATUS_COMPLETED
|
||||
from regluit.core import goodreads
|
||||
from tastypie.models import ApiKey
|
||||
from regluit.payment.models import Transaction
|
||||
|
@ -434,12 +435,29 @@ def campaign_admin(request):
|
|||
check_status_results = pm.checkStatus()
|
||||
except Exception, e:
|
||||
check_status_results = e
|
||||
|
||||
# second task: pull out Campaigns with Transactions that are ACTIVE -- and hence can be executed
|
||||
# Campaign.objects.filter(transaction__status='ACTIVE')
|
||||
|
||||
campaigns_with_active_transactions = models.Campaign.objects.filter(transaction__status=IPN_PAY_STATUS_ACTIVE)
|
||||
|
||||
# third task: pull out Campaigns with Transactions that are INCOMPLETE
|
||||
|
||||
campaigns_with_incomplete_transactions = models.Campaign.objects.filter(transaction__status=IPN_PAY_STATUS_INCOMPLETE)
|
||||
|
||||
# 4th task: show all Campaigns with Transactions that are COMPLETED
|
||||
|
||||
campaigns_with_completed_transactions = models.Campaign.objects.filter(transaction__status=IPN_PAY_STATUS_COMPLETED)
|
||||
|
||||
context.update({
|
||||
'form': form,
|
||||
'check_status_results':check_status_results
|
||||
'check_status_results':check_status_results,
|
||||
'campaigns_with_active_transactions': campaigns_with_active_transactions,
|
||||
'campaigns_with_incomplete_transactions': campaigns_with_incomplete_transactions,
|
||||
'campaigns_with_completed_transactions': campaigns_with_completed_transactions
|
||||
})
|
||||
|
||||
|
||||
return render(request, "campaign_admin.html", context)
|
||||
|
||||
def supporter(request, supporter_username, template_name):
|
||||
|
|
|
@ -2,7 +2,8 @@ from regluit.core.models import Campaign, Wishlist
|
|||
from regluit.payment.models import Transaction, Receiver, PaymentResponse
|
||||
from django.contrib.auth.models import User
|
||||
from regluit.payment.parameters import *
|
||||
from regluit.payment.paypal import Pay, Execute, IPN, IPN_TYPE_PAYMENT, IPN_TYPE_PREAPPROVAL, IPN_TYPE_ADJUSTMENT, Preapproval, IPN_PAY_STATUS_COMPLETED, CancelPreapproval, PaymentDetails, PreapprovalDetails, IPN_SENDER_STATUS_COMPLETED, IPN_TXN_STATUS_COMPLETED
|
||||
from regluit.payment.paypal import Pay, Execute, IPN, IPN_TYPE_PAYMENT, IPN_TYPE_PREAPPROVAL, IPN_TYPE_ADJUSTMENT, IPN_PAY_STATUS_ACTIVE
|
||||
from regluit.payment.paypal import Preapproval, IPN_PAY_STATUS_COMPLETED, CancelPreapproval, PaymentDetails, PreapprovalDetails, IPN_SENDER_STATUS_COMPLETED, IPN_TXN_STATUS_COMPLETED
|
||||
import uuid
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
@ -325,12 +326,10 @@ class PaymentManager( object ):
|
|||
'''
|
||||
|
||||
# only allow active transactions to go through again, if there is an error, intervention is needed
|
||||
transactions = Transaction.objects.filter(campaign=campaign, status="ACTIVE")
|
||||
transactions = Transaction.objects.filter(campaign=campaign, status=IPN_PAY_STATUS_ACTIVE)
|
||||
|
||||
for t in transactions:
|
||||
|
||||
# BUGBUG: Fill this in with the correct info from the campaign object
|
||||
# Campaign.paypal_receiver
|
||||
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':t.amount},
|
||||
{'email':campaign.paypal_receiver, 'amount':D(t.amount) * (D('1.00') - D(str(settings.GLUEJAR_COMMISSION)))}]
|
||||
|
||||
|
|
Loading…
Reference in New Issue