From c570fc224cf51734c38f9957ec8d71bdbdcfa107 Mon Sep 17 00:00:00 2001 From: Betsy Castro <5490820+betsyecastro@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:14:36 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Adds=20not-accepting-undergr?= =?UTF-8?q?ad=20params=20to=20API=20index=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ProfilesApiController.php | 4 ++++ app/Http/Controllers/StudentsController.php | 2 ++ app/Profile.php | 13 +++++++++++++ public/js/app.js | 3 +++ public/mix-manifest.json | 2 +- resources/assets/js/app.js | 4 ++++ resources/views/students/edit.blade.php | 2 +- resources/views/students/form.blade.php | 1 + resources/views/students/show.blade.php | 2 +- 9 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ProfilesApiController.php b/app/Http/Controllers/ProfilesApiController.php index ccec910e..0e523fc7 100644 --- a/app/Http/Controllers/ProfilesApiController.php +++ b/app/Http/Controllers/ProfilesApiController.php @@ -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); diff --git a/app/Http/Controllers/StudentsController.php b/app/Http/Controllers/StudentsController.php index cc33bd36..49989ab8 100644 --- a/app/Http/Controllers/StudentsController.php +++ b/app/Http/Controllers/StudentsController.php @@ -107,6 +107,7 @@ public function show(Request $request, Student $student): View|ViewContract 'custom_questions' => StudentData::customQuestions(), 'languages' => StudentData::$languages, 'majors' => StudentData::majors(), + 'not_accepting_undergrad' => true, ]); } @@ -121,6 +122,7 @@ public function edit(Student $student): View|ViewContract 'custom_questions' => StudentData::customQuestions(), 'languages' => StudentData::$languages, 'majors' => StudentData::majors(), + 'not_accepting_undergrad' => true, ]); } diff --git a/app/Profile.php b/app/Profile.php index 04f34c7b..57fec9d4 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -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 // diff --git a/public/js/app.js b/public/js/app.js index 8b9b4d0a..e7be5087 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -395,6 +395,9 @@ var profiles = function ($, undefined) { if ($select.data('school')) { api += '&from_school=' + $select.data('school'); } + if ($select.data('not_accepting_undergrad')) { + api += '¬_accepting_undergrad=' + $select.data('not_accepting_undergrad'); + } var profileSearch = new Bloodhound({ datumTokenizer: function datumTokenizer(profiles) { return Bloodhound.tokenizers.whitespace(profiles.value); diff --git a/public/mix-manifest.json b/public/mix-manifest.json index de5f1463..10cc8f72 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -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" diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index c187b44f..5e046ea2 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -352,6 +352,10 @@ var profiles = (function ($, undefined) { api += '&from_school=' + $select.data('school'); } + if ($select.data('not_accepting_undergrad')) { + api += '¬_accepting_undergrad=' + $select.data('not_accepting_undergrad'); + } + let profileSearch = new Bloodhound({ datumTokenizer: (profiles) => Bloodhound.tokenizers.whitespace(profiles.value), queryTokenizer: Bloodhound.tokenizers.whitespace, diff --git a/resources/views/students/edit.blade.php b/resources/views/students/edit.blade.php index 45772032..58c5a0aa 100644 --- a/resources/views/students/edit.blade.php +++ b/resources/views/students/edit.blade.php @@ -34,7 +34,7 @@ {!! Form::model($student, ['route' => ['students.update', $student]]) !!} - @include('students.form', ['editable' => true]) + @include('students.form', ['editable' => true, 'not_accepting_undergrad' => $not_accepting_undergrad]) {!! Form::close() !!} diff --git a/resources/views/students/form.blade.php b/resources/views/students/form.blade.php index 36f1a927..4d8a972a 100644 --- a/resources/views/students/form.blade.php +++ b/resources/views/students/form.blade.php @@ -77,6 +77,7 @@ 'aria-labelledby' => 'profiles-picker-label', 'multiple', 'required', + 'data-not_accepting_undergrad' => $not_accepting_undergrad ? 'true' : 'false', ] + ($schools->isNotEmpty() ? ['data-school' => $schools->keys()->implode(';')] : [])) !!} @else diff --git a/resources/views/students/show.blade.php b/resources/views/students/show.blade.php index 18894b0a..8c9f1e4c 100644 --- a/resources/views/students/show.blade.php +++ b/resources/views/students/show.blade.php @@ -108,7 +108,7 @@