Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit d26c953

Browse files
authored
Add status handling UI (#368)
* Add status handling * Add translations and tooltip
1 parent e23d29b commit d26c953

File tree

20 files changed

+182
-8
lines changed

20 files changed

+182
-8
lines changed

app/Http/Controllers/UserController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,26 @@ public function show($id)
108108

109109
return view('admin.user.show')->with('user', $user);
110110
}
111+
112+
public function semesters($id)
113+
{
114+
$user = User::findOrFail($id);
115+
116+
// TODO
117+
$this->authorize('view', $user);
118+
119+
return view('admin.user.semesters')->with('user', $user)->with('semesters', $user->allSemesters);
120+
}
121+
122+
public function updateSemesterStatus($id, $semester, $status)
123+
{
124+
$user = User::findOrFail($id);
125+
126+
// TODO
127+
$this->authorize('view', $user);
128+
129+
$user->setStatusFor(\App\Semester::find($semester), $status);
130+
131+
return redirect()->back()->with('message', __('general.successful_modification'));
132+
}
111133
}

app/Semester.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ class Semester extends Model
2828
const PARTS = [1, 2];
2929
const ACTIVE = 'ACTIVE';
3030
const INACTIVE = 'INACTIVE';
31+
const DEACTIVATED = 'DEACTIVATED';
3132
const PASSIVE = 'PASSIVE';
3233
const PENDING = 'PENDING';
3334
const STATUSES = [
3435
self::ACTIVE,
3536
self::INACTIVE,
37+
self::DEACTIVATED,
3638
self::PASSIVE,
3739
self::PENDING,
3840
];
@@ -161,6 +163,24 @@ public static function getOrCreate($year, $part)
161163
return $semester;
162164
}
163165

166+
public static function colorForStatus($status)
167+
{
168+
switch ($status) {
169+
case self::ACTIVE:
170+
return 'green';
171+
case self::INACTIVE:
172+
return 'grey';
173+
case self::DEACTIVATED:
174+
return 'brown';
175+
case self::PASSIVE:
176+
return 'orange';
177+
case self::PENDING:
178+
return 'lime';
179+
default:
180+
return 'black';
181+
}
182+
}
183+
164184
/* Helpers for testing */
165185

166186
public function equals($other)

app/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function getStatusIn($semester)
231231

232232
public function getStatus()
233233
{
234-
return getStatusIn(Semester::current());
234+
return $this->getStatusIn(Semester::current());
235235
}
236236

237237
public function setStatusFor($semester, $status, $comment = null)

database/factories/UserFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
$user->printAccount()->save(factory(\App\PrintAccount::class)->make(['user_id' => $user->id]));
3232
$user->personalInformation()->save(factory(\App\PersonalInformation::class)->make(['user_id' => $user->id]));
3333
$user->educationalInformation()->save(factory(\App\EducationalInformation::class)->make(['user_id' => $user->id]));
34+
$user->setStatus($faker->randomElement(\App\Semester::STATUSES));
3435
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddVerifiedStatusColumn extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('semester_status', function (Blueprint $table) {
17+
$table->boolean('verified')->default(false);
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
//
29+
}
30+
}

database/seeds/UsersTableSeeder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private function createAdmin()
6969
$user->roles()->attach(Role::getId($role));
7070
}
7171
$user->internetAccess->setWifiUsername();
72+
$user->setStatus(\App\Semester::ACTIVE);
7273
}
7374

7475
private function createCollegist()
@@ -92,6 +93,7 @@ private function createCollegist()
9293
for ($x = 0; $x < rand(1, 3); $x++) {
9394
$user->workshops()->attach(rand(1, count(App\Workshop::ALL)));
9495
}
96+
$user->setStatus(\App\Semester::ACTIVE);
9597
}
9698

9799
private function createTenant()

resources/lang/en/document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
return [
44
'clarify_print' => 'Print the wanted document using the printer in the Collegium, and give it to the secretary/doorman. Costs will be deducted.',
5-
'clarify_request' => 'You can request certificates from the secretariat by clicking on the "request" button. This way the secretariat will be notified. You will find the signed and seald certificate at the secretariat on the next workday. Only the signed and sealed certificates are valid!',
5+
'clarify_request' => 'You can request certificates from the secretariat by clicking on the \"request\" button. This way the secretariat will be notified. You will find the signed and seald certificate at the secretariat on the next workday. Only the signed and sealed certificates are valid!',
66
'computer' => 'personal computer',
77
'documents' => 'Documents',
88
'download' => 'Download',
@@ -14,12 +14,12 @@
1414
'item' => 'Item',
1515
'kitchen' => 'kitchen utensils (eg. dishes)',
1616
'left' => 'left',
17-
'register-statement' => 'Register Statement',
1817
'missing_educational_info' => 'Your educational information are missing. Please contact a system administrator.',
1918
'missing_items' => 'You have not added any items.',
2019
'missing_personal_info' => 'Your personal information are missing. Please contact a system administrator.',
2120
'not_report' => 'You don\'t have to report:',
2221
'print' => 'Print',
22+
'register-statement' => 'Register Statement',
2323
'report' => 'You have to report:',
2424
'request' => 'Request',
2525
'serial_number' => 'Serial number (for computers)',

resources/lang/en/info.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'phone_number' => 'Phone number',
1919
'place_and_date_of_birth' => 'Place and date of birth',
2020
'place_of_birth' => 'Place of birth',
21+
'semesters' => 'Semesters',
2122
'street_and_number' => 'Street and number',
2223
'user_data' => 'User data',
2324
'workshop' => 'Workshop',

resources/lang/en/user.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

33
return [
4+
'ACTIVE' => 'Active',
5+
'DEACTIVATED' => 'Deactivated',
6+
'INACTIVE' => 'Inactive',
7+
'PASSIVE' => 'Passive',
8+
'PENDING' => 'Pending',
49
'accept' => 'Accept',
510
'address' => 'Address',
611
'address_information' => 'Address information',

resources/lang/en/validation.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
'place_of_birth' => 'place of birth',
3030
'date_of_birth' => 'date of birth',
3131
'mothers_name' => 'mother\'s name',
32-
'phone_number' => 'phone number',
3332
'country' => 'country',
3433
'county' => 'county',
3534
'zip_code' => 'zip code',

0 commit comments

Comments
 (0)