mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	Update Job Blueprint package
This commit is contained in:
		
							
								
								
									
										2
									
								
								app/blueprints/jobs/results/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								app/blueprints/jobs/results/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
from .. import bp
 | 
			
		||||
from . import routes
 | 
			
		||||
							
								
								
									
										27
									
								
								app/blueprints/jobs/results/routes.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/blueprints/jobs/results/routes.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
from flask import abort, send_from_directory
 | 
			
		||||
from flask_login import current_user, login_required
 | 
			
		||||
from app.models import JobResult
 | 
			
		||||
from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/<hashid:job_id>/results/<hashid:job_result_id>/download')
 | 
			
		||||
@login_required
 | 
			
		||||
def download_job_result(job_id: int, job_result_id: int):
 | 
			
		||||
    job_result = JobResult.query.filter_by(
 | 
			
		||||
        job_id=job_id,
 | 
			
		||||
        id=job_result_id
 | 
			
		||||
    ).first_or_404()
 | 
			
		||||
 | 
			
		||||
    if not (
 | 
			
		||||
        job_result.job.user == current_user
 | 
			
		||||
        or current_user.is_administrator
 | 
			
		||||
    ):
 | 
			
		||||
        abort(403)
 | 
			
		||||
 | 
			
		||||
    return send_from_directory(
 | 
			
		||||
        job_result.path.parent,
 | 
			
		||||
        job_result.path.name,
 | 
			
		||||
        as_attachment=True,
 | 
			
		||||
        download_name=job_result.filename,
 | 
			
		||||
        mimetype=job_result.mimetype
 | 
			
		||||
    )
 | 
			
		||||
		Reference in New Issue
	
	Block a user