Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SYB to schedules #1065

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Gordon360/Authorization/StateYourBusiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
private IMembershipService _membershipService;
private IMembershipRequestService _membershipRequestService;
private INewsService _newsService;
private IAccountService _accountService;

//RecIM services
private IParticipantService _recimParticipantService;
Expand All @@ -64,13 +65,14 @@
_membershipService = context.HttpContext.RequestServices.GetRequiredService<IMembershipService>();
_membershipRequestService = context.HttpContext.RequestServices.GetRequiredService<IMembershipRequestService>();
_newsService = context.HttpContext.RequestServices.GetRequiredService<INewsService>();
_CCTContext = context.HttpContext.RequestServices.GetService<CCTContext>();

Check warning on line 68 in Gordon360/Authorization/StateYourBusiness.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.
_accountService = context.HttpContext.RequestServices.GetRequiredService<IAccountService>();

// set RecIM services
_recimParticipantService = context.HttpContext.RequestServices.GetRequiredService<IParticipantService>();
_recimTeamService = context.HttpContext.RequestServices.GetRequiredService<ITeamService>();
_recimActivityService = context.HttpContext.RequestServices.GetRequiredService<Services.RecIM.IActivityService>();

user_name = AuthUtils.GetUsername(authenticatedUser);
user_groups = AuthUtils.GetGroups(authenticatedUser);

Expand Down Expand Up @@ -106,7 +108,7 @@
/*
* Operations
*/
private async Task<bool> CanReadOneAsync(string resource)

Check warning on line 111 in Gordon360/Authorization/StateYourBusiness.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
// User is admin
if (user_groups.Contains(AuthGroup.SiteAdmin))
Expand Down Expand Up @@ -188,6 +190,10 @@
}
case Resource.NEWS:
return true;
case Resource.STUDENT_SCHEDULE:
if (context.ActionArguments["username"] is string viewed_username)
return user_groups.Contains(AuthGroup.Advisors) || viewed_username.EqualsIgnoreCase(user_name) || _accountService.GetAccountByUsername(viewed_username).AccountType.EqualsIgnoreCase("FACULTY");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not positive that ACCOUNT.AccountType == "FACULTY" will align perfectly with the profile.PersonType.includes('fac') check that we do on the front end to decide whether to show a person's schedule to another user. That's because Profile.PersonType is calculated based on whether a row was discovered in CCT.dbo.FacultyStaff for the given user.

This is a pretty grey concern though, and won't matter once the new code is in, so it should be fine to push through in this hotfix.

return false;
default: return false;

}
Expand Down
2 changes: 2 additions & 0 deletions Gordon360/Controllers/ScheduleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Gordon360.Enums;
using Gordon360.Models.ViewModels;
using Gordon360.Services;
using Gordon360.Static.Names;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -19,6 +20,7 @@
/// <returns>A IEnumerable of session objects as well as the schedules</returns>
[HttpGet]
[Route("{username}/allcourses")]
[StateYourBusiness(operation = Operation.READ_ONE, resource = Resource.STUDENT_SCHEDULE)]
public async Task<ActionResult<CoursesBySessionViewModel>> GetAllCourses(string username)
{
IEnumerable<CoursesBySessionViewModel> result = await scheduleService.GetAllCoursesAsync(username);
Expand All @@ -32,7 +34,7 @@
/// <returns>Whether they can read student schedules</returns>
[HttpGet]
[Route("canreadstudent")]
public async Task<ActionResult<bool>> GetCanReadStudentSchedules()

Check warning on line 37 in Gordon360/Controllers/ScheduleController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var groups = AuthUtils.GetGroups(User);
return groups.Contains(AuthGroup.Advisors);
Expand Down
1 change: 1 addition & 0 deletions Gordon360/Static Classes/Names.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static class Resource
public const string RECIM_PARTICIPANT_ADMIN = "The admin status of a RecIM participating user";
public const string RECIM_SUPER_ADMIN = "A RecIM director level resource";
public const string RECIM_SURFACE = "RecIM Surfaces/Playing fields/Locations";
public const string STUDENT_SCHEDULE = "A student's schedule events";

// Partial resources, to be targetted by Operation.READ_PARTIAL
public const string MEMBERSHIP_REQUEST_BY_ACTIVITY = "Membership Request Resources associated with an activity";
Expand Down
Loading