Skip to content

Commit

Permalink
Finished fixing allocations display in admin project view
Browse files Browse the repository at this point in the history
  • Loading branch information
happycodemonkey committed Jun 29, 2017
1 parent 04bf565 commit 32216ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
4 changes: 4 additions & 0 deletions allocations/templates/allocations/user-projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ <h3>Projects and Allocations for user: [[selections.username]] ([[projects.lengt
<label>
<input type="checkbox" ng-model="filter.active" ng-change="updateSelected()"> Active</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="filter.approved" ng-change="updateSelected()"> Approved</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="filter.inactive" ng-change="updateSelected()"> Inactive</label>
Expand Down
27 changes: 15 additions & 12 deletions allocations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,25 @@ def user_projects( request, username ):
try:
userProjects = tas.projects_for_user( username=username )
#logger.debug(userProjects)
#if (len(userProjects) > 0):
# logger.info('User Projects: %s', len(userProjects))

temp = {}
# run through and make sure all the allocations are associated with one project
for p in userProjects:
if p['source'] == 'Chameleon':
resp['status'] = 'success'
resp['result'].append(p)
if p['chargeCode'] not in temp:
logger.debug('Project ' + p['chargeCode'] + ' is not in the temp yet, adding')
temp[p['chargeCode']] = p
else:
logger.debug('Project ' + p['chargeCode'] + ' is in temp...appending allocations')
tempProj = temp[p['chargeCode']]
tempProj['allocations'].extend(p['allocations'])
temp[p['chargeCode']] = tempProj
for code, proj in temp.items():
resp['status'] = 'success'
resp['result'].append(proj)
logger.info('Total chameleon projects for user %s: %s', username, len(resp))
# @TODO verify that all projects will have a source of Chameleon
#if (chameleonProjects and userProjects):
# for project in userProjects:
# if project in chameleonProjects:
# resp['status'] = 'success'
# resp['result'].append(project)
# logger.info( 'Total chameleon projects for user %s: %s', username, len( resp ) )
except Exception as e:
logger.debug('Error loading projects for user: %s', username)
logger.debug('Error loading projects for user: %s with error %s', username, e)
resp['msg'] = 'Error loading projects for user: %s' %username
except Exception as e:
logger.debug('User not found with username: %s', username)
Expand Down

0 comments on commit 32216ee

Please sign in to comment.