mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
* Added initial draft for machines * refactor: isPluginRegistryLoaded check into own ready function * Added suggestions from codereview * Refactor: base_drivers -> machine_types * Use new BaseInvenTreeSetting unique interface * Fix Django not ready error * Added get_machines function to driver - get_machines function on driver - get_machine function on driver - initialized attribute on machine * Added error handeling for driver and machine type * Extended get_machines functionality * Export everything from plugin module * Fix spelling mistakes * Better states handeling, BaseMachineType is now used instead of Machine Model * Use uuid as pk * WIP: machine termination hook * Remove termination hook as this does not work with gunicorn * Remove machine from registry after delete * Added ClassProviderMixin * Check for slug dupplication * Added config_type to MachineSettings to define machine/driver settings * Refactor helper mixins into own file in InvenTree app * Fixed typing and added required_attributes for BaseDriver * fix: generic status import * Added first draft for machine states * Added convention for status codes * Added update_machine hook * Removed unnecessary _key suffix from machine config model * Initil draft for machine API * Refactored BaseInvenTreeSetting all_items and allValues method * Added required to InvenTreeBaseSetting and check_settings method * check if all required machine settings are defined and refactor: use getattr * Fix: comment * Fix initialize error and python 3.9 compability * Make machine states available through the global states api * Added basic PUI machine admin implementation that is still in dev * Added basic machine setting UI to PUI * Added machine detail view to PUI admin center * Fix merge issues * Fix style issues * Added machine type,machine driver,error stack tables * Fix style in machine/serializers.py * Added pui link from machine to machine type/driver drawer * Removed only partially working django admin in favor of the PUI admin center implementation * Added required field to settings item * Added machine restart function * Added restart requird badge to machine table/drawer * Added driver init function * handle error functions for machines and registry * Added driver errors * Added machine table to driver drawer * Added back button to detail drawer component * Fix auto formatable pre-commit * fix: style * Fix deepsource * Removed slug field from table, added more links between drawers, remove detail drawer blur * Added initial docs * Removed description from driver/machine type select and fixed disabled driver select if no machine type is selected * Added basic label printing implementation * Remove translated column names because they are now retrieved from the api * Added printer location setting * Save last 10 used printer machine per user and sort them in the printing dialog * Added BasePrintingOptionsSerializer for common options * Fix not printing_options are not properly casted to its internal value * Fix type * Improved machine docs * Fix docs * Added UNKNOWN status code to label printer status * Skip machine loading when running migrations * Fix testing? * Fix: tests? * Fix: tests? * Disable docs check precommit * Disable docs check precommit * First draft for tests * fix test * Add type ignore * Added API tests * Test ci? * Add more tests * Added more tests * Bump api version * Changed driver/base driver naming schema * Added more tests * Fix tests * Added setting choice with kwargs and get_machines with initialized=None * Refetch table after deleting machine * Fix test --------- Co-authored-by: Matthias Mair <code@mjmair.com>
49 lines
1.2 KiB
Python
Executable File
49 lines
1.2 KiB
Python
Executable File
"""Django admin interface for the machine app."""
|
|
|
|
from django.contrib import admin
|
|
from django.http.request import HttpRequest
|
|
|
|
from machine import models
|
|
|
|
|
|
class MachineSettingInline(admin.TabularInline):
|
|
"""Inline admin class for MachineSetting."""
|
|
|
|
model = models.MachineSetting
|
|
|
|
read_only_fields = ['key', 'config_type']
|
|
|
|
def has_add_permission(self, request, obj):
|
|
"""The machine settings should not be meddled with manually."""
|
|
return False
|
|
|
|
|
|
@admin.register(models.MachineConfig)
|
|
class MachineConfigAdmin(admin.ModelAdmin):
|
|
"""Custom admin with restricted id fields."""
|
|
|
|
list_filter = ['active']
|
|
list_display = [
|
|
'name',
|
|
'machine_type',
|
|
'driver',
|
|
'initialized',
|
|
'active',
|
|
'no_errors',
|
|
'get_machine_status',
|
|
]
|
|
readonly_fields = [
|
|
'initialized',
|
|
'is_driver_available',
|
|
'get_admin_errors',
|
|
'get_machine_status',
|
|
]
|
|
inlines = [MachineSettingInline]
|
|
|
|
def get_readonly_fields(self, request, obj):
|
|
"""If update, don't allow changes on machine_type and driver."""
|
|
if obj is not None:
|
|
return ['machine_type', 'driver', *self.readonly_fields]
|
|
|
|
return self.readonly_fields
|