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_internaltransfer_list(db_id):
    fund = data_models.lookup_entity(db_id)
    new_transfer = db.InternalTransfer(parent=fund.key)
    model = data_models.Model(new_transfer, fund.committee,
                              db.InternalTransfer)
    add_transfer_form(request.form, model, ACTION_CREATE)
    property_list = (state_field, properties.KeyProperty('dest_fund'),
                     properties.StringProperty('amount'))
    transfer_query = db.InternalTransfer.query(
        ancestor=fund.key).order(-db.InternalTransfer.state_index)
    return views.view_std_entity_list(model, 'Internal Transfer List',
                                      ACTION_CREATE, property_list,
                                      transfer_query, fund)
Example #3
0
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))
Example #4
0
    return renderers.render_link(label, url, class_="button")


def view_links(parent, *link_pairs):
    links = [view_link(kind, label, parent) for kind, label in link_pairs]
    return renderers.render_nav(*links)


def view_errors(model):
    return renderers.render_errors(model.errors)


audit_fields = [
    properties.DateProperty('timestamp'),
    properties.StringProperty('message'),
    properties.KeyProperty('user')
]


def view_entity_history(key):
    audit_list = db.AuditRecord.query(
        db.AuditRecord.entity == key).order(-db.AuditRecord.timestamp).iter(
            limit=20)
    sub_heading = renderers.sub_heading('Activity Log')
    table = view_entity_list(audit_list,
                             audit_fields,
                             selectable=False,
                             no_links=False)
    return (sub_heading, table)

Example #5
0
    entity.transfer = None
    entity.put()
    model.email_and_audit(action_name, 'Checked performed')

ACTION_CHECKED = views.StateAction('checked', 'Funds Checked', RoleType.FUND_ADMIN,
                                   perform_checked, [STATE_WAITING])
ACTION_ACKNOWLEDGED = views.StateAction('ack', 'Received', RoleType.COMMITTEE_ADMIN,
                                        data_models.Model.perform_close, [STATE_TRANSFERED])
ACTION_CANCEL = views.cancel_action(RoleType.COMMITTEE_ADMIN, [STATE_WAITING, STATE_READY])
ACTION_UPDATE = views.update_action(RoleType.COMMITTEE_ADMIN, [STATE_WAITING])
ACTION_CREATE = views.Action('create', 'New', RoleType.COMMITTEE_ADMIN, perform_create)

action_list = [ACTION_UPDATE, ACTION_CHECKED, ACTION_ACKNOWLEDGED, ACTION_CANCEL]

state_field = properties.SelectProperty(state_of, 'State', enumerate(state_labels))
creator_field = properties.KeyProperty('creator', 'Requestor')
project_field = properties.KeyProperty('project')
amount_field = properties.StringProperty('amount')
transferred_amount_field = properties.StringProperty(data_models.calculate_transferred_amount, 'Transferred Amount')
source_field = properties.StringProperty(lambda e: e.key.parent().get().code, 'Source Fund')
target_date_field = properties.DateProperty('target_date', format='%Y-%m')
description_field = properties.StringProperty('description')
foreign_transfer_field = properties.KeyProperty('transfer')

class GrantForm(wtforms.Form):
    amount = wtforms.FormField(custom_fields.MoneyForm, label='Requested Amount', widget=custom_fields.form_field_widget)
    project = custom_fields.SelectField(coerce=data_models.create_key, validators=[wtforms.validators.InputRequired()])
    target_date = wtforms.DateField(widget=widgets.MonthInput(), format='%Y-%m',
                                validators=[wtforms.validators.InputRequired()])
    description = wtforms.TextAreaField()

def render_grants_due_list(supplier):
    cutoff_date = datetime.date.today() + datetime.timedelta(21)
    grant_list = db.find_pending_grants(supplier, cutoff_date)
    field_list = (grants.state_field, grants.target_date_field,
                  grants.creator_field, grants.source_field,
                  grants.project_field, grants.amount_field)
    sub_heading = renderers.sub_heading('Grant Payments Due')
    table = views.view_entity_list(grant_list, field_list)
    return (sub_heading, table)


po_number_field = properties.StringProperty(
    lambda e: e.key.parent().get().po_number, 'PO Number')
creator_field = properties.KeyProperty(lambda e: e.key.parent().get().creator,
                                       'Requestor')
source_field = properties.StringProperty(
    lambda e: e.key.parent().parent().get().code, 'Source Fund')
payment_field_list = [
    purchases.payment_type_field, po_number_field, creator_field, source_field,
    purchases.payment_amount_field
]


def render_purchase_payments_list(supplier):
    column_headers = properties.get_labels(payment_field_list)
    payment_list = db.find_pending_payments(supplier)
    payment_grid = properties.display_entity_list(payment_list,
                                                  payment_field_list,
                                                  no_links=True)
    purchase_list = [data_models.get_parent(e) for e in payment_list]
Example #7
0
from flask import render_template

from application import app
import db
import data_models
import views
import properties
import renderers
import role_types

from page import *

audit_fields = [
    properties.DateProperty('timestamp'),
    properties.StringProperty(lambda e: e.entity.kind(), 'EntityType'),
    properties.KeyProperty('entity'),
    properties.StringProperty('message'),
    properties.KeyProperty('user')
]


@app.route('/')
def home():
    model = data_models.Model(None)
    links = views.view_links(None, ('Committee', 'Show Committees'),
                             ('Supplier', 'Show Suppliers'),
                             ('User', 'Show Users'))
    audit_list = db.AuditRecord.query(db.AuditRecord.parent == None).order(
        -db.AuditRecord.timestamp).fetch(10)
    sub_heading = renderers.sub_heading('Recent Activity')
    table = views.view_entity_list(audit_list,
Example #8
0
    'Advance Paid', 'Payment Due'
]


def state_of(purchase):
    state = purchase.state_index
    if state == STATE_ORDERED:
        if purchase.invoice != None and not purchase.invoice.get().paid:
            return STATE_PAYMENT_DUE
        if purchase.advance != None:
            return STATE_ADVANCED if purchase.advance.get(
            ).paid else STATE_ADVANCE_PENDING
    return state


supplier_field = properties.KeyProperty('supplier')
quote_amount_field = properties.StringProperty('quote_amount')
description_field = properties.StringProperty('description')
state_field = properties.SelectProperty(state_of, 'State',
                                        enumerate(state_labels))
po_number_field = properties.StringProperty('po_number', 'PO number')
creator_field = properties.KeyProperty('creator')

payment_amount_field = properties.StringProperty('amount', 'Payment Amount')
payment_paid_field = properties.StringProperty('paid', 'Paid')
payment_type_field = properties.StringProperty(
    lambda e: e.payment_type.capitalize(), 'Type')
payment_transfer_field = properties.KeyProperty('transfer')
payment_transferred_field = properties.StringProperty(
    lambda e: data_models.calculate_transferred_amount(e),
    'Transferred Amount')