Example #1
0
def add_campaign(user, org):
    campaign = Campaign(created_by=user, org=org,
            title='Test Campaign', description=' Test description', 
            who='Test who', impact='test impact',
            utilization='A very large impact', state="Haryana", city="Karnal", nbooks='100', nlic=0, languages="Hindi, Tamil",
            image="1.jpg", status="Approved",approved_at=datetime.now(),
            total_impact_on_children='2000', featured=False)
    db.session.add(campaign)
    db.session.commit()
    return campaign
Example #2
0
def send_last_week_mails():
    campaigns_last_week = Campaign.last_week()
    for campaign in campaigns_last_week:
        name = campaign.created_by.profile_name()
        campaign_title = campaign.title
        end_date = "{:%B %d, %Y}".format(campaign.end_date())

        text = 'Dear ' + name + ',\n\nYour campaign with title: ' + campaign_title + ' ends on ' + end_date + '. You are just 7 days away from completion.\nPull up your socks, give it a final push and meet your targets. Our books await you.\nGood Luck. Let it be your best foot forward. \n\nRegards,\nDonate-a-Book Team'
        send_email(to=campaign.emails(),
                   subject="Just 7 days to go!",
                   text=text)
Example #3
0
def send_last_week_mails():
    campaigns_last_week = Campaign.last_week()
    for campaign in campaigns_last_week:
        name = campaign.created_by.profile_name()
        campaign_title = campaign.title
        end_date = "{:%B %d, %Y}".format(campaign.end_date())

        text = 'Dear ' + name + ',\n\nYour campaign with title: ' + campaign_title + ' ends on ' + end_date +'. You are just 7 days away from completion.\nPull up your socks, give it a final push and meet your targets. Our books await you.\nGood Luck. Let it be your best foot forward. \n\nRegards,\nDonate-a-Book Team'
        send_email(to=campaign.emails(),
                subject="Just 7 days to go!",
                text=text
                )
Example #4
0
def close_campaigns():
    campaigns_last_day_today = Campaign.last_day_today()
    for campaign in campaigns_last_day_today:
        campaign.status = 'Closed'
        db.session.add(campaign)
        try:
          db.session.commit()
        except Exception as e:
          print e,"Unable to Commit"

        name = campaign.created_by.profile_name()
        campaign_title = campaign.title
        percent = campaign.percent_funded()

        text = 'Dear ' + name + ',\n\nWhat a ride that was! Your Donate-a-Book Campaign: ' + campaign_title + ' has officially come to an end.\n'+ 'You have raised ' + str(percent) + ' of your target fund. Congratulations on the success of your campaign. \n\nYou can expect to receive an email from the Pratham Books team which will have a comprehensive list of all books in stock. You would be able to pick and choose your preferred books priced within the fund limit that you have raised.\nKeep an eye out for our email, we will be in touch soon with more details. \n\nRegards, \nDonate-a-Book Team'
        send_email(to=campaign.emails(),
                subject="Congratulations on the success of your campaign!",
                text=text)
Example #5
0
def close_campaigns():
    campaigns_last_day_today = Campaign.last_day_today()
    for campaign in campaigns_last_day_today:
        campaign.status = 'Closed'
        db.session.add(campaign)
        try:
            db.session.commit()
        except Exception as e:
            print e, "Unable to Commit"

        name = campaign.created_by.profile_name()
        campaign_title = campaign.title
        percent = campaign.percent_funded()

        text = 'Dear ' + name + ',\n\nWhat a ride that was! Your Donate-a-Book Campaign: ' + campaign_title + ' has officially come to an end.\n' + 'You have raised ' + str(
            percent
        ) + ' of your target fund. Congratulations on the success of your campaign. \n\nYou can expect to receive an email from the Pratham Books team which will have a comprehensive list of all books in stock. You would be able to pick and choose your preferred books priced within the fund limit that you have raised.\nKeep an eye out for our email, we will be in touch soon with more details. \n\nRegards, \nDonate-a-Book Team'
        send_email(to=campaign.emails(),
                   subject="Congratulations on the success of your campaign!",
                   text=text)
