column_labels = dict(
        category='Category Group', category_friendly_name='Category Name'
    )

    form_extra_fields = {
        'category': QuerySelectField(
            'Stage Order',
            query_factory=Category.parent_category_query_factory,
            get_pk=lambda i: i.category,
            get_label=lambda i: i.category,
        )
    }

admin.add_view(ScoutContractAdmin(
    ContractBase, db.session, name='Contracts', endpoint='contract', category='Scout'
))
admin.add_view(CompanyAdmin(
    Company, db.session, name='Companies', endpoint='company', category='Scout'
))
admin.add_view(ContractTypeAdmin(
    ContractType, db.session, name='Contract Types', endpoint='contract-type', category='Scout'
))
admin.add_view(DepartmentAdmin(
    Department, db.session, name='Departments', endpoint='department', category='Scout'
))

admin.add_view(StageAdmin(Stage, db.session, endpoint='stage', category='Conductor'))
admin.add_view(FlowAdmin(Flow, db.session, endpoint='flow', category='Conductor'))
admin.add_view(ConductorContractAdmin(
    ContractBase, db.session, name='Contracts', endpoint='conductor-contract', category='Conductor'
    column_list = ["category", "category_friendly_name"]
    form_columns = ["category", "category_friendly_name"]

    column_labels = dict(category="Category Group", category_friendly_name="Category Name")

    form_extra_fields = {
        "category": QuerySelectField(
            "Stage Order",
            query_factory=Category.parent_category_query_factory,
            get_pk=lambda i: i.category,
            get_label=lambda i: i.category,
        )
    }


admin.add_view(ScoutContractAdmin(ContractBase, db.session, name="Contracts", endpoint="contract", category="Scout"))
admin.add_view(CompanyAdmin(Company, db.session, name="Companies", endpoint="company", category="Scout"))
admin.add_view(
    ContractTypeAdmin(ContractType, db.session, name="Contract Types", endpoint="contract-type", category="Scout")
)
admin.add_view(DepartmentAdmin(Department, db.session, name="Departments", endpoint="department", category="Scout"))

admin.add_view(StageAdmin(Stage, db.session, endpoint="stage", category="Conductor"))
admin.add_view(FlowAdmin(Flow, db.session, endpoint="flow", category="Conductor"))
admin.add_view(
    ConductorContractAdmin(
        ContractBase, db.session, name="Contracts", endpoint="conductor-contract", category="Conductor"
    )
)
admin.add_view(
    ConductorContractStageAdmin(
                         category_friendly_name='Category Name')

    form_extra_fields = {
        'category':
        QuerySelectField(
            'Stage Order',
            query_factory=Category.parent_category_query_factory,
            get_pk=lambda i: i.category,
            get_label=lambda i: i.category,
        )
    }


admin.add_view(
    ScoutContractAdmin(ContractBase,
                       db.session,
                       name='Contracts',
                       endpoint='contract',
                       category='Scout'))
admin.add_view(
    CompanyAdmin(Company,
                 db.session,
                 name='Companies',
                 endpoint='company',
                 category='Scout'))
admin.add_view(
    ContractTypeAdmin(ContractType,
                      db.session,
                      name='Contract Types',
                      endpoint='contract-type',
                      category='Scout'))
admin.add_view(
Exemplo n.º 4
0
    form_overrides = dict(department=SelectField)
    form_args = dict(department={'choices': DEPARTMENT_CHOICES})

    def is_accessible(self):
        if current_user.is_anonymous():
            return url_for('users.login', next=request.path)
        if current_user.role.name == 'admin':
            return True


class UserRoleAdmin(SuperAdminMixin, sqla.ModelView):
    form_columns = ['email', 'first_name', 'last_name', 'department', 'role']

    form_overrides = dict(department=SelectField)
    form_args = dict(department={'choices': DEPARTMENT_CHOICES})


class RoleAdmin(SuperAdminMixin, sqla.ModelView):
    pass


admin.add_view(ContractAdmin(ContractBase, db.session, endpoint='contract'))
admin.add_view(CompanyAdmin(Company, db.session, endpoint='company'))
admin.add_view(StageAdmin(Stage, db.session, endpoint='stage'))
admin.add_view(FlowAdmin(Flow, db.session, endpoint='flow'))
admin.add_view(UserAdmin(User, db.session, name='User', endpoint='user'))
admin.add_view(
    UserRoleAdmin(User, db.session, name='User w/Roles',
                  endpoint='user-roles'))
admin.add_view(RoleAdmin(Role, db.session, endpoint='role'))
Exemplo n.º 5
0
    form_overrides = dict(department=SelectField)
    form_args = dict(department={
        'choices': DEPARTMENT_CHOICES
    })

    def is_accessible(self):
        if current_user.is_anonymous():
            return url_for('users.login', next=request.path)
        if current_user.role.name == 'admin':
            return True

class UserRoleAdmin(SuperAdminMixin, sqla.ModelView):
    form_columns = ['email', 'first_name', 'last_name', 'department', 'role']

    form_overrides = dict(department=SelectField)
    form_args = dict(department={
        'choices': DEPARTMENT_CHOICES
    })


class RoleAdmin(SuperAdminMixin, sqla.ModelView):
    pass

admin.add_view(ContractAdmin(ContractBase, db.session, endpoint='contract'))
admin.add_view(CompanyAdmin(Company, db.session, endpoint='company'))
admin.add_view(StageAdmin(Stage, db.session, endpoint='stage'))
admin.add_view(FlowAdmin(Flow, db.session, endpoint='flow'))
admin.add_view(UserAdmin(User, db.session, name='User', endpoint='user'))
admin.add_view(UserRoleAdmin(User, db.session, name='User w/Roles', endpoint='user-roles'))
admin.add_view(RoleAdmin(Role, db.session, endpoint='role'))