Skip to content

Commit f7265cf

Browse files
committed
Merge branch 'release' into #355-2fa
# Conflicts: # routes/console.php # routes/web.php
2 parents 429612e + 590f0d2 commit f7265cf

File tree

106 files changed

+1440
-122
lines changed

Some content is hidden

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

106 files changed

+1440
-122
lines changed

app/Console/Kernel.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Jobs\Snackspace\LogDebtJob;
66
use Illuminate\Console\Scheduling\Schedule;
7+
use App\Jobs\GateKeeper\ZoneOccupantResetJob;
78
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
89

910
class Kernel extends ConsoleKernel
@@ -42,6 +43,7 @@ protected function schedule(Schedule $schedule)
4243
$schedule->command('horizon:snapshot')->everyFiveMinutes();
4344

4445
$schedule->job(new LogDebtJob)->daily();
46+
$schedule->job(new ZoneOccupantResetJob)->twiceDaily();
4547
}
4648

4749
/**

app/HMS/Entities/GateKeeper/Zone.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class Zone
66
{
7+
const OFF_SITE = 'Off-site';
8+
79
/**
810
* @var int
911
*/

app/HMS/Entities/GateKeeper/ZoneOccupancyLog.php

+48
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,52 @@ public function getTimeEntered()
7373
{
7474
return $this->timeEntered;
7575
}
76+
77+
/**
78+
* @param Zone $zone
79+
*
80+
* @return self
81+
*/
82+
public function setZone(Zone $zone)
83+
{
84+
$this->zone = $zone;
85+
86+
return $this;
87+
}
88+
89+
/**
90+
* @param User $user
91+
*
92+
* @return self
93+
*/
94+
public function setUser(User $user)
95+
{
96+
$this->user = $user;
97+
98+
return $this;
99+
}
100+
101+
/**
102+
* @param Carbon $timeExited
103+
*
104+
* @return self
105+
*/
106+
public function setTimeExited(Carbon $timeExited)
107+
{
108+
$this->timeExited = $timeExited;
109+
110+
return $this;
111+
}
112+
113+
/**
114+
* @param Carbon $timeEntered
115+
*
116+
* @return self
117+
*/
118+
public function setTimeEntered(Carbon $timeEntered)
119+
{
120+
$this->timeEntered = $timeEntered;
121+
122+
return $this;
123+
}
76124
}

app/HMS/Entities/GateKeeper/ZoneOccupant.php

+36-10
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ class ZoneOccupant
2222
*/
2323
protected $timeEntered;
2424