Example #6
0
def seed_db():
    admin = Role(
            name="admin",
            description="Administrator who can approve campaigns"
            )
    db.session.add(admin)

    user = User(
            status=USER_STATUS.ACTIVE, 
            email='*****@*****.**',
            first_name='Pratham', 
            last_name='Admin', 
            active=True,
            address='XXX',
            contact_number='123456789',
            pan_number='XXYYZZ',
            roles=[admin],
            confirmed_at=datetime.now())

    
    db.session.add(user)

    user_auth = UserAuth(password=app.user_manager.hash_password('admin123'), 
            user=user, active=True)
    db.session.add(user_auth)

    user = User(
            status=USER_STATUS.ACTIVE, 
            email='*****@*****.**',
            first_name='User', 
            last_name='1', 
            active=True,
            address='101, Good Homes',
            contact_number='990232323232',
            pan_number='XXYYZZ',
            confirmed_at=datetime.now())
    db.session.add(user)

    user_auth = UserAuth(password=app.user_manager.hash_password('user1123'), 
            user=user, active=True)
    db.session.add(user_auth)

    org = Organization(title='Whitefield Awake', created_by=user)
    db.session.add(org)

    # Create org info
    org_info = OrganizationInfo(
         org=org, email='*****@*****.**', category=2, status=1, address='123, Street 2',
         contact_number='99010201011', facebook='http://facebook.com/mirafra', 
         website='http://www.mirafra.com',
         has_80g_certificate='t', person1_name='User 1',
         person1_position='CEO', person1_email='*****@*****.**',
         person2_position='COO', person2_email='*****@*****.**',
         person1_phone='898923232328', person2_name='shyam',
         person2_phone='89323232899')
    db.session.add(org_info)

    work = OrganizationWork(organization=org, choice_id='3') 

    campaign = Campaign(created_by=user, org=org,
            title='Harayana Library', description='Project to get 1000 books for Ramagondanhalli School', 
            who='We are an organization of volunteers', impact='This will raise funds to buy 1000 books for government schools',
            utilization='A very large impact', state="Haryana", city="Karnal", nbooks='1000', nlic=0, languages="Hindi, Tamil",
            image="1.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=1),
            total_impact_on_children='2000', featured=False)
    donation = Donation(donor=user, campaign=campaign, amount=50000, confirmation=53499, 
            city="Bangalore", state="Karnataka", address="ABC", first_name="Sahil", identification="ABCDEF",
            identification_type="DL", ann_choice=False,
            tax_exemption_certificate=False)
    db.session.add(donation)
    db.session.add(campaign)

    campaign = Campaign(created_by=user, org=org,
            title='Rural Library With a very very very long name that should not be allowed', description='Project to set up a rural library', 
            who='We are an organization who works in rural AP', impact='This will raise funds to set up a new library.',
            utilization='Utilize to get books', state="Andhra Pradesh", city="Hyderabad", nbooks='500', nlic=2, languages="Telugu, English",
            image="2.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=2),
            total_impact_on_children='1000', featured=True)
    db.session.add(campaign)
    donation = Donation(donor=user, campaign=campaign, amount=10000, confirmation=53499, 
            city="Bangalore", state="Karnataka", address="ABC", first_name="Sahil", identification="ABCDEF",
            identification_type="P", ann_choice=False,
            tax_exemption_certificate=True)
    db.session.add(donation)
    comment = Comment(comment_by=user, campaign_comment=campaign, comment="[Dummy Comment 1]")
    db.session.add(comment)

    campaign = Campaign(created_by=user, org=org,
            title='Urban Library', description='Project to get 750 books for old age home', 
            who='We are an organization of old people', impact='Make 100 old people happy',
            utilization='It will help a few old people smile', state="Karnataka", city="Dharwad", nbooks='100', nlic=0, languages="English, Tamil",
            image="3.jpg", status="Rejected",
            total_impact_on_children='500', featured=True)
    db.session.add(campaign)

    campaign = Campaign(created_by=user, org=org,
            title='Slum Library', description='Slum library in Dharavi, Mumbai', 
            who='We are an organization of volunteers', impact='Library for street children',
            utilization='Take children off the streets', state="Maharashtra", city="Mumbai", nbooks='10000', nlic=0, languages="Hindi, Punjabi",
            image="4.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=3),
            total_impact_on_children='4000', featured=True)
    db.session.add(campaign)

    comment = Comment(comment_by=user, campaign_comment=campaign, comment="[Dummy Comment 1]")
    db.session.add(comment)

    campaign = Campaign(created_by=user, org=org,
            title='Karnataka Library', description='Project to get 1000 books for Sidhapura School', 
            who='We are an organization of volunteers', impact='This will raise funds to buy 1000 books for government schools',
            utilization='A very large impact', state="Karnataka", city="Bangalore", nbooks='1000', nlic=0, languages="Kannada, Tamil",
            image="5.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=4),
            total_impact_on_children='200', featured=True)
    db.session.add(campaign)

    comment = Comment(comment_by=user, campaign_comment=campaign, comment="[Dummy Comment 3]")
    db.session.add(comment)
    comment = Comment(comment_by=user, campaign_comment=campaign, comment="[Dummy Comment 2]")
    db.session.add(comment)
    comment = Comment(comment_by=user, campaign_comment=campaign, comment="[Dummy Comment 1]")
    db.session.add(comment)

    campaign = Campaign(created_by=user, org=org,
            title='Harayana Village Library', description='Project to get 1000 books for Ramagondanhalli School', 
            who='We are an organization of volunteers', impact='This will raise funds to buy 1000 books for government schools',
            utilization='A very large impact', state="Haryana", city="Karnal", nbooks='1000', nlic=0, languages="Hindi, Tamil",
            image="6.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=5),
            total_impact_on_children='1500', featured=False)
    db.session.add(campaign)


    campaign = Campaign(created_by=user, org=org,
            title='Varthur Village Library', description='Project to get 1000 books for Ramagondanhalli School', 
            who='We are an organization of volunteers', impact='This will raise funds to buy 1000 books for government schools',
            utilization='A very large impact', state="Haryana", city="Karnal", nbooks='1000', nlic=0, languages="Hindi, Tamil",
            image="6.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=5),
            total_impact_on_children='1500', featured=False)
    db.session.add(campaign)


    campaign = Campaign(created_by=user, org=org,
            title='Ramgondahalli Village Library', description='Project to get 1000 books for Ramagondanhalli School', 
            who='We are an organization of volunteers', impact='This will raise funds to buy 1000 books for government schools',
            utilization='A very large impact', state="Haryana", city="Karnal", nbooks='1000', nlic=0, languages="Hindi, Tamil",
            image="6.jpg", status="Approved",approved_at=datetime.now()-timedelta(days=5),
            total_impact_on_children='1500', featured=False)
    db.session.add(campaign)

    memory = Memory(name="Alok", city="Bangalore", state="Karnataka", 
            email="*****@*****.**", can_share=True, words="Hello there from Alok")
    db.session.add(memory)

    memory = Memory(name="Sai", city="Bangalore", state="Karnataka", 
            email="*****@*****.**", can_share=False, words="Hello there from Sai")
    db.session.add(memory)

    db.session.commit()