Changes in progress to the model

pull/1/head
Raymond Yee 2011-10-07 14:17:54 -07:00
parent ac7deebf9a
commit 68b94f768f
4 changed files with 38 additions and 3 deletions

View File

@ -9,12 +9,31 @@ class Campaign(models.Model):
description = models.CharField(max_length=10000, null=False)
target = models.DecimalField(max_digits=14, decimal_places=2)
deadline = models.DateTimeField(null=False)
activated = models.DateTimeField(null=True)
suspended = models.DateTimeField(null=True)
withdrawn = models.DateTimeField(null=True)
supended_reason = models.CharField(max_length=10000, null=True)
withdrawn_reason = models.CharField(max_length=10000, null=True)
paypal_receiver = models.CharField(max_length=100, null=True)
amazon_receiver = models.CharField(max_length=100, null=True)
work = models.ForeignKey("Work", related_name="campaigns")
def __unicode__(self):
return u"Campaign for %s" % self.work.title
def status(self):
"""Returns the status of the campaign
"""
if self.activated is None:
return 'INITIALIZED'
else:
if self.suspended is not None:
return 'SUSPENDED'
elif self.withdrawn is not None:
return 'WITHDRAWN'
else: # ACTIVE, SUCCESSFUL, or UNSUCCESSFUL
return 'ACTIVE or SUCCESSFUL or UNSUCCESSFUL'
class Work(models.Model):

View File

@ -59,3 +59,10 @@ class SearchTests(TestCase):
def test_googlebooks_search(self):
response = search.googlebooks_search('melville')
self.assertEqual(len(response['items']), 10)
class CampaignTests(TestCase):
def setUp(self):
pass
def trivial(self):
self.assertTrue(1==1)

View File

@ -174,7 +174,7 @@ class PaymentManager( object ):
return value: either a float summary or a list of transactions
'''
def query_campaign(self, list, summary=False, pledged=True, authorized=True):
def query_list(self, list, summary=False, pledged=True, authorized=True):
transactions = Transaction.objects.filter(list=list)
return self.run_query(transactions, summary, pledged, authorized)

View File

@ -6,6 +6,7 @@ Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
from django.utils import unittest
from regluit.payment.manager import PaymentManager
from regluit.payment.paypal import IPN, IPN_PAY_STATUS_ACTIVE, IPN_PAY_STATUS_COMPLETED, IPN_TXN_STATUS_COMPLETED
from noseselenium.cases import SeleniumTestCaseMixin
@ -19,8 +20,6 @@ from django.core.exceptions import ValidationError
import time
from selenium import selenium, webdriver
def loginSandbox(test, selenium):
print "LOGIN SANDBOX"
@ -214,5 +213,15 @@ class AuthorizeTest(TestCase):
self.assertEqual(t.status, IPN_PAY_STATUS_ACTIVE)
class TransactionTest(TestCase):
def testSimple(self):
self.assertEqual(1,1)
def suite():
#testcases = [PledgeTest, AuthorizeTest]
testcases = [TransactionTest]
suites = unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(testcase) for testcase in testcases])
return suites