Exemplo n.º 1
0
class CodeTableAdmin(ocom_admin.NoDeleteMixin, ocom_admin.CodeModelsAdmin):
    list_display = ocom_admin.build_list_property(*CODE_DESCRIPTION_TUPLE, with_list_filter=False)
    list_filter = ocom_admin.build_list_property('code', )
    fieldsets = (
        (None, {'fields': CODE_DESCRIPTION_TUPLE}),
        ACTIVE_DATE_FIELDS_TUPLE,
    )
    search_fields = CODE_DESCRIPTION_TUPLE
Exemplo n.º 2
0
class ClientManagerAdmin(CreateUserAdminMixin, ocom_admin.OcomModelAdmin):
    fieldsets = (
        ('Main Info', {'fields': ('name', 'email', 'phone_number', 'client', )}),
        ('Account', {'classes': ('collapse',), 'fields': ACCOUNT_TUPLE}),
        ACTIVE_DATE_FIELDS_TUPLE,
    )
    list_display = ocom_admin.build_list_property(*('name', 'email', 'phone_number', 'enabled', 'username'),
                                                  with_list_filter=False)
    list_filter = ocom_admin.build_list_property('enabled')
    search_fields = ('name', 'phone_number', ) + EMAIL_USERNAME_TUPLE
    form = forms.ClientManagerForm

    role_name = "client_manager"
Exemplo n.º 3
0
class CodeFileTypeAdmin(CodeTableAdmin):
    list_display = ocom_admin.build_list_property(*CODE_DESCRIPTION_CAN_EMAIL_TUPLE, with_list_filter=False)
    fieldsets = (
        ('Main Info', {'fields': CODE_DESCRIPTION_CAN_EMAIL_TUPLE}),
        ACTIVE_DATE_FIELDS_TUPLE,
    )
    form = forms.CodeFileTypeForm
Exemplo n.º 4
0
class ClientAdmin(ocom_admin.OcomModelAdmin):
    fieldsets = (
        ('Main Info', {'fields': CLIENT_TUPLE + ('suppliers', )}),
        ACTIVE_DATE_FIELDS_TUPLE,
    )
    list_display = ocom_admin.build_list_property(*('name', 'has_xero', 'send_invoices', 'required_part_a',
                                                    'they_supply_pump',), with_list_filter=False)
    list_filter = ocom_admin.build_list_property('suppliers__name')
    search_fields = ('name', 'suppliers__name', )
    form = forms.ClientForm

    # noinspection PyMethodMayBeStatic
    def has_xero(self, obj):
        if obj.xero_customer:
            return "Existing Xero Customer"
        else:
            return "-- Create New --"
Exemplo n.º 5
0
class SubbieAdmin(CreateUserAdminMixin, ocom_admin.OcomModelAdmin):
    fieldsets = (
        ('Main Info', {'fields': NAME_TYPE_XERO_SUPPLIER_TUPLE + ('email', 'rate_per_m', 'jobs_per_day',
                                                                  'can_see_plans_before_accept', 'display_order',)}),
        ('Account', {'classes': ('collapse',), 'fields': ACCOUNT_TUPLE}),
        ACTIVE_DATE_FIELDS_TUPLE,
    )
    list_display = ocom_admin.build_list_property(*(('name', 'type', 'has_xero', 'display_order',) +
                                                    EMAIL_USERNAME_TUPLE),
                                                  with_list_filter=False)
    list_filter = ocom_admin.build_list_property('type', 'enabled')
    search_fields = ('name', 'display_order', ) + EMAIL_USERNAME_TUPLE
    form = forms.SubbieForm

    role_name = "subcontractor"

    # noinspection PyMethodMayBeStatic
    def has_xero(self, obj):
        if obj.xero_supplier:
            return "Existing Xero Supplier"
        else:
            return "-- Create New --"
Exemplo n.º 6
0
class RoleAdmin(ocom_admin.NoDeleteMixin, admin.ModelAdmin):
    fieldsets = (
        ('Main Info', {'fields': ('user', 'is_active', 'first_name', 'last_name', 'email', 'administrator', 'supervisor',
                                  'subcontractor', 'client_manager', 'employee')}),
        ACTIVE_DATE_FIELDS_TUPLE,
    )
    list_display = ocom_admin.build_list_property(
        *('user', 'is_active', 'administrator', 'supervisor', 'subcontractor', 'client_manager',
          'employee', 'last_name', 'first_name', 'email',), with_list_filter=False)
    form = forms.RoleForm
    list_filter = ocom_admin.build_list_property('administrator', 'supervisor', 'subcontractor',
                                                 'client_manager', 'employee')
    search_fields = ('user__last_name', 'user__first_name', 'user__email', 'user__username')
    ordering = ('user__username',)

    def email(self, obj):
        return obj.user.email
    email.admin_order_field = 'user__email'

    def last_name(self, obj):
        return obj.user.last_name
    last_name.admin_order_field = 'user__last_name'

    def first_name(self, obj):
        return obj.user.first_name
    first_name.admin_order_field = 'user__first_name'

    def is_active(self, obj):
        return obj.user.is_active
    is_active.short_description = "Is Active"
    is_active.admin_order_field = 'user__is_active'
    is_active.boolean = True

    def change_password(self, obj):
        # the link here is presumed so if this was customised in urls.py, you have to change the one below as well
        return '<a href="/adm/auth/user/{}/password/">Change</a>'.format(obj.user.id)
    change_password.allow_tags = True
    change_password.short_description = "Password"
Exemplo n.º 7
0
class CodeJobTypeAdmin(CodeTableAdmin):
    list_display = ocom_admin.build_list_property(*(CODE_DESCRIPTION_TUPLE + ('colour_actual', )),
                                                  with_list_filter=False)
    fieldsets = (
        ('Main Info', {
            'fields': CODE_DESCRIPTION_TUPLE + ('background_colour', 'foreground_colour', )
        }), ACTIVE_DATE_FIELDS_TUPLE,
    )
    form = forms.CodeJobTypeForm

    # noinspection PyMethodMayBeStatic
    def colour_actual(self, instance):
        return '<span class="color-block" style="background-color: {}; color: {}">TEXT GOES HERE</span>'.\
            format(instance.background_colour, instance.foreground_colour)
    colour_actual.short_description = "Colour"
    colour_actual.allow_tags = True