Skip to content

Commit 3b9fbcf

Browse files
authored
Merge pull request #72 from IFRCGo/staging
Staging
2 parents cc1a834 + aaadfbe commit 3b9fbcf

6 files changed

Lines changed: 270 additions & 228 deletions

File tree

app/Classes/Repositories/ApplicationRepository.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public function findIn($ids = [], $columns = ['*'])
5454
public function create(array $attributes)
5555
{
5656
$attributes['key'] = Application::generateKey();
57+
$attributes['rules'] = array_merge([
58+
'can_access_legacy_whatnow' => true,
59+
'can_access_preparedness_v2' => false,
60+
'allowed_country_code' => [],
61+
], $attributes['rules'] ?? []);
5762

5863
return $this->applicationModel->create($attributes);
5964
}

app/Classes/Repositories/WhatNowRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class WhatNowRepository implements WhatNowRepositoryInterface
1414
'recover',
1515
'anticipated',
1616
'assess_and_plan',
17-
'mitigate_risks',
17+
'mitigate_risk',
1818
'prepare_to_respond',
1919

2020

app/Http/Middleware/ApiAuthMiddleware.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ public function handle($request, Closure $next)
4444
return response()->json(['error' => 'Application is not allowed to access this API version'], 403);
4545
}
4646

47-
$canAccessOrganisation = $this->canAccessOrganisation($request->path(), (array) $application->rules);
47+
$canAccessOrganisation = true;
48+
if (strpos($request->path(), 'v2/') === 0) {
49+
$canAccessOrganisation = $this->canAccessOrganisation($request->path(), (array) $application->rules);
50+
}
4851

4952
if (!$canAccessOrganisation) {
5053
return response()->json(['error' => 'Application is not allowed to access this organisation'], 403);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
class ChangeMitigateRisksToMitigateRiskInWhatnowEntityStagesTable extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
DB::statement("ALTER TABLE whatnow_entity_stages MODIFY COLUMN stage ENUM('immediate', 'warning', 'anticipated', 'assess_and_plan', 'mitigate_risks', 'mitigate_risk', 'prepare_to_respond', 'recover') NOT NULL");
16+
DB::statement("UPDATE whatnow_entity_stages SET stage = 'mitigate_risk' WHERE stage = 'mitigate_risks'");
17+
DB::statement("ALTER TABLE whatnow_entity_stages MODIFY COLUMN stage ENUM('immediate', 'warning', 'anticipated', 'assess_and_plan', 'mitigate_risk', 'prepare_to_respond', 'recover') NOT NULL");
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
DB::statement("ALTER TABLE whatnow_entity_stages MODIFY COLUMN stage ENUM('immediate', 'warning', 'anticipated', 'assess_and_plan', 'mitigate_risks', 'mitigate_risk', 'prepare_to_respond', 'recover') NOT NULL");
28+
DB::statement("UPDATE whatnow_entity_stages SET stage = 'mitigate_risks' WHERE stage = 'mitigate_risk'");
29+
DB::statement("ALTER TABLE whatnow_entity_stages MODIFY COLUMN stage ENUM('immediate', 'warning', 'anticipated', 'assess_and_plan', 'mitigate_risks', 'prepare_to_respond', 'recover') NOT NULL");
30+
}
31+
}
32+

0 commit comments

Comments
 (0)