25-
/**
26-
* Gets the value of id.
27-
*
28-
* @return int
29-
*/
30-
public function getId()
31-
{
32-
return $this->id;
33-
}
34-
3525
/**
3626
* @return User
3727
*/
@@ -55,4 +45,40 @@ public function getTimeEntered()
5545
{
5646
return $this->timeEntered;
5747
}
48+
49+
/**
50+
* @param User $user
51+
*
52+
* @return self
53+
*/
54+
public function setUser(User $user)
55+
{
56+
$this->user = $user;
57+
58+
return $this;
59+
}
60+
61+
/**
62+
* @param Zone $zone
63+
*
64+
* @return self
65+
*/
66+
public function setZone(Zone $zone)
67+
{
68+
$this->zone = $zone;
69+
70+
return $this;
71+
}
72+
73+
/**
74+
* @param Carbon $timeEntered
75+
*
76+
* @return self
77+
*/
78+
public function setTimeEntered(Carbon $timeEntered)
79+
{
80+
$this->timeEntered = $timeEntered;
81+
82+
return $this;
83+
}
5884
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace HMS\Repositories\GateKeeper\Doctrine;
4+
5+
use HMS\Entities\GateKeeper\ZoneOccupancyLog;
6+
use Doctrine\ORM\EntityRepository;
7+
use HMS\Repositories\GateKeeper\ZoneOccupancyLogRepository;
8+
9+
class DoctrineZoneOccupancyLogRepository extends EntityRepository implements ZoneOccupancyLogRepository
10+
{
11+
/**
12+
* Save ZoneOccupancyLog to the DB.
13+
*
14+
* @param ZoneOccupancyLog $zoneOccupancyLog
15+
*/
16+
public function save(ZoneOccupancyLog $zoneOccupancyLog)
17+
{
18+
$this->_em->persist($zoneOccupancyLog);
19+
$this->_em->flush();
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace HMS\Repositories\GateKeeper\Doctrine;
4+
5+
use HMS\Entities\GateKeeper\ZoneOccupant;
6+
use Doctrine\ORM\EntityRepository;
7+
use HMS\Repositories\GateKeeper\ZoneOccupantRepository;
8+
9+
class DoctrineZoneOccupantRepository extends EntityRepository implements ZoneOccupantRepository
10+
{
11+
/**
12+
* Save ZoneOccupant to the DB.
13+
*
14+
* @param ZoneOccupant $zoneOccupant
15+
*/
16+
public function save(ZoneOccupant $zoneOccupant)
17+
{
18+
$this->_em->persist($zoneOccupant);
19+
$this->_em->flush();
20+
}
21+
}

app/HMS/Repositories/GateKeeper/Doctrine/DoctrineZoneRepository.php

+22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88

99
class DoctrineZoneRepository extends EntityRepository implements ZoneRepository
1010
{
11+
/**
12+
* Find all zones.
13+
*
14+
* @return Zone[]
15+
*/
16+
public function findAll()
17+
{
18+
return parent::findAll();
19+
}
20+
21+
/**
22+
* Find one zone by short name
23+
*
24+
* @param string $shortName
25+
*
26+
* @return Zone
27+
*/
28+
public function findOneByShortName(string $shortName)
29+
{
30+
return parent::findOneByShortName($shortName);
31+
}
32+
1133
/**
1234
* Save Zone to the DB.
1335
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace HMS\Repositories\GateKeeper;
4+
5+
use HMS\Entities\GateKeeper\ZoneOccupancyLog;
6+
7+
interface ZoneOccupancyLogRepository
8+
{
9+
/**
10+
* Save ZoneOccupancyLog to the DB.
11+
*
12+
* @param ZoneOccupancyLog $zoneOccupancyLog
13+
*/
14+
public function save(ZoneOccupancyLog $zoneOccupancyLog);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace HMS\Repositories\GateKeeper;
4+
5+
use HMS\Entities\GateKeeper\ZoneOccupant;
6+
7+
interface ZoneOccupantRepository
8+
{
9+
/**
10+
* Save ZoneOccupant to the DB.
11+
*
12+
* @param ZoneOccupant $zoneOccupant
13+
*/
14+
public function save(ZoneOccupant $zoneOccupant);
15+
}

app/HMS/Repositories/GateKeeper/ZoneRepository.php

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66

77
interface ZoneRepository
88
{
9+
/**
10+
* Find all zones.
11+
*
12+
* @return Zone[]
13+
*/
14+
public function findAll();
15+
16+
/**
17+
* Find one zone by short name
18+
*
19+
* @param string $shortName
20+
*
21+
* @return Zone
22+
*/
23+
public function findOneByShortName(string $shortName);
24+
925
/**
1026
* Save Zone to the DB.
1127
*

app/HMS/Tools/BookingManager.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function bookMaintenance(Tool $tool, Carbon $start, Carbon $end, User $us
156156
}
157157

158158
// Maintenance slot length can be to the end of the day
159-
$maxLength = $start->diffInMinutes($start->copy()->endOfDay());
159+
$maxLength = $start->diffInMinutes($start->copy()->endOfDay()->addMinutes(1));
160160

161161
$basicChecks = $this->basicTimeChecks($start, $end, $maxLength);
162162
if (is_string($basicChecks)) {
@@ -213,7 +213,7 @@ public function update(Tool $tool, Booking $booking, Carbon $start = null, Carbo
213213

214214
if ($booking->getType() == BookingType::MAINTENANCE) {
215215
// Maintenance slot length can be to the end of the day
216-
$maxLength = $start->diffInMinutes($start->copy()->endOfDay());
216+
$maxLength = $start->diffInMinutes($start->copy()->endOfDay()->addMinutes(1));
217217
} else {
218218
$maxLength = $tool->getLengthMax();
219219
}

app/Http/Controllers/Api/TransactionUploadController.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class TransactionUploadController extends Controller
1111
{
1212
/**
13-
* Upload new bank transacions via json.
13+
* Upload new bank transactions via json.
1414
*
1515
* @param Request $request
1616
*
@@ -20,27 +20,31 @@ public function upload(Request $request)
2020
{
2121
/*
2222
* example JSON for request
23+
* make sure headers are
24+
* Accept: application/json
25+
* Content-Type: application/json
26+
* body =
2327
* [
2428
* {
2529
* "sortCode" : "77-22-24",
2630
* "accountNumber" : "13007568",
27-
* "date" : "2017-07-17",
31+
* "date" : "2017-07-17T00:00:00.000Z",
2832
* "description" : "Edward Murphy HSNTSBBPRK86CWPV 4",
2933
* "amount" : 500
3034
* },
3135
* {
3236
* "sortCode" : "77-22-24",
3337
* "accountNumber" : "13007568",
34-
* "date" : "2017-07-16",
38+
* "date" : "2017-07-16T00:00:00.000Z",
3539
* "description" : "Gordon Johnson HSNTSB27496WPB2M 53",
3640
* "amount" : 700
3741
* },
3842
* {
3943
* "sortCode" : "77-22-24",
4044
* "accountNumber" : "13007568",
41-
* "date" : "2017-07-16",
45+
* "date" : "2017-07-16T00:00:00.000Z",
4246
* "description" : "BIZSPACE",
43-
* "amount" : -2389.63
47+
* "amount" : -238963
4448
* }
4549
* ]
4650
*/

app/Http/Controllers/HomeController.php

-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use HMS\Entities\Role;
66
use HMS\Entities\Tools\Booking;
7-
use HMS\Repositories\MetaRepository;
87
use HMS\Repositories\RoleRepository;
98
use HMS\Repositories\Members\BoxRepository;
109
use HMS\Repositories\Tools\BookingRepository;
@@ -128,26 +127,4 @@ public function index()
128127
'bookings' => $mappedBookings,
129128
]);
130129
}
131-
132-
/**
133-
* Show the Hacksapce access codes.
134-
*
135-
* @return \Illuminate\Http\Response
136-
*/
137-
public function accessCodes(MetaRepository $metaRepository)
138-
{
139-
if (! \Gate::allows('accessCodes.view')) {
140-
return redirect()->route('home');
141-
}
142-
$accessCodes = [
143-
'outerDoorCode' => $metaRepository->get('access_street_door'),
144-
'innerDoorCode' => $metaRepository->get('access_inner_door'),
145-
'wifiSsid' => $metaRepository->get('access_wifi_ssid'),
146-
'wifiPass' => $metaRepository->get('access_wifi_password'),
147-
'guestWifiSsid' => $metaRepository->get('access_guest_wifi_ssid'),
148-
'guestWifiPass' => $metaRepository->get('access_guest_wifi_password'),
149-
];
150-
151-
return view('pages.access')->with($accessCodes);
152-
}
153130
}

app/Http/Controllers/Tools/BookingController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function index(Tool $tool)
5555

5656
$userCanBook = [
5757
'userId' => $user->getId(),
58-
'normal' => $user->can('tools.' . $tool->getPermissionName() . '.book'), // TODO: true for an unrestriced tool
58+
'normal' => $user->can('tools.' . $tool->getPermissionName() . '.book'),
5959
'normalCurrentCount' => $this->bookingRepository->countNormalByToolAndUser($tool, $user),
6060
'induction' => $user->can('tools.' . $tool->getPermissionName() . '.book.induction'),
6161
'maintenance' => $user->can('tools.' . $tool->getPermissionName() . '.book.maintenance'),

0 commit comments

Comments
 (0)