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

S23 user privacy setting #937

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b407dad
Update EF Core models
ArabellaJi Jun 27, 2023
daaa94f
continue EF Core update
ArabellaJi Jun 27, 2023
8d0f4ec
add mobilePhone, isMobilePhonePrivate, and isHomePhonePrivate
ArabellaJi Jun 27, 2023
3adcc9a
add UpdateHomePrivacyAsync - not working yet
ArabellaJi Jun 27, 2023
4eb6757
fix the error
ArabellaJi Jun 28, 2023
d870395
remove isMobilePhonePrivate and isHomePhonePrivate for fac/staff
ArabellaJi Jun 28, 2023
ab48999
remove UpdateHomePrivacyAsync from ProfileController and ProfileServi…
ArabellaJi Jun 28, 2023
ca323c1
modifying UpdateFacStaffPrivacyAsync - not working
ArabellaJi Jun 28, 2023
9b6189d
finishing update route
ArabellaJi Jun 29, 2023
3a768b3
decided using one row for each User and Field
ArabellaJi Jun 30, 2023
e3c398e
Update table connections
amos-cha Jun 30, 2023
7f5f0c2
Fix syntax errors
amos-cha Jun 30, 2023
4fbbafb
Merge branch 's23-fac-privacy-option' of https://github.com/gordon-cs…
amos-cha Jun 30, 2023
ee37a34
finishing get profile functions
ArabellaJi Jun 30, 2023
3ab1e77
using a better way to wipe out the private imformation
ArabellaJi Jul 3, 2023
ee5e0cb
Update variable naming
amos-cha Jul 5, 2023
3dcbf87
Update to use route instead of direct cast
amos-cha Jul 5, 2023
48c14ab
Deprecate use of privacy bit for FacStaff
amos-cha Jul 5, 2023
2cd45e3
Fix async race condition
amos-cha Jul 5, 2023
0c06b6c
Merge branch 'develop' into s23-fac-privacy-option
amos-cha Jul 5, 2023
389f69d
Manage minor cleanup
amos-cha Jul 5, 2023
36d0bad
Add SyB to `put` route
amos-cha Jul 5, 2023
1af67aa
add primary key
ArabellaJi Jul 7, 2023
f20b553
update comments for UserPrivacyViewModel.cs
ArabellaJi Jul 7, 2023
b029f18
adding get privacy setting
ArabellaJi Jul 10, 2023
9339e46
working on get privacy setting
ArabellaJi Jul 11, 2023
8e5b4c8
distinguish Country and HomeCountry
ArabellaJi Jul 11, 2023
6693a05
add comments and test for ToPublicProfileViewModel
ArabellaJi Jul 12, 2023
517d5a6
change async functions to not async functions
ArabellaJi Jul 13, 2023
0ad3c9c
completed privacy setting for Home field
ArabellaJi Jul 14, 2023
e666a49
cleaning up
ArabellaJi Jul 14, 2023
a48035b
simplify querying
ArabellaJi Jul 17, 2023
5f5c062
continue to simplify querying (GetPrivacySettingAsync)
ArabellaJi Jul 17, 2023
4ad5dce
change the fields from strings to lists of strings
ArabellaJi Jul 20, 2023
d44a44e
using implicitly cast
ArabellaJi Jul 20, 2023
ca65e18
remove unused comments
ArabellaJi Jul 20, 2023
ede4917
continue to clean up code
ArabellaJi Jul 21, 2023
bb21116
resolve merge conflicts
ArabellaJi Jul 21, 2023
5f9c2ca
changing comments
ArabellaJi Jul 21, 2023
416c1e1
add HomePhone for student in public profile
ArabellaJi Jul 21, 2023
32128b8
remove unnecessary lines
ArabellaJi Jul 21, 2023
7fd260c
Merge branch 'develop' into s23-fac-privacy-option
ArabellaJi Jul 21, 2023
6e8e19c
Merge branch 'develop' into s23-fac-privacy-option
ArabellaJi Jul 22, 2023
2a99d70
Merge branch 'develop' into s23-fac-privacy-option
ArabellaJi Jul 24, 2023
1342930
fix minor spelling issue
ArabellaJi Aug 11, 2023
414263c
change the order of parameters and add a comment
ArabellaJi Aug 11, 2023
1210ca0
initial add roommate completed
ArabellaJi Oct 5, 2023
8d8ab77
Revert "initial add roommate completed"
ArabellaJi Oct 5, 2023
5979e60
Revert "Revert "initial add roommate completed""
ArabellaJi Oct 5, 2023
0de79fe
Merge branch 's23-fac-privacy-option' of https://github.com/gordon-cs…
ArabellaJi May 21, 2024
6d0f528
fixed a few issue
ArabellaJi May 21, 2024
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
6 changes: 5 additions & 1 deletion Gordon360/Authorization/StateYourBusiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,11 @@ private async Task<bool> CanUpdateAsync(string resource)

