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

Filter out faculty members from the people picker in the student research application form #161

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions app/Http/Controllers/ProfilesApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public function index(ProfilesApiRequest $request): JsonResponse
}
}

if ($request->boolean('not_accepting_undergrad')) {
$profile = $profile->notAcceptingUndergradStudents();
}

if ($request->boolean('with_data')) {
if(count(array_filter($request->query())) <=1){
return response()->json(['error' => 'Please use a filter when pulling data.'], 400);
Expand Down
13 changes: 13 additions & 0 deletions app/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,19 @@ public function scopeStudentsPendingReviewWithSemester($query, $semester)
$query_students->WithStatusPendingReview();
});
}
/**
* Query scope for Profiles that are not marked as "Not accepting undergrad students" or
* have not selected the option "Show not accepting students" on their pages
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotAcceptingUndergradStudents($query) {
return $query->whereHas('information', function($q) {
$q->whereJsonDoesntContain('data->show_not_accepting_students','1')
->orWhereJsonDoesntContain('data->not_accepting_students','1');
});
}

///////////////////////////////////
// Mutators & Virtual Attributes //
Expand Down
3 changes: 3 additions & 0 deletions public/js/app.js

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

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/js/app.js": "/js/app.js?id=24be537863fbbe2259218dfb56ecef72",
"/js/app.js": "/js/app.js?id=55b50a6d43f8ad90c1f1d53c057224e8",
"/js/manifest.js": "/js/manifest.js?id=dc9ead3d7857b522d7de22d75063453c",
"/css/app.css": "/css/app.css?id=bff46e69abe7a97b008296b99e4abadd",
"/js/vendor.js": "/js/vendor.js?id=4d3313683b3a2faf8ca0278ce47f3880"
Expand Down
4 changes: 4 additions & 0 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ var profiles = (function ($, undefined) {
api += '&from_school=' + $select.data('school');
}

if ($select.data('not_accepting_undergrad')) {
api += '&not_accepting_undergrad=' + $select.data('not_accepting_undergrad');
}

let profileSearch = new Bloodhound({
datumTokenizer: (profiles) => Bloodhound.tokenizers.whitespace(profiles.value),
queryTokenizer: Bloodhound.tokenizers.whitespace,
Expand Down
1 change: 1 addition & 0 deletions resources/views/students/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
'aria-labelledby' => 'profiles-picker-label',
'multiple',
'required',
'data-not_accepting_undergrad' => 'true',
] + ($schools->isNotEmpty() ? ['data-school' => $schools->keys()->implode(';')] : []))
!!}
@else
Expand Down
Loading