mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
* Add skeleton for builtin label printing plugin * Force selection of plugin when printing labels * Enhance LabelPrintingMixin class - Add render_to_pdf method - Add render_to_html method * Enhance plugin mixin - Add class attribute to select blocking or non-blocking printing - Add render_to_png method - Add default method for printing multiple labels - Add method for offloding print job * Simplify print_label background function - All arguments now handled by specific plugin * Simplify label printing API - Simply pass data to the particular plugin - Check result type - Return result * Updated sample plugin * Working on client side code * Cleanup * Update sample plugin * Add new model type - LabelOutput model - Stores generated label file to the database - Makes available for download * Update label printing plugin mixin * Add background task to remove any old label outputs * Open file if response contains filename * Remove "default printer" option which does not specify a plugin * Delete old labels after 5 days * Remove debug statements * Update API version * Changed default behaviour to background printing * Update label plugin mixin docs * Provide default printer if none provided (legacy) * Update unit test * unit test updates * Further fixes for unit tests * unit test updates
17 lines
479 B
Python
17 lines
479 B
Python
"""Background tasks for the label app"""
|
|
|
|
from datetime import timedelta
|
|
|
|
from django.utils import timezone
|
|
|
|
from InvenTree.tasks import ScheduledTask, scheduled_task
|
|
from label.models import LabelOutput
|
|
|
|
|
|
@scheduled_task(ScheduledTask.DAILY)
|
|
def cleanup_old_label_outputs():
|
|
"""Remove old label outputs from the database"""
|
|
|
|
# Remove any label outputs which are older than 30 days
|
|
LabelOutput.objects.filter(created__lte=timezone.now() - timedelta(days=5)).delete()
|