Example #1
0
import properties
import views
from role_types import RoleType, get_choices


def perform_delete(model, action_name):
    model.entity.key.delete()
    parent = data_models.get_parent(model.entity)
    roleName = dict(get_choices()).get(model.entity.type_index, "")
    model.audit(action_name, "Delete role %s performed" % roleName, parent)
    model.entity_deleted = True
    return True


ACTION_UPDATE = views.update_action(RoleType.USER_ADMIN)
ACTION_CREATE = views.create_action(RoleType.USER_ADMIN)
ACTION_DELETE = views.Action('delete', 'Delete', RoleType.USER_ADMIN,
                             perform_delete)


class RoleForm(wtforms.Form):
    type_index = custom_fields.SelectField(label='Role Type',
                                           coerce=int,
                                           choices=get_choices())
    committee = custom_fields.SelectField(choices=[("", "")] +
                                          data_models.committee_labels)


@app.route('/role_list/<db_id>', methods=['GET', 'POST'])
def view_role_list(db_id):
    user = data_models.lookup_entity(db_id)
Example #2
0
               (2, u'Large >= £5k pa')]


def perform_approve(model, action_name):
    model.entity.state_index = STATE_APPROVED
    model.entity.put()
    model.audit(action_name, 'Approved performed')
    return True


ACTION_APPROVE = views.StateAction('approve', 'Approve',
                                   RoleType.PROJECT_APPROVER, perform_approve,
                                   [STATE_APPROVAL_PENDING])
ACTION_UPDATE = views.update_action(RoleType.PROJECT_CREATOR,
                                    [STATE_APPROVAL_PENDING, STATE_APPROVED])
ACTION_CREATE = views.create_action(RoleType.PROJECT_CREATOR)
ACTION_CLOSE = views.StateAction('close', 'Close', RoleType.PROJECT_CREATOR,
                                 data_models.Model.perform_close,
                                 [STATE_APPROVAL_PENDING, STATE_APPROVED])
action_list = [ACTION_UPDATE, ACTION_APPROVE, ACTION_CLOSE]


class ProjectForm(wtforms.Form):
    name = wtforms.StringField(validators=[wtforms.validators.InputRequired()])
    committee = custom_fields.SelectField(label='Primary Committee',
                                          choices=data_models.committee_labels)
    multi_committee = wtforms.BooleanField()
    fund = custom_fields.SelectField(coerce=data_models.create_key)
    partner = custom_fields.SelectField(coerce=data_models.create_key)
    size = custom_fields.SelectField(label='Project Size',
                                     coerce=int,
                                        enumerate(state_labels))


def perform_transferred(model, action_name):
    model.entity.state_index = TRANSFER_COMPLETE
    model.entity.put()
    model.audit(action_name, "Transfer performed")
    return True


ACTION_TRANSFERRED = views.StateAction('transferred', 'Transferred',
                                       RoleType.FUND_ADMIN,
                                       perform_transferred, [TRANSFER_PENDING])
ACTION_UPDATE = views.update_action(RoleType.COMMITTEE_ADMIN,
                                    [TRANSFER_PENDING])
ACTION_CREATE = views.create_action(RoleType.COMMITTEE_ADMIN)
ACTION_CANCEL = views.cancel_action(RoleType.COMMITTEE_ADMIN,
                                    [TRANSFER_PENDING])
action_list = [ACTION_UPDATE, ACTION_TRANSFERRED, ACTION_CANCEL]


class MoneyForm(wtforms.Form):
    value = wtforms.IntegerField()


class InternalTransferForm(wtforms.Form):
    amount = wtforms.FormField(MoneyForm,
                               widget=custom_fields.form_field_widget)
    dest_fund = custom_fields.SelectField(
        'Destination Fund',
        coerce=data_models.create_key,