mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Add more context data to report
This commit is contained in:
		@@ -175,6 +175,10 @@ class ReportTemplateBase(ReportBase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        context = self.get_context_data(request)
 | 
					        context = self.get_context_data(request)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        context['media'] = settings.MEDIA_ROOT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        context['report_name'] = self.name
 | 
				
			||||||
 | 
					        context['report_description'] = self.description
 | 
				
			||||||
        context['request'] = request
 | 
					        context['request'] = request
 | 
				
			||||||
        context['user'] = request.user
 | 
					        context['user'] = request.user
 | 
				
			||||||
        context['datetime'] = datetime.datetime.now()
 | 
					        context['datetime'] = datetime.datetime.now()
 | 
				
			||||||
@@ -194,8 +198,16 @@ class ReportTemplateBase(ReportBase):
 | 
				
			|||||||
                raise ValidationError("Enable LaTeX support in config.yaml")
 | 
					                raise ValidationError("Enable LaTeX support in config.yaml")
 | 
				
			||||||
        elif self.extension in ['.htm', '.html']:
 | 
					        elif self.extension in ['.htm', '.html']:
 | 
				
			||||||
            # Render HTML template to PDF
 | 
					            # Render HTML template to PDF
 | 
				
			||||||
            wp = WeasyprintReportMixin(request, self.template_name, **kwargs)
 | 
					            wp = WeasyprintReportMixin(
 | 
				
			||||||
            return wp.render_to_response(context, **kwargs)
 | 
					                request,
 | 
				
			||||||
 | 
					                self.template_name,
 | 
				
			||||||
 | 
					                base_url=request.build_absolute_uri("/"),
 | 
				
			||||||
 | 
					                presentational_hints=True,
 | 
				
			||||||
 | 
					                **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return wp.render_to_response(
 | 
				
			||||||
 | 
					                context,
 | 
				
			||||||
 | 
					                **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enabled = models.BooleanField(
 | 
					    enabled = models.BooleanField(
 | 
				
			||||||
        default=True,
 | 
					        default=True,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,15 @@ function selectTestReport(reports, items, options={}) {
 | 
				
			|||||||
     * (via AJAX) from the server.
 | 
					     * (via AJAX) from the server.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // If there is only a single report available, just print!
 | 
				
			||||||
 | 
					    if (reports.length == 1) {
 | 
				
			||||||
 | 
					        if (options.success) {
 | 
				
			||||||
 | 
					            options.success(reports[0].pk);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var modal = options.modal || '#modal-form';
 | 
					    var modal = options.modal || '#modal-form';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var report_list = makeOptionsList(
 | 
					    var report_list = makeOptionsList(
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user