return false;
}

case Resource.PROFILE_PRIVACY:
{
// current implementation only allows for facstaff implementation.
return user_groups.Contains(AuthGroup.FacStaff);
}
case Resource.ACTIVITY_INFO:
{
// User is admin
Expand Down
73 changes: 62 additions & 11 deletions Gordon360/Controllers/ProfilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Gordon360.Models.CCT.Context;

namespace Gordon360.Controllers
{
Expand All @@ -29,13 +30,16 @@ public class ProfilesController : GordonControllerBase
private readonly IMembershipService _membershipService;
private readonly IConfiguration _config;
private readonly webSQLContext _webSQLContext;
private readonly CCTContext _context;

public ProfilesController(IProfileService profileService, IAccountService accountService, IMembershipService membershipService, IConfiguration config, webSQLContext webSQLContext)
public ProfilesController(IProfileService profileService, IAccountService accountService,
ArabellaJi marked this conversation as resolved.
Show resolved Hide resolved
IMembershipService membershipService, IConfiguration config, CCTContext context, webSQLContext webSQLContext)
ArabellaJi marked this conversation as resolved.
Show resolved Hide resolved
{
_profileService = profileService;
_accountService = accountService;
_membershipService = membershipService;
_config = config;
_context = context;
_webSQLContext = webSQLContext;
}

Expand Down Expand Up @@ -67,7 +71,7 @@ public ProfilesController(IProfileService profileService, IAccountService accoun
/// <returns></returns>
[HttpGet]
[Route("{username}")]
public ActionResult<ProfileViewModel?> GetUserProfile(string username)
public ActionResult<ProfileViewModel?> GetUserProfileAsync(string username)
{
var viewerGroups = AuthUtils.GetGroups(User);

Expand All @@ -79,7 +83,7 @@ public ProfilesController(IProfileService profileService, IAccountService accoun
object? student = null;
object? faculty = null;
object? alumni = null;

if (viewerGroups.Contains(AuthGroup.SiteAdmin) || viewerGroups.Contains(AuthGroup.Police))
{
student = _student;
Expand All @@ -89,23 +93,26 @@ public ProfilesController(IProfileService profileService, IAccountService accoun
else if (viewerGroups.Contains(AuthGroup.FacStaff))
{
student = _student;
faculty = _faculty == null ? null : (PublicFacultyStaffProfileViewModel)_faculty;
faculty = _faculty == null ? null :
_profileService.ToPublicFacultyStaffProfileViewModel(username, "fac", _faculty);
alumni = _alumni == null ? null : (PublicAlumniProfileViewModel)_alumni;
}
else if (viewerGroups.Contains(AuthGroup.Student))
{
student = _student == null ? null : (PublicStudentProfileViewModel)_student;
faculty = _faculty == null ? null : (PublicFacultyStaffProfileViewModel)_faculty;
// If this student is also in Alumni AuthGroup, then s/he can see alumni's
// public profile; if not, return null.
student = _student == null ? null :
_profileService.ToPublicStudentProfileViewModel(username, "stu", _student);
faculty = _faculty == null ? null :
_profileService.ToPublicFacultyStaffProfileViewModel(username, "stu", _faculty);
// If this student is also in Alumni AuthGroup, then s/he can see alumni's public profile; if not, return null.
alumni = (_alumni == null) ? null :
viewerGroups.Contains(AuthGroup.Alumni) ?
(PublicAlumniProfileViewModel)_alumni : null;
viewerGroups.Contains(AuthGroup.Alumni) ?
(PublicAlumniProfileViewModel)_alumni : null;
}
else if (viewerGroups.Contains(AuthGroup.Alumni))
{
student = null;
faculty = _faculty == null ? null : (PublicFacultyStaffProfileViewModel)_faculty;
faculty = _faculty == null ? null :
_profileService.ToPublicFacultyStaffProfileViewModel(username, "alu", _faculty);
alumni = _alumni == null ? null : (PublicAlumniProfileViewModel)_alumni;
}

Expand Down Expand Up @@ -134,6 +141,20 @@ public async Task<ActionResult<IEnumerable<AdvisorViewModel>>> GetAdvisorsAsync(
return Ok(advisors);
}

///<summary>Get the privacy settings of a particular user</summary>
/// <returns>
/// All privacy settings of the given user.
/// </returns>
[HttpGet]
[Route("privacy_setting/{username}")]
[StateYourBusiness(operation = Operation.READ_ONE, resource = Resource.PROFILE)]
public ActionResult<IEnumerable<UserPrivacyGetViewModel>> GetPrivacySettingAsync(string username)
{
var privacy = _profileService.GetPrivacySettingAsync(username);

return Ok(privacy);
}

/// <summary> Gets the clifton strengths of a particular user </summary>
/// <param name="username"> The username for which to retrieve info </param>
/// <returns> Clifton strengths of the given user. </returns>
Expand Down Expand Up @@ -479,6 +500,36 @@ public async Task<ActionResult<FacultyStaffProfileViewModel>> UpdateOfficeHours(
return Ok(result);
}

/// <summary>
/// Set visibility of some piece of personal data for user.
/// </summary>
/// <param name="userPrivacy">Faculty Staff Privacy Decisions (see UserPrivacyUpdateViewModel)</param>
/// <returns></returns>
[HttpPut]
[Route("user_privacy")]
// [StateYourBusiness(operation = Operation.UPDATE, resource = Resource.PROFILE_PRIVACY)]
public async Task<ActionResult<UserPrivacyUpdateViewModel>> UpdateUserPrivacyAsync(UserPrivacyUpdateViewModel userPrivacy)
{
var authenticatedUserUsername = AuthUtils.GetUsername(User);
await _profileService.UpdateUserPrivacyAsync(authenticatedUserUsername, userPrivacy);
return Ok();
}

/// <summary>
/// Return a list visibility groups.
/// </summary>
/// <returns> All visibility groups (Public, FacStaff, Private)</returns>
[HttpGet]
[Route("visibility_group")]
public ActionResult<IEnumerable<string>> GetVisibilityGroup()
{
var groups = _context.UserPrivacy_Visibility_Groups.Select(up_v_g => up_v_g.Group)
.Distinct()
.Where(g => g != null)
.OrderBy(g => g);
amos-cha marked this conversation as resolved.
Show resolved Hide resolved
return Ok(groups);
}

/// <summary>
/// Update mail location
/// </summary>
Expand Down
66 changes: 65 additions & 1 deletion Gordon360/Documentation/Gordon360.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Gordon360/Models/CCT/Context/CCTContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
public virtual DbSet<Team> Team { get; set; }
public virtual DbSet<TeamStatus> TeamStatus { get; set; }
public virtual DbSet<Timesheets_Clock_In_Out> Timesheets_Clock_In_Out { get; set; }
public virtual DbSet<UserPrivacy_Fields> UserPrivacy_Fields { get; set; }
public virtual DbSet<UserPrivacy_Settings> UserPrivacy_Settings { get; set; }
public virtual DbSet<UserPrivacy_Visibility_Groups> UserPrivacy_Visibility_Groups { get; set; }
public virtual DbSet<UserCourses> UserCourses { get; set; }
public virtual DbSet<User_Connection_Ids> User_Connection_Ids { get; set; }
public virtual DbSet<User_Rooms> User_Rooms { get; set; }
Expand Down Expand Up @@ -729,6 +732,31 @@
.HasConstraintName("FK_Team_TeamStatus");
});

modelBuilder.Entity<UserPrivacy_Fields>(entity =>
{
entity.Property(e => e.ID).ValueGeneratedOnAdd();
});

modelBuilder.Entity<UserPrivacy_Settings>(entity =>
{
entity.HasKey(e => new { e.gordon_id, e.Field });

entity.HasOne(d => d.FieldNavigation)
.WithMany(p => p.UserPrivacy_Settings)
.HasForeignKey(d => d.Field)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_UserPrivacy_Settings_UserPrivacy_Fields");

entity.HasOne(d => d.VisibilityNavigation)
.WithMany(p => p.UserPrivacy_Settings)
.HasForeignKey(d => d.Visibility)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_UserPrivacy_Settings_UserPrivacy_Visibility_Groups");
});

modelBuilder.Entity<UserPrivacy_Visibility_Groups>(entity =>
{
entity.Property(e => e.ID).ValueGeneratedOnAdd();
modelBuilder.Entity<UserCourses>(entity =>
{
entity.ToView("UserCourses", "dbo");
Expand Down Expand Up @@ -768,7 +796,7 @@

OnModelCreatingGeneratedProcedures(modelBuilder);
OnModelCreatingPartial(modelBuilder);
}

Check failure on line 799 in Gordon360/Models/CCT/Context/CCTContext.cs

View workflow job for this annotation

GitHub Actions / build

) expected

Check failure on line 799 in Gordon360/Models/CCT/Context/CCTContext.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 799 in Gordon360/Models/CCT/Context/CCTContext.cs

View workflow job for this annotation

GitHub Actions / build

} expected

Check failure on line 799 in Gordon360/Models/CCT/Context/CCTContext.cs

View workflow job for this annotation

GitHub Actions / build

) expected

Check failure on line 799 in Gordon360/Models/CCT/Context/CCTContext.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 799 in Gordon360/Models/CCT/Context/CCTContext.cs

View workflow job for this annotation

GitHub Actions / build

} expected

partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
Expand Down
14 changes: 13 additions & 1 deletion Gordon360/Models/CCT/Context/efpt.CCT.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@
"Name": "[dbo].[User_Rooms]",
"ObjectType": 0
},
{
"Name": "[dbo].[UserPrivacy_Fields]",
"ObjectType": 0
},
{
"Name": "[dbo].[UserPrivacy_Settings]",
"ObjectType": 0
},
{
"Name": "[dbo].[UserPrivacy_Visibility_Groups]",
"ObjectType": 0
},
{
"Name": "[dbo].[Users]",
"ObjectType": 0
Expand Down Expand Up @@ -799,7 +811,7 @@
"ObjectType": 1
}
],
"UiHint": "SQLTrain1.CCT",
"UiHint": "sqltrain1.CCT.dbo",
"UseBoolPropertiesWithoutDefaultSql": false,
"UseDatabaseNames": true,
"UseDbContextSplitting": false,
Expand Down
3 changes: 3 additions & 0 deletions Gordon360/Models/CCT/dbo/FacStaff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public partial class FacStaff
public string HomePhone { get; set; }
[StringLength(15)]
[Unicode(false)]
public string MobilePhone { get; set; }
[StringLength(1)]
[Unicode(false)]
public string HomeFax { get; set; }
[Required]
[StringLength(1)]
Expand Down
28 changes: 28 additions & 0 deletions Gordon360/Models/CCT/dbo/UserPrivacy_Fields.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace Gordon360.Models.CCT
{
[Table("UserPrivacy_Fields", Schema = "dbo")]
public partial class UserPrivacy_Fields
{
public UserPrivacy_Fields()
{
UserPrivacy_Settings = new HashSet<UserPrivacy_Settings>();
}

public int ID { get; set; }
[Key]
[StringLength(50)]
[Unicode(false)]
public string Field { get; set; }

[InverseProperty("FieldNavigation")]
public virtual ICollection<UserPrivacy_Settings> UserPrivacy_Settings { get; set; }
}
}
Loading
Loading