Now in campaign admin, you can pick specific campaign to take action on.

pull/1/head
Raymond Yee 2011-12-23 09:59:07 -05:00
parent 217f06edeb
commit c721c9c6b2
2 changed files with 36 additions and 22 deletions

View File

@ -30,19 +30,18 @@
{% endif %}
<!-- Active transactions -->
<p style="font-weight:bold">Campaigns with active transactions</p>
{% if campaigns_with_active_transactions %}
<form method="post" action="#">
{% csrf_token %}
<ul>
{% for campaign in campaigns_with_active_transactions %}
<li>{{campaign.id}} | {{campaign.name}} </li>
<li><input type="radio" name="active_campaign" value="{{campaign.id}}" />{{campaign.id}} | {{campaign.name}} </li>
{% endfor %}
</ul>
<form method="post" action="#">
{% csrf_token %}
<input type="submit" name="execute_campaigns" value="Execute Payment to Gluejar" id="submit">
</form>
<form method="post" action="#">
{% csrf_token %}
<input type="submit" name="cancel_campaigns" value="Cancel Active Transactions" id="submit">
</form>
{% else %}
@ -52,13 +51,13 @@
<!-- 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>
<form method="post" action="#">
{% csrf_token %}
<ul>
{% for campaign in campaigns_with_incomplete_transactions %}
<li><input type="radio" name="incomplete_campaign" value="{{campaign.id}}" />{{campaign.id}} | {{campaign.name}} </li>
{% endfor %}
</ul>
<input type="submit" name="finish_campaigns" value="Pay Rights Holders" id="submit">
</form>
{% else %}

View File

@ -473,19 +473,34 @@ def campaign_admin(request):
command_status = _("Transactions updated based on PaymentDetails and PreapprovalDetails")
except Exception, e:
check_status_results = e
elif 'execute_campaigns' in request.POST.keys():
campaigns_with_active_transactions = models.Campaign.objects.filter(transaction__status=IPN_PAY_STATUS_ACTIVE)
results = [pm.execute_campaign(c) for c in campaigns_with_active_transactions]
command_status = str(results)
elif 'execute_campaigns' in request.POST.keys():
c_id = request.POST.get('active_campaign', None)
if c_id is not None:
try:
campaign = models.Campaign.objects.get(id=c_id)
results = pm.execute_campaign(campaign)
command_status = str(results)
except Exception, e:
command_status = "Error in executing transactions for campaign %s " % (str(e))
elif 'finish_campaigns' in request.POST.keys():
campaigns_with_incomplete_transactions = models.Campaign.objects.filter(transaction__status=IPN_PAY_STATUS_INCOMPLETE)
results = [pm.finish_campaign(c) for c in campaigns_with_incomplete_transactions]
command_status = str(results)
pass
c_id = request.POST.get('incomplete_campaign', None)
if c_id is not None:
try:
campaign = models.Campaign.objects.get(id=c_id)
results = pm.finish_campaign(campaign)
command_status = str(results)
except Exception, e:
command_status = "Error in finishing transactions for campaign %s " % (str(e))
elif 'cancel_campaigns' in request.POST.keys():
campaigns_with_active_transactions = models.Campaign.objects.filter(transaction__status=IPN_PAY_STATUS_ACTIVE)
results = [pm.cancel_campaign(c) for c in campaigns_with_active_transactions]
command_status = str(results)
c_id = request.POST.get('active_campaign', None)
if c_id is not None:
try:
campaign = models.Campaign.objects.get(id=c_id)
results = pm.cancel_campaign(campaign)
command_status = str(results)
except Exception, e:
command_status = "Error in canceling transactions for campaign %s " % (str(e))
(campaigns_with_active_transactions, campaigns_with_incomplete_transactions, campaigns_with_completed_transactions,
campaigns_with_canceled_transactions) = campaigns_types()