def view_partner(db_id): partner = data_models.lookup_entity(db_id) supplier = data_models.get_parent(partner) model = data_models.Model(partner, None, db.Partner) form = PartnerForm(request.form, obj=partner) model.add_form(ACTION_UPDATE.name, form) return views.view_std_entity(model, 'Partner ' + partner.name, (name_field, ), (ACTION_UPDATE, ))
def view_user(db_id): user = data_models.lookup_entity(db_id) model = data_models.Model(user, None, db.User) form = UserForm(request.form, obj=user) model.add_form(ACTION_UPDATE.name, form) property_list = (name_field, email_field) return views.view_std_entity(model, 'User ' + user.name, property_list, (ACTION_UPDATE, ), 0, link_pairs)
def view_fund(db_id): fund = data_models.lookup_entity(db_id) model = data_models.Model(fund, fund.committee, db.Fund) form = FundForm(request.form, fund) model.add_form(ACTION_UPDATE.name, form) property_list = (state_field, name_field, code_field, description_field) return views.view_std_entity(model, 'Fund ' + fund.name, property_list, [ACTION_UPDATE, ACTION_CLOSE], 1, link_pairs)
def view_role(db_id): role = data_models.lookup_entity(db_id) model = data_models.Model(role, None) form = RoleForm(request.form, role) model.add_form(ACTION_UPDATE.name, form) property_list = map(properties.create_readonly_field, form._fields.keys(), form._fields.values()) return views.view_std_entity(model, 'Role', property_list, [ACTION_UPDATE, ACTION_DELETE])
def view_grant(db_id): grant = data_models.lookup_entity(db_id) fund = data_models.get_parent(grant) model = GrantModel(grant, fund.committee) add_grant_form(model, ACTION_UPDATE) title = 'Grant on ' + str(grant.target_date) property_list = (state_field, creator_field, transferred_amount_field, amount_field, project_field, target_date_field, foreign_transfer_field, description_field) return views.view_std_entity(model, title, property_list, action_list, num_wide=1)
def view_internaltransfer(db_id): transfer = data_models.lookup_entity(db_id) fund = data_models.get_parent(transfer) model = data_models.Model(transfer, fund.committee) add_transfer_form(request.form, model, ACTION_UPDATE) title = 'InternalTransfer to ' + transfer.dest_fund.get( ).name if transfer.dest_fund != None else "" property_list = (state_field, properties.KeyProperty('creator'), properties.KeyProperty('dest_fund'), properties.StringProperty('amount'), properties.StringProperty('description')) return views.view_std_entity(model, title, property_list, action_list)
def view_pledge(db_id): pledge = data_models.lookup_entity(db_id) fund = data_models.get_parent(pledge) model = data_models.Model(pledge, fund.committee) form = PledgeForm(request.form, obj=pledge) model.add_form(ACTION_UPDATE.name, form) title = 'Pledge ' + pledge.ref_id property_list = (ref_id_field, state_field, properties.KeyProperty('creator'), properties.StringProperty('amount'), properties.StringProperty('description')) return views.view_std_entity( model, title, property_list, (ACTION_UPDATE, ACTION_FULFILLED, ACTION_BOOKED))
def view_project(db_id): project = data_models.lookup_entity(db_id) supplier = data_models.get_parent(project) model = data_models.Model(project, None, db.Project) form = create_project_form(project, supplier) model.add_form(ACTION_UPDATE.name, form) property_list = [state_field] + map(properties.create_readonly_field, form._fields.keys(), form._fields.values()) return views.view_std_entity(model, 'Project ' + project.name, property_list, action_list, num_wide=1)
def view_supplierfund(db_id): fund = data_models.lookup_entity(db_id) supplier = data_models.get_parent(fund) model = data_models.Model(fund, None, db.SupplierFund) if request.form: form = SupplierFundForm(request.form) else: form = SupplierFundForm(obj=fund) model.add_form(ACTION_UPDATE.name, form) property_list = map(properties.create_readonly_field, form._fields.keys(), form._fields.values()) return views.view_std_entity(model, 'SupplierFund ' + fund.name, property_list, (ACTION_UPDATE, ), num_wide=1)