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

Commit 68b9af2

Browse files
committed
Release Uran-2.1
Merge branch 'uran-2.x'
2 parents 01de9ba + e9e1f1b commit 68b9af2

File tree

103 files changed

+1786
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1786
-583
lines changed

app/EducationalInformation.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class EducationalInformation extends Model
8+
{
9+
public $timestamps = false;
10+
11+
protected $fillable = [
12+
'user_id',
13+
'year_of_graduation',
14+
'high_school',
15+
'neptun',
16+
'year_of_acceptance',
17+
];
18+
19+
public function user()
20+
{
21+
return $this->belongsTo('App\User');
22+
}
23+
}

app/Faculty.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
class Faculty extends Model
88
{
9-
const AJK = "Állam- és Jogtudományi Kar";
10-
const BGGYK = "Bárczi Gusztáv Gyógypedagógiai Kar";
11-
const BTK = "Bölcsészettudományi Kar";
12-
const IK = "Informatikai Kar";
13-
const PPK = "Pedagógiai és Pszichológiai Kar";
14-
const TOK = "Tanító- és Óvóképző Kar";
15-
const TATK = "Társadalomtudományi Kar";
16-
const TTK = "Természettudományi Kar";
9+
const AJK = 'Állam- és Jogtudományi Kar';
10+
const BGGYK = 'Bárczi Gusztáv Gyógypedagógiai Kar';
11+
const BTK = 'Bölcsészettudományi Kar';
12+
const IK = 'Informatikai Kar';
13+
const PPK = 'Pedagógiai és Pszichológiai Kar';
14+
const TOK = 'Tanító- és Óvóképző Kar';
15+
const TATK = 'Társadalomtudományi Kar';
16+
const TTK = 'Természettudományi Kar';
1717

1818
const ALL = [
1919
self::AJK,
@@ -26,7 +26,8 @@ class Faculty extends Model
2626
self::TTK,
2727
];
2828

29-
public function users() {
29+
public function users()
30+
{
3031
return $this->belongsToMany(User::class, 'faculty_users');
3132
}
3233
}

app/FaultsTable.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
class FaultsTable extends Model
88
{
9-
const UNSEEN = "UNSEEN";
10-
const SEEN = "SEEN";
11-
const DONE = "DONE";
12-
const WONT_FIX = "WONT_FIX";
9+
const UNSEEN = 'UNSEEN';
10+
const SEEN = 'SEEN';
11+
const DONE = 'DONE';
12+
const WONT_FIX = 'WONT_FIX';
1313
const STATES = [self::UNSEEN, self::SEEN, self::DONE, self::WONT_FIX];
1414

15-
static function getState($value) {
15+
public static function getState($value)
16+
{
1617
return strtoupper($value);
1718
}
1819
}

app/FreePages.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class FreePages extends Model
8+
{
9+
protected $table = 'printing_free_pages';
10+
protected $primaryKey = 'id';
11+
public $incrementing = false;
12+
public $timestamps = true;
13+
14+
protected $fillable = [
15+
'user_id',
16+
'amount',
17+
'deadline',
18+
'last_modified_by',
19+
'comment',
20+
];
21+
22+
public function user()
23+
{
24+
return $this->belongsTo('App\User');
25+
}
26+
27+
public function printAccount()
28+
{
29+
return $this->belongsTo('App\PrintAccount', 'user_id', 'user_id');
30+
}
31+
}

app/Http/Controllers/Admin/RegistrationsController.php

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

33
namespace App\Http\Controllers\Admin;
44

5-
use Illuminate\Http\Request;
65
use App\Http\Controllers\Controller;
76
use App\User;
7+
use Illuminate\Http\Request;
88

9-
class RegistrationsController extends Controller {
10-
public function __construct() {
9+
class RegistrationsController extends Controller
10+
{
11+
public function __construct()
12+
{
1113
$this->middleware('can:registration.handle');
1214
}
1315

14-
public function index() {
16+
public function index()
17+
{
1518
$users = User::where('verified', false)->get();
19+
1620
return view('admin.registrations', ['users' => $users]);
1721
}
18-
public function accept(Request $request) {
22+
23+
public function accept(Request $request)
24+
{
1925
User::findOrFail($request->user_id)->update(['verified' => true]);
26+
2027
return redirect()->route('admin.registrations');
2128
}
22-
public function reject(Request $request) {
29+
30+
public function reject(Request $request)
31+
{
2332
User::findOrFail($request->user_id)->delete();
33+
2434
return redirect()->route('admin.registrations');
2535
}
26-
public function show(Request $request) {
36+
37+
public function show(Request $request)
38+
{
2739
//TODO
2840
return redirect()->route('admin.registrations');
2941
}

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
namespace App\Http\Controllers\Auth;
44

5+
use App\EducationalInformation;
6+
use App\Faculty;
57
use App\Http\Controllers\Controller;
6-
use App\User;
7-
use App\PrintAccount;
8+
use App\PersonalInformation;
89
use App\Role;
9-
use App\Faculty;
10+
use App\User;
1011
use App\Workshop;
11-
use App\PersonalInformation;
1212
use Illuminate\Foundation\Auth\RegistersUsers;
1313
use Illuminate\Support\Facades\Hash;
1414
use Illuminate\Support\Facades\Validator;
15-
use Illuminate\Validation\Rule;
1615

1716
class RegisterController extends Controller
1817
{
@@ -45,7 +44,7 @@ public function __construct()
4544
{
4645
$this->middleware('guest');
4746
}
48-
47+
4948
public function showRegistrationForm()
5049
{
5150
return view('auth.register', ['user_type' => Role::COLLEGIST, 'faculties' => Faculty::all(), 'workshops' => Workshop::all()]);
@@ -77,15 +76,15 @@ protected function validator(array $data)
7776
'zip_code' => ['required', 'string', 'max:31'],
7877
'city' => ['required', 'string', 'max:255'],
7978
'street_and_number' => ['required', 'string', 'max:255'],
80-
'user_type' => ['required', 'exists:roles,name']
79+
'user_type' => ['required', 'exists:roles,name'],
8180
];
8281
$informationOfStudies = [
83-
'year_of_graduation' => ['required', 'integer', 'between:1895,'. date("Y")],
82+
'year_of_graduation' => ['required', 'integer', 'between:1895,'.date('Y')],
8483
'high_school' => ['required', 'string', 'max:255'],
8584
'neptun' => ['required', 'string', 'size:6'],
86-
'year_of_acceptance' => ['required', 'integer', 'between:1895,'. date("Y")],
87-
'faculty' => ['required', 'array', 'exists:faculties,id',],
88-
'workshop' => ['required', 'array', 'exists:workshops,id',],
85+
'year_of_acceptance' => ['required', 'integer', 'between:1895,'.date('Y')],
86+
'faculty' => ['required', 'array', 'exists:faculties,id'],
87+
'workshop' => ['required', 'array', 'exists:workshops,id'],
8988
];
9089
switch ($data['user_type']) {
9190
case Role::TENANT:
@@ -121,10 +120,6 @@ protected function create(array $data)
121120
'zip_code' => $data['zip_code'],
122121
'city' => $data['city'],
123122
'street_and_number' => $data['street_and_number'],
124-
'year_of_graduation' => $data['year_of_graduation'] ?? null,
125-
'high_school' => $data['high_school'] ?? null,
126-
'neptun' => $data['neptun'] ?? null,
127-
'year_of_acceptance' => $data['year_of_acceptance'] ?? null
128123
]);
129124

130125
//TODO change collegist and tenant role into role group
@@ -138,6 +133,13 @@ protected function create(array $data)
138133
$user->roles()->attach(Role::getId(Role::COLLEGIST));
139134
$user->roles()->attach(Role::getId(Role::PRINTER));
140135
$user->roles()->attach(Role::getId(Role::INTERNET_USER));
136+
EducationalInformation::create([
137+
'user_id' => $user->id,
138+
'year_of_graduation' => $data['year_of_graduation'],
139+
'high_school' => $data['high_school'],
140+
'neptun' => $data['neptun'],
141+
'year_of_acceptance' => $data['year_of_acceptance'],
142+
]);
141143
foreach ($data['faculty'] as $key => $faculty) {
142144
$user->faculties()->attach($faculty);
143145
}
@@ -149,6 +151,7 @@ protected function create(array $data)
149151
throw new AuthorizationException();
150152
}
151153
$user->internetAccess->setWifiUsername();
154+
152155
return $user;
153156
}
154157
}

app/Http/Controllers/FaultsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function addFault(Request $new)
2424
'description' => $new['description'],
2525
'status' => FaultsTable::UNSEEN,
2626
'created_at' => date('Y-m-d H:i:s'),
27-
'updated_at' => date('Y-m-d H:i:s')
27+
'updated_at' => date('Y-m-d H:i:s'),
2828
]
2929
);
3030

@@ -38,12 +38,12 @@ public function getFaultsTable(Request $request)
3838

3939
public function updateStatus(Request $new)
4040
{
41-
$auth = Auth::User()->hasRole(Role::INTERNET_ADMIN) || FaultsTable::getState($new['status']) === FaultsTable::UNSEEN;
41+
$auth = Auth::User()->hasRole(Role::STAFF) || FaultsTable::getState($new['status']) === FaultsTable::UNSEEN;
4242

4343
if ($auth) {
4444
DB::table('faults')->where('id', $new['id'])->update(['status' => FaultsTable::getState($new['status'])]);
4545
}
4646

4747
return var_export($auth);
4848
}
49-
}
49+
}

app/Http/Controllers/HomeController.php

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

33
namespace App\Http\Controllers;
44

5-
use Illuminate\Http\Request;
6-
75
class HomeController extends Controller
86
{
97
/**

app/Http/Controllers/InternetController.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
use App\InternetAccess;
66
use App\MacAddress;
77
use App\User;
8-
use Illuminate\Auth\Access\AuthorizationException;
8+
use App\Utils\TabulatorPaginator;
99
use Illuminate\Http\Request;
1010
use Illuminate\Support\Facades\Auth;
11-
use App\Utils\TabulatorPaginator;
1211
use Illuminate\Support\Facades\DB;
1312
use Illuminate\Support\Str;
1413

@@ -22,10 +21,10 @@ public function __construct()
2221
public function index()
2322
{
2423
$internetAccess = Auth::user()->internetAccess;
24+
2525
return view('internet.app', ['internet_access' => $internetAccess]);
2626
}
2727

28-
2928
public function admin()
3029
{
3130
$activationDate = env('INTERNET_ACTIVATION_DATE'); //TODO: get date for current semester
@@ -58,7 +57,8 @@ public function getUsersMacAddressesAdmin(Request $request)
5857
return $paginator;
5958
}
6059

61-
public function getInternetAccessesAdmin() {
60+
public function getInternetAccessesAdmin()
61+
{
6262
$this->authorize('viewAny', InternetAccess::class);
6363

6464
$paginator = TabulatorPaginator::from(InternetAccess::join('users as user', 'user.id', '=', 'user_id')->select('internet_accesses.*')->with('user'))
@@ -80,9 +80,10 @@ public function deleteMacAddress(Request $request, $id)
8080
$this->autoApproveMacAddresses($macAddress->user);
8181
}
8282

83-
public function resetWifiPassword(Request $request) {
83+
public function resetWifiPassword(Request $request)
84+
{
8485
$request->validate([
85-
'confirm' => 'accepted'
86+
'confirm' => 'accepted',
8687
]);
8788

8889
$internetAccess = Auth::user()->internetAccess;
@@ -161,7 +162,8 @@ public function addMacAddress(Request $request)
161162
return redirect()->back();
162163
}
163164

164-
private function autoApproveMacAddresses($user) {
165+
private function autoApproveMacAddresses($user)
166+
{
165167
DB::statement('UPDATE mac_addresses SET state = \'APPROVED\' WHERE user_id = ? ORDER BY FIELD(state,\'APPROVED\',\'REQUESTED\',\'REJECTED\'), updated_at DESC limit ?;', [$user->id, $user->internetAccess->auto_approved_mac_slots]);
166168
}
167169

@@ -181,6 +183,7 @@ public function translateStates(): \Closure
181183
$data->state = __('internet.requested');
182184
break;
183185
}
186+
184187
return $data;
185188
};
186189
}

0 commit comments

Comments
 (0)