Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a few standard projects to scripts/initialize_database.py #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions scripts/initialize_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,66 @@ def create_session():


def init():
'''Adds the initial currency, account, and project for the General Fund.'''
'''Adds the initial currency, account, and a few standard projects.'''


ccy = Currency(code="USD", name="US Dollar")
acct = Account(name="General Fund Account", ccy=ccy)
project = Project(name="General Fund",
desc="Noisebridge's account of record",
goal=0,
accounts=[acct])


# Gen fund
acct_gen_fund = Account(name="General Fund Account", ccy=ccy)
project_gen_fund = Project(name="General Fund",
desc="Noisebridge's account of record",
goal=0,
accounts=[acct_gen_fund])

# Laser Cutter
acct_laser = Account(name="Laser Cutter Account", ccy=ccy)
project_laser = Project(name="Laser Cutter",
desc="Noisebridge's account of record for laser cutter expenses",
goal=0,
accounts=[acct_laser])

# Sewing
acct_sewing = Account(name="Sewing Account", ccy=ccy)
project_sewing = Project(name="Sewing",
desc="Noisebridge's account of record for Sewing expenses",
goal=0,
accounts=[acct_sewing])

# Circuit Hacking/Electronics
acct_circuit_hacking_electronics = Account(name="Circuit Hacking/Electronics Account", ccy=ccy)
project_circuit_hacking_electronics = Project(name="Circuit Hacking/Electronics",
desc="Noisebridge's account of record for Circuit Hacking/Electronics expenses",
goal=0,
accounts=[acct_circuit_hacking_electronics])
# 3D Printers
acct_3d_printers = Account(name="3D Printer Account", ccy=ccy)
project_3d_printers = Project(name="3D printer",
desc="Noisebridge's account of record for 3D printer expenses",
goal=0,
accounts=[acct_3d_printers])

# Wood/metal shop
acct_wood_metal_shop = Account(name="Wood/Metal Shop Account", ccy=ccy)
project_wood_metal_shop = Project(name="Wood/Metal Shop",
desc="Noisebridge's account of record for Wood/Metal shop expenses",
goal=0,
accounts=[acct_wood_metal_shop])

session = create_session()

donate_config = DonateConfiguration(key="INIT",
type="string",
value="true")
try:
session.add(project) # Includes the ccy and acct of the project
# Includes the ccy and acct of the project
session.add(project_gen_fund)
session.add(project_laser)
session.add(project_sewing)
session.add(project_circuit_hacking_electronics)
session.add(project_3d_printers)
session.add(project_wood_metal_shop)
session.add(donate_config)
session.commit()
except Exception as e:
Expand Down