def can_convert_to_pdf(self): ft = self.filetype.lower() name = self.name.lower() return ( self.converted_id is None and can_convert_to_pdf(ft, name=name) )
def foiattachment_convert_attachment(instance=None, created=False, **kwargs): if kwargs.get('raw', False): return from .tasks import convert_attachment_task if can_convert_to_pdf(instance.filetype, name=instance.name): if instance.converted_id is None: convert_attachment_task.delay(instance.id)
def convert(self, request, queryset): if not queryset: return count = 0 for instance in queryset: ft = instance.filetype.lower() name = instance.name.lower() if can_convert_to_pdf(ft, name=name): count += 1 convert_attachment_task.delay(instance.pk) self.message_user(request, _("Conversion tasks started: %s") % count)
def can_convert_to_pdf(self): ft = self.filetype.lower() name = self.name.lower() return (self.converted_id is None and can_convert_to_pdf(ft, name=name))