def donation_controller():
    """sample controller for save the whales foundation
    setup with basic information and no donations"""
    database.connect()
    database.create_tables([Donor, Donation])
    yield DonationController()
    database.close()
def test_controller_creates_saved_file(stw, donor1):
    """given a controller is intialized and donors added
    when saved with the internal method and then loaded
    then the results can be reloaded"""
    # create controller and save
    test_filename = 'test.json'
    stw.create_donor(donor1)
    extract = stw.save(test_filename)

    # now make load database and compare
    stw2 = DonationController.load(test_filename)
    assert str(stw) == str(stw2)
def donation_controller(example_database):
    """sample controller for save the whales foundation
    setup with basic information 1 donor and 1 donation"""
    dc = DonationController(example_database)
    dc.create_donor(donor_name='test1', donor_email="test1")
    dc.create_donation(amount=500,
                       donor='test1',
                       date=datetime.datetime(2018, 1, 1))
    yield dc
def stw():
    """sample controller for save the whales foundation
    setup with basic information and no donations"""
    return DonationController(name='Save The Whales')
Beispiel #5
0
"""entry point to mailroom application"""

from pathlib import Path
from mailroom.DonationController import DonationController
from mailroom.Donor import Donor
from mailroom.helpers import menu_selection

CONTROLLER = DonationController.load('stw.json')


def main_menu():
    """calls main menu for program"""
    MAIN_MENU_OPTIONS = {
        '1': create_donation_menu,
        '2': donor_report_menu,
        '3': send_thank_you_letters,
        '4': save_database
    }
    user_input = ('Options:\n'
                  '\t1: Create Donation\n'
                  '\t2: Create Donor Report\n'
                  '\t3: Send donors Thank Yous\n'
                  '\t4: Save Database\n'
                  '\t0: Quit\n'
                  'Please input number for option: ')

    menu_selection(user_input, MAIN_MENU_OPTIONS)


def create_donation_menu():
    """calls create donation menu
def donation_controller(sqlite_dbaccess):
    """sample controller for save the whales foundation
    setup with basic information and no donations"""
    yield DonationController(sqlite_dbaccess)
from mailroom.helpers import menu_selection
from mailroom.Donation import Donation
from mailroom.Donor import Donor
from mailroom.config import database

from peewee import *

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

database.connect()
database.execute_sql('PRAGMA foreign_keys = ON;')
database.create_tables([Donation, Donor])

# start initial controller
controller = DonationController()


def main_menu():
    """calls main menu for program"""
    MAIN_MENU_OPTIONS = {
        '1': create_donation_menu,
        '2': donor_report_menu,
        '3': send_thank_you_letters,
        '4': edit_donation_menu
    }
    user_input = ('Options:\n'
                  '\t1: Create Donation\n'
                  '\t2: Create Donor Report\n'
                  '\t3: Send donors Thank Yous\n'
                  '\t4: Edit Records\n'
Beispiel #8
0
TODO:
* add error catching if inputs for edits don't exist.  """

import logging

from mailroom.DonationController import DonationController
from mailroom.helpers import menu_selection
from mailroom.config import Database

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

database = Database()
database.db_init('prod')
controller = DonationController(database=database)


def main_menu():
    """calls main menu for program"""
    MAIN_MENU_OPTIONS = {
        '1': create_donation_menu,
        '2': donor_report_menu,
        '3': send_thank_you_letters,
        '4': edit_donation_menu
    }
    user_input = ('Options:\n'
                  '\t1: Create Donation\n'
                  '\t2: Create Donor Report\n'
                  '\t3: Send donors Thank Yous\n'
                  '\t4: Edit Records\n'