Skip to content

Commit

Permalink
Merge pull request #461 from ucdavis/JCS/AddClusterAccount
Browse files Browse the repository at this point in the history
When adding an admin, add an cluster account if not there
  • Loading branch information
jSylvestre authored Aug 29, 2024
2 parents 6cf4882 + bf374c9 commit 687a9d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Hippo.Web/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public async Task<IActionResult> RemoveClusterAdmin(int id)
.Include(p => p.Role)
.Include(p => p.User)
.Where(p =>
p.Id == id
p.UserId == id
&& p.Cluster.Name == Cluster
&& p.Role.Name == Role.Codes.ClusterAdmin)
.SingleOrDefaultAsync();
Expand Down
14 changes: 7 additions & 7 deletions Hippo.Web/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public async Task<IActionResult> AdminOrders()
return BadRequest("You do not have permission to view this page.");
}
var currentUserAccount = await _dbContext.Accounts.SingleOrDefaultAsync(a => a.Cluster.Name == Cluster && a.OwnerId == currentUser.Id);
if (currentUserAccount == null)
{
return Ok(new OrderListModel[0]);
}
//if (currentUserAccount == null)
//{
// return Ok(new OrderListModel[0]);
//}

//Probably will want to filter out old ones that are completed and the expiration date has passed.
var adminStatuses = new List<string> { Order.Statuses.Submitted, Order.Statuses.Processing, Order.Statuses.Active, Order.Statuses.Closed, Order.Statuses.Completed };
Expand Down Expand Up @@ -289,7 +289,7 @@ public async Task<IActionResult> UpdateBilling([FromBody] OrderPostModel model)

//TODO: Validation
//Updating an existing order without changing the status.
var existingOrder = await _dbContext.Orders.Include(a => a.PrincipalInvestigator).Include(a => a.Cluster).Include(a => a.Billings).FirstAsync(a => a.Id == model.Id);
var existingOrder = await _dbContext.Orders.Include(a => a.PrincipalInvestigator.Owner).Include(a => a.Cluster).Include(a => a.Billings).FirstAsync(a => a.Id == model.Id);
if (existingOrder.PrincipalInvestigator.Owner.Id != currentUser.Id && !isClusterOrSystemAdmin) //Do we want admins to be able to make these chanegs?
{
return BadRequest("You do not have permission to update the billing information on this order.");
Expand Down Expand Up @@ -499,7 +499,7 @@ public async Task<IActionResult> CancelOrder(int id)
//var permissions = await _userService.GetCurrentPermissionsAsync();
//var isClusterOrSystemAdmin = permissions.IsClusterOrSystemAdmin(Cluster);

var existingOrder = await _dbContext.Orders.Include(a => a.PrincipalInvestigator).Include(a => a.Cluster).FirstAsync(a => a.Id == id);
var existingOrder = await _dbContext.Orders.Include(a => a.PrincipalInvestigator.Owner).Include(a => a.Cluster).FirstAsync(a => a.Id == id);
var isPi = existingOrder.PrincipalInvestigator.Owner.Id == currentUser.Id;

if (!isPi)
Expand Down Expand Up @@ -575,7 +575,7 @@ public async Task<IActionResult> MakePayment(int id, decimal amount)

amount = Math.Round(amount, 2);

var order = await _dbContext.Orders.Include(a => a.PrincipalInvestigator).Include(a => a.Payments).Include(a => a.Cluster).FirstAsync(a => a.Id == id && a.Cluster.Name == Cluster);
var order = await _dbContext.Orders.Include(a => a.PrincipalInvestigator.Owner).Include(a => a.Payments).Include(a => a.Cluster).FirstAsync(a => a.Id == id && a.Cluster.Name == Cluster);
if (order == null)
{
return NotFound();
Expand Down

0 comments on commit 687a9d3

Please sign in to comment.