Skip to content

Commit

Permalink
🐛 Adds not-accepting-undergrad params to API index endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
betsyecastro committed Aug 19, 2024
1 parent f808d39 commit c570fc2
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 3 deletions.
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
2 changes: 2 additions & 0 deletions app/Http/Controllers/StudentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}

Expand All @@ -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,
]);
}

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
2 changes: 1 addition & 1 deletion resources/views/students/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>

{!! 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() !!}

</div>
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' => $not_accepting_undergrad ? 'true' : 'false',
] + ($schools->isNotEmpty() ? ['data-school' => $schools->keys()->implode(';')] : []))
!!}
@else
Expand Down
2 changes: 1 addition & 1 deletion resources/views/students/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<hr>

<fieldset disabled>
@include('students.form', ['editable' => false])
@include('students.form', ['editable' => false, 'not_accepting_undergrad' => $not_accepting_undergrad])
</fieldset>

@can('viewFeedback', $student)
Expand Down

0 comments on commit c570fc2

Please sign in to comment.