Coverage for portality/view/jct.py: 65%

20 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-07-19 17:05 +0100

1from flask import Blueprint 

2from flask_login import current_user 

3from flask import abort 

4from portality.decorators import api_key_required 

5 

6from portality import models 

7from portality import constants 

8from portality.crosswalks.jct_inprogress import JCTInProgressXWalk 

9from portality.util import make_json_resp 

10 

11blueprint = Blueprint('jct', __name__) 

12 

13INCLUDE_STATUSES = [ 

14 constants.APPLICATION_STATUS_COMPLETED, 

15 constants.APPLICATION_STATUS_IN_PROGRESS, 

16 constants.APPLICATION_STATUS_READY, 

17 constants.APPLICATION_STATUS_REVISIONS_REQUIRED, 

18 constants.APPLICATION_STATUS_UPDATE_REQUEST 

19] 

20 

21@blueprint.route('/inprogress') 

22@api_key_required 

23def inprogress(): 

24 if not current_user.has_role("jct_inprogress"): 

25 abort(404) 

26 

27 records = [] 

28 for application in models.Application.list_by_status(INCLUDE_STATUSES): 

29 record = JCTInProgressXWalk.application2jct(application) 

30 records.append(record) 

31 

32 return make_json_resp(records, 200)