def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: huge = Account("Finance", 2013) office = Office("New York", 10, huge) corporate = Department("Corporate", huge) ceo = Role(huge, "Senior Developer", corporate, 150000, 50000) aaron = User(huge, "Atish Narlawar", "*****@*****.**", office, ceo, 100000, datetime.date(2012, 1, 1)) aaron.set_password("atish") aaron.is_administrator = True salary = Salary(aaron, 100000, 1, datetime.date(2012, 1, 1), 100) aaron.salary_history.append(salary) DBSession.add(aaron)
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: huge = Account("Finance", 2013) huge.benefits_and_bonus = 25 huge.midyear_review_start = datetime.date(2013, 4, 15) huge.midyear_review_setup_deadline = datetime.date(2013, 4, 25) huge.midyear_review_end_date = datetime.date(2013, 5, 25) huge.annual_review_start = datetime.date(2014, 1, 15) huge.annual_review_setup_deadline = datetime.date(2014, 1, 15) huge.annual_review_end_date = datetime.date(2014, 1, 15) corp = Office("Corporate", 10, huge) ny = Office("New York", 10, huge) la = Office("Los Angeles", 10, huge) sf = Office("San Francisco", 10, huge) dc = Office("Washington DC", 10, huge) pd = Office("Portland", 10, huge) at = Office("Atlanta", 10, huge) ri = Office("Rio de Janiero", 10, huge) ld = Office("London", 10, huge) bz = Office("Brazilia", 10, huge) bt = Office("Boutique", 10, huge) ny.allocated_salary_expense = 500000 ny.sga_expense = 2500000 ny.allocated_salary_expense = 200000 ny.sga_expense = 1200000 creative = Department("Creative", huge) corporate = Department("Corporate", huge) ux = Department("User Experience", huge) progm = Department("Program Management", huge) ceo = Role(huge, "CEO", corporate, 50000, 150000) spm = Role(huge, "Senior Project Manager", progm, 50000, 150000) pm = Role(huge, "Project Manager", progm, 50000, 150000) cd = Role(huge, "Creative Director", creative, 50000, 150000) vppm = Role(huge, "Vice President Program Management", progm, 150000, 200000) apm = Role(huge, "Associate Project Manager", progm, 50000, 75000) aaron_permissions = Permissions(True, True, True, True, True, True, True) aaron_permissions.all_financials = True aaron_permissions.all_utilization = True aaron_permissions.all_pipeline = True meghan_permissions = Permissions(False, False, False, False, False, False) aaron = User(huge, "Aaron Mark Shapiro", "*****@*****.**", corp, ceo, 1000, datetime.date(2012, 1, 1)) aaron.permissions = aaron_permissions aaron.percent_billable = 0 mary = User(huge, "Mary Sue Watson", "*****@*****.**", ny, pm, 75000, datetime.date(2013, 1, 1)) meghan = User(huge, "Meghan Francis Henderson", "*****@*****.**", ny, vppm, 150000, datetime.date(2013, 1, 1)) meghan.permissions = meghan_permissions meghan.percent_billable = 50 # this and next time is a hack because i can't get class associations to work progm.manager_name = "Meghan Henderson" #this does not work because meghan.id is not created yet progm.manager_id = meghan.id je = JobHistoryEntry(mary, apm, 50000) je.created_at = datetime.date(2010, 1, 4) je1 = JobHistoryEntry(mary, apm, 55000) je1.created_at = datetime.date(2011, 2, 16) je2 = JobHistoryEntry(mary, pm, 75000) je2.created_at = datetime.date(2012, 1, 7) mary.job_history.append(je) mary.job_history.append(je1) mary.job_history.append(je2) mary.manager = aaron aaron.set_password("aaron") aaron_permissions.user = aaron huge.users.append(aaron) huge.users.append(mary) skillset_category_pd_1 = SkillsetCategory("360 Knowledge Base", progm) skillset_category_pd_2 = SkillsetCategory("Client Management", progm) skillset_pd_1_1 = Skillset("Knows how to tie their shoes", spm, skillset_category_pd_1) skillset_pd_1_2 = Skillset("Can make double knots", spm, skillset_category_pd_1) skillset_pd_2_1 = Skillset("Can use email", spm, skillset_category_pd_1) skillset_pd_2_2 = Skillset("Can send texts", spm, skillset_category_pd_1) skillset_category_pd_1.skillsets.append(skillset_pd_1_1) skillset_category_pd_1.skillsets.append(skillset_pd_1_2) skillset_category_pd_2.skillsets.append(skillset_pd_2_1) skillset_category_pd_2.skillsets.append(skillset_pd_2_2) progm.skillset_categorys.append(skillset_category_pd_1) progm.skillset_categorys.append(skillset_category_pd_2) mary_review = Review(mary, 2013) se_m_1 = SkillsetEntry(mary_review, True, skillset_pd_1_1, 4) se_m_2 = SkillsetEntry(mary_review, True, skillset_pd_1_2, 3) se_m_3 = SkillsetEntry(mary_review, True, skillset_pd_2_1, 3) se_m_4 = SkillsetEntry(mary_review, True, skillset_pd_2_2, 2) mary_review.self_assessment_goals = "I want to learn how to play the piano." mary_review.self_assessment_performance_midyear = "I need to do a better job with sandals." mary_review.general_midyear_comments = "Stellar shoe tieing skills." mary_review.skillset_entries.append(se_m_1) mary_review.skillset_entries.append(se_m_2) mary_review.skillset_entries.append(se_m_3) mary_review.skillset_entries.append(se_m_4) mary.reviews.append(mary_review) DBSession.add_all([mary, meghan, aaron]) lexus = Client("lexus", la) lexus.account = huge comcast = Client("comcast", ny) comcast.account = huge strategy = Project("strategy", lexus, 600000, datetime.date(2013, 5, 1), datetime.date(2013, 6, 15)) design = Project("design", lexus, 1400000, datetime.date(2013, 7, 1), datetime.date(2013, 9, 1)) fall_campaign = Project("fall campaign", comcast, 300000, datetime.date(2013, 5, 1), datetime.date(2013, 6, 15)) ux_refresh = Project("ux refresh", comcast, 400000, datetime.date(2013, 7, 1), datetime.date(2013, 9, 1)) DBSession.add_all( [lexus, comcast, strategy, design, fall_campaign, ux_refresh]) free1 = Freelancer("Bob Jones", apm, datetime.date(2013, 5, 1), datetime.date(2013, 6, 1), 30, 100, lexus) free2 = Freelancer("Jane Jones", apm, datetime.date(2013, 5, 1), datetime.date(2013, 6, 1), 30, 50, lexus) ua = UserAllocation(mary, lexus, None, 100, datetime.date(2013, 5, 1), datetime.date(2013, 12, 31)) gu = GhostUser(apm, la, datetime.date(2013, 7, 1), 100) gh = GhostAllocation(gu, lexus, None, 100, datetime.date(2013, 8, 1), datetime.date(2013, 12, 31)) gp = GhostProject("development", lexus, None, 1200000, 90, datetime.date(2013, 8, 1), datetime.date(2013, 12, 31)) usaa = GhostClient("USAA", ny) gp2 = GhostProject("aor", None, usaa, 3500000, 10, datetime.date(2013, 9, 1), datetime.date(2014, 12, 31)) tbg = GhostClient(None, ny) gp3 = GhostProject("tbg", None, tbg, 200000, 0, datetime.date(2013, 6, 1), datetime.date(2013, 12, 31)) DBSession.add_all([free1, free2, ua, gu, gh, gp, usaa, gp2, tbg, gp3])
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') event.listen(engine, 'checkout', checkout_listener) DBSession.configure(bind=engine) Base.metadata.bind = engine authn_policy = AuthTktAuthenticationPolicy('mysupersecret', callback=permission_finder, hashalg='sha512') authz_policy = ACLAuthorizationPolicy() config = Configurator( settings=settings, root_factory='hr.models.SecurityFactory.SecurityFactory', session_factory=my_session_factory) config.set_authentication_policy(authn_policy) config.set_authorization_policy(authz_policy) config.scan('hr.models') config.scan("hr.views") config.include('pyramid_jinja2') config.add_jinja2_extension('jinja2.ext.do') config.add_renderer('.html', 'pyramid_jinja2.renderer_factory') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('login', '/login') config.add_route('logout', '/logout') config.add_route('person_delete', '/person/{person_id}/delete') config.add_route('person_show_review', '/person/{person_id}/{review_id}/show') config.add_route('people', '/people/{office_id}/{department_id}/{type_of_person}') config.add_route('person_add', '/person/add') config.add_route('person', '/person/{person_id}') config.add_route('person_edit', '/person/{person_id}/edit') config.add_route('person_enable_login', '/person/{person_id}/enable/login') config.add_route('person_password_reset', '/person/{person_id}/password/reset') config.add_route('person_disable_login', '/person/{person_id}/disable/login') config.add_route('person_assign_add', '/person/{person_id}/assign/add') config.add_route('person_assign_edit', '/person/{person_id}/assign/edit') config.add_route('person_assign_delete', '/person/{person_id}/assign/{assignment_id}/delete') config.add_route('roles', '/roles/{department_id}') config.add_route('role_add', '/role/add') config.add_route('role_edit', '/role/{role_id}/edit') config.add_route('role_delete', '/role/{role_id}/delete') config.add_route('role', '/role/{role_id}') config.add_route('administration_company', '/administration/company') config.add_route('administration_company_edit', '/administration/company/edit') config.add_route('administration_employees', '/administration/employees') config.add_route('administration_password', '/administration/password') config.add_route('administration_revenue', '/administration/revenue') config.add_route('administration_expenses', '/administration/expenses') config.add_route('administration_expenses_clients', '/administration/expenses/clients') config.add_route('administration_expenses_global', '/administration/expenses/global/{year}') config.add_route( 'skillset_entry_update', '/skillset_entry/{person_id}/{skillset_entry_id}/update/{rating}') config.add_route( 'skillset_entry_add', '/skillset_entry/{person_id}/{review_id}/add/{skillset_id}/{interval}/{rating}' ) config.add_route('office_financials', '/office/{office_id}/financials/{year}') config.add_route('office_utilization', '/office/{office_id}/utilization/{year}') config.add_route('office_clients', '/office/{office_id}/clients/{year}') config.add_route('office_pipeline', '/office/{office_id}/pipeline/{year}') config.add_route('office_add', '/office/add') config.add_route('office_edit', '/office/{office_id}/edit') config.add_route('office_delete', '/office/{office_id}/delete') config.add_route('office_projects_update', '/office/{office_id}/projects/update') config.add_route('department_add', '/department/add') config.add_route('department_edit', '/department/{department_id}/edit') config.add_route('department_delete', '/department/{department_id}/delete') config.add_route('department_financials', '/department/{department_id}/financials/{year}') config.add_route('department_utilization', '/department/{department_id}/utilization/{year}') config.add_route('currency_add', '/currency/add') config.add_route('currency_edit', '/currency/{currency_id}/edit') config.add_route('currency_delete', '/currency/{currency_id}/delete') config.add_route('client_add', '/client/add') config.add_route('client_edit', '/client/{client_id}/edit') config.add_route('client_delete', '/client/{client_id}/delete') config.add_route('client_assign_ghost', '/client/assign/ghost') config.add_route('client_assign_resource', '/client/assign/resource') config.add_route('client_financials', '/client/{client_id}/financials/{year}') config.add_route('client_utilization', '/client/{client_id}/utilization/{year}') config.add_route('client_pipeline', '/client/{client_id}/pipeline/{year}') config.add_route('client_projects', '/client/{client_id}/projects/{year}') config.add_route('client_projects_update', '/client/{client_id}/projects/update') config.add_route('project_add', '/project/add') config.add_route('project_bulk_edit', '/office/{office_id}/bulk/edit') config.add_route('project_edit', '/project/{project_id}/edit') config.add_route('project_delete', '/project/{project_id}/delete') config.add_route('freelancer_add', '/freelancer/add') config.add_route('freelancer_edit', '/freelancer/{freelancer_id}/edit') config.add_route('freelancer_convert', '/freelancer/{freelancer_id}/convert') config.add_route('freelancer_delete', '/freelancer/{freelancer_id}/delete') config.add_route('ghost_client_add', '/ghost/client/add') config.add_route('ghost_client_assign_resource', '/ghost/client/assign/resource') config.add_route('ghost_client_edit', '/ghost/client/{ghost_client_id}/edit') config.add_route('ghost_client_delete', '/ghost/client/{ghost_client_id}/delete') config.add_route('ghost_client_financials', '/ghost/client/{ghost_client_id}/financials/{year}') config.add_route('ghost_client_utilization', '/ghost/client/{ghost_client_id}/utilization/{year}') config.add_route('ghost_client_pipeline', '/ghost/client/{ghost_client_id}/pipeline/{year}') config.add_route('ghost_project_add', '/ghost/project/add') config.add_route('ghost_project_edit', '/ghost/project/{ghost_project_id}/edit') config.add_route('ghost_project_delete', '/ghost/project/{ghost_project_id}/delete') config.add_route('ghost_user_add', '/ghost/user/add') config.add_route('ghost_user_edit', '/ghost/user/{ghost_user_id}/edit') config.add_route('ghost_user_delete', '/ghost/user/{ghost_user_id}/delete') config.add_route('ghost_user_assign_edit', '/ghost/user/{ghost_user_id}/assign/edit') config.add_route('ghost_user_assign_add', '/ghost/user/{ghost_user_id}/assign/add') config.add_route( 'ghost_user_assign_delete', '/ghost/user/{ghost_user_id}/assign/{assignment_id}/delete') config.add_route('global_financials', '/global/financials/{year}') config.add_route('global_offices', '/global/office/{year}') config.add_route('global_pipeline', '/global/pipeline/{year}') config.add_route('global_department_utilization', '/global/utilization/department/{year}') config.add_route('global_utilization', '/global/utilization/{year}') config.add_route('global_departments', '/global/department/{year}') return config.make_wsgi_app()
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: huge = Account("Finance", 2013) huge.benefits_and_bonus = 25 huge.midyear_review_start = datetime.date(2013, 4, 15) huge.midyear_review_setup_deadline = datetime.date(2013, 4, 25) huge.midyear_review_end_date = datetime.date(2013, 5, 25) huge.annual_review_start = datetime.date(2014, 1, 15) huge.annual_review_setup_deadline = datetime.date(2014, 1, 15) huge.annual_review_end_date = datetime.date(2014, 1, 15) corp = Office("Corporate", 10, huge) ny = Office("New York", 10, huge) la = Office("Los Angeles", 10, huge) sf = Office("San Francisco", 10, huge) dc = Office("Washington DC", 10, huge) pd = Office("Portland", 10, huge) at = Office("Atlanta",10, huge) ri = Office("Rio de Janiero",10, huge) ld = Office("London", 10, huge) bz = Office("Brazilia", 10, huge) bt = Office("Boutique", 10, huge) ny.allocated_salary_expense = 500000 ny.sga_expense = 2500000 ny.allocated_salary_expense = 200000 ny.sga_expense = 1200000 creative = Department("Creative", huge) corporate = Department("Corporate", huge) ux = Department("User Experience", huge) progm = Department("Program Management", huge) ceo = Role(huge, "CEO", corporate, 50000, 150000) spm = Role(huge, "Senior Project Manager", progm, 50000, 150000) pm = Role(huge, "Project Manager", progm, 50000, 150000) cd = Role(huge, "Creative Director", creative, 50000, 150000) vppm = Role(huge, "Vice President Program Management", progm, 150000, 200000) apm = Role(huge, "Associate Project Manager", progm, 50000, 75000) aaron_permissions = Permissions(True, True, True, True, True, True, True) aaron_permissions.all_financials = True aaron_permissions.all_utilization = True aaron_permissions.all_pipeline = True meghan_permissions = Permissions(False, False, False, False, False, False) aaron = User(huge, "Aaron Mark Shapiro", "*****@*****.**", corp, ceo, 1000, datetime.date(2012, 1, 1)) aaron.permissions = aaron_permissions aaron.percent_billable = 0 mary = User(huge, "Mary Sue Watson", "*****@*****.**", ny, pm, 75000, datetime.date(2013, 1, 1)) meghan = User(huge, "Meghan Francis Henderson", "*****@*****.**", ny, vppm, 150000, datetime.date(2013, 1, 1)) meghan.permissions = meghan_permissions meghan.percent_billable = 50 # this and next time is a hack because i can't get class associations to work progm.manager_name = "Meghan Henderson" #this does not work because meghan.id is not created yet progm.manager_id = meghan.id je = JobHistoryEntry(mary, apm, 50000) je.created_at = datetime.date(2010, 1, 4) je1 = JobHistoryEntry(mary, apm, 55000) je1.created_at = datetime.date(2011, 2, 16) je2 = JobHistoryEntry(mary, pm, 75000) je2.created_at = datetime.date(2012, 1, 7) mary.job_history.append(je) mary.job_history.append(je1) mary.job_history.append(je2) mary.manager = aaron aaron.set_password("aaron") aaron_permissions.user = aaron huge.users.append(aaron) huge.users.append(mary) skillset_category_pd_1 = SkillsetCategory("360 Knowledge Base", progm) skillset_category_pd_2 = SkillsetCategory("Client Management", progm) skillset_pd_1_1 = Skillset("Knows how to tie their shoes", spm, skillset_category_pd_1) skillset_pd_1_2 = Skillset("Can make double knots", spm, skillset_category_pd_1) skillset_pd_2_1 = Skillset("Can use email", spm, skillset_category_pd_1) skillset_pd_2_2 = Skillset("Can send texts", spm, skillset_category_pd_1) skillset_category_pd_1.skillsets.append(skillset_pd_1_1) skillset_category_pd_1.skillsets.append(skillset_pd_1_2) skillset_category_pd_2.skillsets.append(skillset_pd_2_1) skillset_category_pd_2.skillsets.append(skillset_pd_2_2) progm.skillset_categorys.append(skillset_category_pd_1) progm.skillset_categorys.append(skillset_category_pd_2) mary_review = Review(mary, 2013) se_m_1 = SkillsetEntry(mary_review, True, skillset_pd_1_1, 4) se_m_2 = SkillsetEntry(mary_review, True, skillset_pd_1_2, 3) se_m_3 = SkillsetEntry(mary_review, True, skillset_pd_2_1, 3) se_m_4 = SkillsetEntry(mary_review, True, skillset_pd_2_2, 2) mary_review.self_assessment_goals = "I want to learn how to play the piano." mary_review.self_assessment_performance_midyear = "I need to do a better job with sandals." mary_review.general_midyear_comments = "Stellar shoe tieing skills." mary_review.skillset_entries.append(se_m_1) mary_review.skillset_entries.append(se_m_2) mary_review.skillset_entries.append(se_m_3) mary_review.skillset_entries.append(se_m_4) mary.reviews.append(mary_review) DBSession.add_all([mary, meghan, aaron]) lexus = Client("lexus", la) lexus.account = huge comcast = Client("comcast", ny) comcast.account = huge strategy = Project("strategy", lexus, 600000, datetime.date(2013, 5, 1), datetime.date(2013, 6, 15)) design = Project("design", lexus, 1400000, datetime.date(2013, 7, 1), datetime.date(2013, 9, 1)) fall_campaign = Project("fall campaign", comcast, 300000, datetime.date(2013, 5, 1), datetime.date(2013, 6, 15)) ux_refresh = Project("ux refresh", comcast, 400000, datetime.date(2013, 7, 1), datetime.date(2013, 9, 1)) DBSession.add_all([lexus, comcast, strategy, design, fall_campaign, ux_refresh]) free1 = Freelancer("Bob Jones", apm, datetime.date(2013, 5, 1), datetime.date(2013, 6, 1), 30, 100, lexus) free2 = Freelancer("Jane Jones", apm, datetime.date(2013, 5, 1), datetime.date(2013, 6, 1), 30, 50, lexus) ua = UserAllocation(mary, lexus, None, 100, datetime.date(2013, 5, 1), datetime.date(2013, 12, 31)) gu = GhostUser(apm, la, datetime.date(2013, 7, 1), 100) gh = GhostAllocation(gu, lexus, None, 100, datetime.date(2013, 8, 1), datetime.date(2013, 12, 31)) gp = GhostProject("development", lexus, None, 1200000, 90, datetime.date(2013, 8, 1), datetime.date(2013, 12, 31)) usaa = GhostClient("USAA", ny) gp2 = GhostProject("aor", None, usaa, 3500000, 10, datetime.date(2013, 9, 1), datetime.date(2014, 12, 31)) tbg = GhostClient(None, ny) gp3 = GhostProject("tbg", None, tbg, 200000, 0, datetime.date(2013, 6, 1), datetime.date(2013, 12, 31)) DBSession.add_all([free1, free2, ua, gu, gh, gp, usaa, gp2, tbg, gp3])