Skip to content

Commit a569a68

Browse files
betsyecastrowunc
andauthored
πŸ”’οΈ Adds CSRF token implementation for student app status update (#163)
* πŸ”’ Adds CSRF token implementation for student app status updates * βœ… Update request method in StudentTest for student app status update * Adds 419 - Page expired error view --------- Co-authored-by: Wun Chiou <wun@utdallas.edu>
1 parent dae998e commit a569a68

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@extends('layout')
2+
@section('title', 'Page Expired')
3+
@section('header')
4+
@include('nav')
5+
@stop
6+
@section('content')
7+
8+
<div class="jumbotron">
9+
<div class="text-center">
10+
<h2>419: Page Expired 😭</h2>
11+
</div>
12+
</div>
13+
14+
@include('errors/list')
15+
16+
@stop

β€Žresources/views/students/show.blade.phpβ€Ž

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,24 @@
3636
</a>
3737
</small>
3838
</h2>
39-
<div class="mb-3 mb-md-0">
39+
<div class="mb-3 mb-md-0 row">
4040
@can('update', $student)
41-
<a class="btn btn-primary btn-sm" href="{{ route('students.edit', [$student]) }}"><i class="fas fa-edit"></i> Edit</a>
42-
@if($student->status === 'drafted')
43-
<a class="btn btn-secondary btn-sm" href="{{ route('students.status', ['student' => $student, 'status' => 'submitted']) }}" data-toggle="tooltip" data-placement="auto" title="Submit this student application for consideration"><i class="fas fa-check"></i> Submit</a>
44-
@else
45-
<a class="btn btn-secondary btn-sm" href="{{ route('students.status', ['student' => $student, 'status' => 'drafted']) }}" data-toggle="tooltip" data-placement="auto" title="Un-submit if you've already joined a research group or want to remove your application from future consideration"><i class="fas fa-undo"></i> Un-submit</a>
46-
@endif
41+
<div class="ml-3 mr-2"><a class="btn btn-primary btn-sm" href="{{ route('students.edit', [$student]) }}"><i class="fas fa-edit"></i> Edit</a></div>
42+
<div class="mr-2">
43+
{!! Form::open(['url' => route('students.status', $student), 'method' => 'PATCH']) !!}
44+
@if($student->status === 'drafted')
45+
<button class="btn btn-secondary btn-sm" type="submit" name="status" value="submitted" data-toggle="tooltip" data-placement="auto" title="Submit this student application for consideration"><i class="fas fa-check"></i> Submit</button>
46+
@else
47+
<button class="btn btn-secondary btn-sm" type="submit" name="status" value="drafted" data-toggle="tooltip" data-placement="auto" title="Un-submit if you've already joined a research group or want to remove your application from future consideration"><i class="fas fa-undo"></i> Un-submit</button>
48+
@endif
49+
{!! Form::close() !!}
50+
</div>
4751
@endcan
4852
@if(!auth()->user()->owns($student))
4953
<livewire:bookmark-button :model="$student">
5054
@endif
5155
@can('viewFeedback', $student)
52-
<a class="btn btn-primary btn-sm" href="#student_feedback"><i class="fas fa-comment"></i> Feedback</a>
56+
<div class="mr-2"><a class="btn btn-primary btn-sm" href="#student_feedback"><i class="fas fa-comment"></i> Feedback</a></div>
5357
@endcan
5458
</div>
5559
</div>

β€Žroutes/components/students.phpβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Route::name('show')->get('/', [StudentsController::class, 'show']);
1818
Route::name('edit')->get('/edit', [StudentsController::class, 'edit']);
1919
Route::name('update')->post('/update', [StudentsController::class, 'update']);
20-
Route::name('status')->get('/status', [StudentsController::class, 'setStatus']);
20+
Route::name('status')->patch('/status', [StudentsController::class, 'setStatus']);
2121
});
2222

2323
});

β€Žtests/Feature/StudentTest.phpβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testStudentUnsubmit(): void
105105
->assertViewIs('students.show')
106106
->assertSee('Un-submit');
107107

108-
$this->followingRedirects()->get($unsubmit_route)
108+
$this->followingRedirects()->patch($unsubmit_route)
109109
->assertStatus(200)
110110
->assertSee('Student profile status updated');
111111

0 commit comments

Comments
Β (0)