From b3a30d99f0fa54670dedde47bfb16dfd2f19bb11 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 5 Jun 2023 09:42:16 +0100 Subject: [PATCH 01/19] Demote network coordinator. --- app/Http/Controllers/UserController.php | 10 ++++- .../Feature/Events/AddRemoveVolunteerTest.php | 2 +- tests/Feature/Networks/NetworkTest.php | 40 ++++++++++++++++--- tests/TestCase.php | 2 + 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 7995c57cd2..51cbedd665 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -373,11 +373,19 @@ public function postAdminEdit(Request $request) $user = User::find($user_id); + $oldRole = $user->role; + // Set role for User $user->update([ - 'role' => $request->input('user_role'), + 'role' => $request->input('user_role'), ]); + // If we are demoting from NetworkCoordinator to host, remove them from the list of coordinators for + // any networks they are currently coordinating. + if ($oldRole == Role::NETWORK_COORDINATOR && $user->role == Role::HOST) { + $user->networks()->detach(); + } + // The user may have previously been removed from the group, which will mean they have an entry in // users_groups with deleted_at set. Zap that if present so that sync() then works. sync() doesn't // handle soft deletes itself. diff --git a/tests/Feature/Events/AddRemoveVolunteerTest.php b/tests/Feature/Events/AddRemoveVolunteerTest.php index 88d34800f9..8f6588a0b3 100644 --- a/tests/Feature/Events/AddRemoveVolunteerTest.php +++ b/tests/Feature/Events/AddRemoveVolunteerTest.php @@ -198,7 +198,7 @@ public function testAdminRemoveReaddHost() { $response = $this->post('/profile/edit-admin-settings', [ '_token' => $tokenValue, 'id' => $host->id, - 'user_role' => 2, + 'user_role' => Role::ADMINISTRATOR, 'assigned_groups' => [ $idgroups ], diff --git a/tests/Feature/Networks/NetworkTest.php b/tests/Feature/Networks/NetworkTest.php index f563f4cd97..6aedc154cf 100644 --- a/tests/Feature/Networks/NetworkTest.php +++ b/tests/Feature/Networks/NetworkTest.php @@ -19,11 +19,6 @@ class NetworkTest extends TestCase protected function setUp(): void { parent::setUp(); - DB::statement('SET foreign_key_checks=0'); - Network::truncate(); - DB::delete('delete from user_network'); - DB::statement('SET foreign_key_checks=1'); - $this->networkService = new RepairNetworkService(); } @@ -330,4 +325,39 @@ public function admins_can_edit() $this->assertTrue($network->containsGroup($group)); $this->assertTrue($group->isMemberOf($network)); } + + public function testRemoveNetworkCoordinatorByRole() { + $this->withoutExceptionHandling(); + + $network = Network::factory()->create(); + + $admin = User::factory()->administrator()->create(); + $coordinator = User::factory()->networkCoordinator()->create(); + $network->addCoordinator($coordinator); + + $this->actingAs($admin); + + $response = $this->get('/user/edit/' . $coordinator->id); + $response->assertStatus(200); + + $crawler = new Crawler($response->getContent()); + + $tokens = $crawler->filter('input[name=_token]')->each(function (Crawler $node, $i) { + return $node; + }); + + $tokenValue = $tokens[0]->attr('value'); + + $response = $this->post('/profile/edit-admin-settings', [ + '_token' => $tokenValue, + 'id' => $coordinator->id, + 'assigned_groups' => [], + 'user_role' => Role::HOST, + ]); + $response->assertSessionHas('message'); + $this->assertTrue($response->isRedirection()); + + // Demoting to host should remove as a network coordinator. + $this->assertFalse($network->coordinators->contains($coordinator)); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index cb82ed3650..4fe386f7fd 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -94,6 +94,8 @@ protected function setUp(): void $network->name = 'Restarters'; $network->shortname = 'restarters'; $network->save(); + } else { + error_log("Got network"); } $this->withoutExceptionHandling(); From 6c845be9a8f1a133caf83ec9de458fe98dc8f3cc Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 5 Jun 2023 09:43:33 +0100 Subject: [PATCH 02/19] Demote network coordinator. --- app/Http/Controllers/UserController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 51cbedd665..8b2ce89958 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -380,9 +380,9 @@ public function postAdminEdit(Request $request) 'role' => $request->input('user_role'), ]); - // If we are demoting from NetworkCoordinator to host, remove them from the list of coordinators for + // If we are demoting from NetworkCoordinator, remove them from the list of coordinators for // any networks they are currently coordinating. - if ($oldRole == Role::NETWORK_COORDINATOR && $user->role == Role::HOST) { + if ($oldRole == Role::NETWORK_COORDINATOR && ($user->role == Role::HOST) || $user->role == Role::RESTARTER) { $user->networks()->detach(); } From 33e8166377a661925775759ebb43f63118d8d3f8 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 5 Jun 2023 10:20:09 +0100 Subject: [PATCH 03/19] Test fixes. --- tests/Feature/Events/AddRemoveVolunteerTest.php | 1 + tests/Feature/Networks/NetworkTest.php | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Feature/Events/AddRemoveVolunteerTest.php b/tests/Feature/Events/AddRemoveVolunteerTest.php index 8f6588a0b3..5a047e91bd 100644 --- a/tests/Feature/Events/AddRemoveVolunteerTest.php +++ b/tests/Feature/Events/AddRemoveVolunteerTest.php @@ -9,6 +9,7 @@ use App\Notifications\AdminModerationEvent; use App\Notifications\NotifyRestartersOfNewEvent; use App\Party; +use App\Role; use App\User; use DB; use Faker\Generator as Faker; diff --git a/tests/Feature/Networks/NetworkTest.php b/tests/Feature/Networks/NetworkTest.php index 6aedc154cf..9b31092927 100644 --- a/tests/Feature/Networks/NetworkTest.php +++ b/tests/Feature/Networks/NetworkTest.php @@ -300,10 +300,7 @@ public function admins_can_edit() $admin = User::factory()->administrator()->create(); $this->actingAs($admin); - $network = new Network(); - $network->name = 'Restarters'; - $network->shortname = 'restarters'; - $network->save(); + $network = Network::where('shortname', 'restarters')->first(); $response = $this->get('/networks/' . $network->id . '/edit', $network->attributesToArray()); $response->assertSuccessful(); From e276705859e7729cfbbab14cb069fe310e05dd93 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 5 Jun 2023 10:59:00 +0100 Subject: [PATCH 04/19] Test change to help debug intermittent test failure. --- tests/Feature/Events/InviteEventTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Feature/Events/InviteEventTest.php b/tests/Feature/Events/InviteEventTest.php index cf8fe315e9..390f5e18f1 100644 --- a/tests/Feature/Events/InviteEventTest.php +++ b/tests/Feature/Events/InviteEventTest.php @@ -146,8 +146,8 @@ public function testInviteReal() // ...should show up in the list of events with an invitation as we have not yet accepted. $response3 = $this->get('/party'); $events = $this->getVueProperties($response3)[1][':initial-events']; - $this->assertNotFalse(strpos($events, '"attending":false')); - $this->assertNotFalse(strpos($events, '"invitation"')); + $this->assertStringContainsString('"attending":false', $events); + $this->assertStringContainsString('"invitation"', $events); // Now accept the invitation. $response4 = $this->get($invitation); From 1968013f8c8fd5b31ec0b6f524516e0f07f00bd6 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 12 Jun 2023 11:51:10 +0100 Subject: [PATCH 05/19] WIP Add varying message, handle weight mandatory. --- lang/en/devices.php | 3 +- lang/fr-BE/devices.php | 3 +- lang/fr/devices.php | 3 +- .../js/components/DeviceCategorySelect.vue | 22 +++---- resources/js/components/DeviceWeight.vue | 17 ++++- resources/js/components/EventDevice.vue | 64 +++++++++---------- resources/js/constants.js | 3 +- 7 files changed, 62 insertions(+), 53 deletions(-) diff --git a/lang/en/devices.php b/lang/en/devices.php index c358aa2afe..c159235700 100644 --- a/lang/en/devices.php +++ b/lang/en/devices.php @@ -44,7 +44,8 @@ 'powered_items' => 'powered items', 'unpowered_items' => 'unpowered items', 'weight' => 'Weight', - 'required_impact' => 'kg - required for environmental impact calculation', + 'required_impact' => 'kg - used for environmental impact calculation (required)', + 'optional_impact' => 'kg - used for environmental impact calculation (optional)', 'age_approx' => 'years (approximate if unknown)', 'repair_source' => 'Source of repair information', 'tooltip_category' => 'Choose the category that best fits this item. More information about these categories...', diff --git a/lang/fr-BE/devices.php b/lang/fr-BE/devices.php index 77962e3747..044d8fac4d 100644 --- a/lang/fr-BE/devices.php +++ b/lang/fr-BE/devices.php @@ -47,7 +47,8 @@ 'powered_items' => 'Appareils électriques', 'repair_outcome' => 'Résultat de la réparation?', 'repair_source' => 'Source d\'information de la réparation', - 'required_impact' => 'kg - requis pour calcul de l\'impact environnemental', + 'required_impact' => 'kg - utilisé pour le calcul de l\'impact environnemental (obligatoire)', + 'optional_impact' => 'kg - utilisé pour le calcul de l\'impact environnemental (facultatif)', 'title_assessment' => 'Evaluation', 'title_items' => 'Objet', 'title_items_at_event' => 'Objets à cet événement', diff --git a/lang/fr/devices.php b/lang/fr/devices.php index 77962e3747..044d8fac4d 100644 --- a/lang/fr/devices.php +++ b/lang/fr/devices.php @@ -47,7 +47,8 @@ 'powered_items' => 'Appareils électriques', 'repair_outcome' => 'Résultat de la réparation?', 'repair_source' => 'Source d\'information de la réparation', - 'required_impact' => 'kg - requis pour calcul de l\'impact environnemental', + 'required_impact' => 'kg - utilisé pour le calcul de l\'impact environnemental (obligatoire)', + 'optional_impact' => 'kg - utilisé pour le calcul de l\'impact environnemental (facultatif)', 'title_assessment' => 'Evaluation', 'title_items' => 'Objet', 'title_items_at_event' => 'Objets à cet événement', diff --git a/resources/js/components/DeviceCategorySelect.vue b/resources/js/components/DeviceCategorySelect.vue index a0a563e8cc..51d08e0bc0 100644 --- a/resources/js/components/DeviceCategorySelect.vue +++ b/resources/js/components/DeviceCategorySelect.vue @@ -29,7 +29,7 @@ diff --git a/resources/js/components/EventDevice.vue b/resources/js/components/EventDevice.vue index 4ce598ffa5..af6be5b287 100644 --- a/resources/js/components/EventDevice.vue +++ b/resources/js/components/EventDevice.vue @@ -25,7 +25,7 @@ :suppress-brand-warning="suppressBrandWarning"/> - + @@ -378,7 +378,7 @@ export default { }, async addDevice () { try { - if (this.weightRequired && this.currentDevice.weight == null) { + if (this.weightRequired && (isNaN(this.currentDevice.estimate) || this.currentDevice.estimate == null)) { this.missingWeight = true } else { this.missingWeight = false @@ -401,7 +401,7 @@ export default { }, async saveDevice () { try { - if (this.weightRequired && this.currentDevice.weight == null) { + if (this.weightRequired && (isNaN(this.currentDevice.estimate) || this.currentDevice.estimate == null)) { this.missingWeight = true } else { this.missingWeight = false From 77120b0fce6751263d37d7cdf84191ebec6f4fc1 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 12 Jun 2023 12:12:02 +0100 Subject: [PATCH 07/19] Review feedback. --- app/Http/Controllers/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 8b2ce89958..d52114b66e 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -382,7 +382,7 @@ public function postAdminEdit(Request $request) // If we are demoting from NetworkCoordinator, remove them from the list of coordinators for // any networks they are currently coordinating. - if ($oldRole == Role::NETWORK_COORDINATOR && ($user->role == Role::HOST) || $user->role == Role::RESTARTER) { + if ($oldRole == Role::NETWORK_COORDINATOR && ($user->role == Role::HOST || $user->role == Role::RESTARTER)) { $user->networks()->detach(); } From 9e644b202aa694bfb9fb4df83a81fec2c6ca1cd5 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 12 Jun 2023 18:12:06 +0100 Subject: [PATCH 08/19] Change from storing country names in the DB to country codes. --- app/Console/Commands/CheckGroupLocations.php | 2 +- app/Console/Commands/FixLatitudeLongitude.php | 45 -------------- app/Console/Commands/ImportGroups.php | 4 +- app/Console/Commands/SyncEvents.php | 3 +- app/Console/Commands/SyncGroups.php | 3 +- app/Group.php | 2 +- app/Helpers/Geocoder.php | 4 +- app/Http/Controllers/API/GroupController.php | 12 ++-- .../Controllers/API/UserGroupsController.php | 3 +- app/Http/Controllers/ExportController.php | 2 +- app/Http/Controllers/GroupController.php | 2 +- app/Http/Controllers/UserController.php | 12 ++-- app/Http/Resources/GroupLocation.php | 9 ++- app/Listeners/CreateWordpressPostForEvent.php | 2 +- app/Listeners/CreateWordpressPostForGroup.php | 2 +- app/Listeners/EditWordpressPostForEvent.php | 2 +- app/Listeners/EditWordpressPostForGroup.php | 2 +- app/User.php | 2 +- database/factories/UserFactory.php | 2 +- .../2023_06_12_153317_country_codes.php | 58 +++++++++++++++++++ lang/en/countries.php | 2 +- lang/fr-BE/countries.php | 2 +- .../blocks/groups-near-you.blade.php | 2 +- resources/views/user/all.blade.php | 2 +- .../views/user/profile/profile.blade.php | 2 +- tests/Feature/Dashboard/BasicTest.php | 6 +- tests/Feature/Groups/APIv2GroupTest.php | 1 + tests/Feature/Groups/GroupCommandsTest.php | 2 +- tests/Feature/Microtasks/BattcatOraTest.php | 6 +- tests/Feature/Microtasks/DustupOraTest.php | 6 +- tests/Feature/Microtasks/MobifixOraTest.php | 2 +- tests/Feature/Microtasks/PrintcatOraTest.php | 6 +- tests/Feature/Microtasks/TabicatOraTest.php | 4 +- tests/Feature/Networks/APIv2NetworkTest.php | 4 +- tests/Feature/Users/EditProfileTest.php | 6 +- .../Registration/AccountCreationTest.php | 2 +- tests/TestCase.php | 2 +- tests/Unit/{t => }/GeocoderTest.php | 3 +- 38 files changed, 128 insertions(+), 105 deletions(-) delete mode 100644 app/Console/Commands/FixLatitudeLongitude.php create mode 100644 database/migrations/2023_06_12_153317_country_codes.php rename tests/Unit/{t => }/GeocoderTest.php (80%) diff --git a/app/Console/Commands/CheckGroupLocations.php b/app/Console/Commands/CheckGroupLocations.php index 7e0d23c910..7a44642e22 100644 --- a/app/Console/Commands/CheckGroupLocations.php +++ b/app/Console/Commands/CheckGroupLocations.php @@ -19,7 +19,7 @@ class CheckGroupLocations extends Command * * @var string */ - protected $description = 'Check that all gtroup locations are geocodeable'; + protected $description = 'Check that all group locations are geocodeable'; /** * Create a new command instance. diff --git a/app/Console/Commands/FixLatitudeLongitude.php b/app/Console/Commands/FixLatitudeLongitude.php deleted file mode 100644 index cf4a748c88..0000000000 --- a/app/Console/Commands/FixLatitudeLongitude.php +++ /dev/null @@ -1,45 +0,0 @@ - 99 OR longitude > 99) AND deleted_at IS NULL;')); - - foreach ($users as $user) { - $this->info("User {$user->id} {$user->country}:{$user->location}"); - $geocoded = $geocoder->geocode($user->location.','.$user->country); - - if (! empty($geocoded)) { - $this->info("...{$geocoded['latitude']}, {$geocoded['longitude']}"); - DB::update(DB::raw("UPDATE users SET latitude = {$geocoded['latitude']}, longitude={$geocoded['longitude']} WHERE id = {$user->id};")); - } - } - } -} diff --git a/app/Console/Commands/ImportGroups.php b/app/Console/Commands/ImportGroups.php index 18c8ddada8..bf4aa49532 100644 --- a/app/Console/Commands/ImportGroups.php +++ b/app/Console/Commands/ImportGroups.php @@ -61,7 +61,7 @@ public function handle() return iconv( "iso-8859-15", "UTF-8", $str ); }, $fields); - // Format is 'Name', 'Location', 'Postcode', 'Area', 'Country', 'Latitude', 'Longitude', 'Website', 'Phone', 'Networks', 'Description'. + // Format is 'Name', 'Location', 'Postcode', 'Area', 'CountryCode', 'Latitude', 'Longitude', 'Website', 'Phone', 'Networks', 'Description'. $groupname = $fields[0]; $location = $fields[1]; @@ -122,7 +122,7 @@ public function handle() $group->area = $area; $group->latitude = $lat; $group->longitude = $lng; - $group->country = $country; + $group->country_code = $country; $group->website = $website; $group->phone = $phone; $group->free_text = $description; diff --git a/app/Console/Commands/SyncEvents.php b/app/Console/Commands/SyncEvents.php index 182ea8aff3..9e6d3600a8 100644 --- a/app/Console/Commands/SyncEvents.php +++ b/app/Console/Commands/SyncEvents.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use App\Group; +use App\Helpers\Fixometer; use App\Party; use DateTime; use Illuminate\Console\Command; @@ -77,7 +78,7 @@ public function handle() $custom_fields = [ ['key' => 'party_grouphash', 'value' => $event->group], - ['key' => 'party_groupcountry', 'value' => $group->country], + ['key' => 'party_groupcountry', 'value' => Fixometer::getCountryFromCountryCode($group->country_code)], ['key' => 'party_groupcity', 'value' => $group->area], ['key' => 'party_venue', 'value' => $event->venue], ['key' => 'party_location', 'value' => $event->location], diff --git a/app/Console/Commands/SyncGroups.php b/app/Console/Commands/SyncGroups.php index 8d00012056..051f7b4f9c 100644 --- a/app/Console/Commands/SyncGroups.php +++ b/app/Console/Commands/SyncGroups.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use App\Group; +use App\Helpers\Fixometer; use Illuminate\Console\Command; class SyncGroups extends Command @@ -54,7 +55,7 @@ public function handle() try { $custom_fields = [ ['key' => 'group_city', 'value' => $group->area], - ['key' => 'group_country', 'value' => $group->country], + ['key' => 'group_country', 'value' => Fixometer::getCountryFromCountryCode($group->country_code)], ['key' => 'group_website', 'value' => $group->website], ['key' => 'group_hash', 'value' => $group->idgroups], ['key' => 'group_latitude', 'value' => $group->latitude], diff --git a/app/Group.php b/app/Group.php index 1ecf268740..1cb8c8d8f9 100644 --- a/app/Group.php +++ b/app/Group.php @@ -34,7 +34,7 @@ class Group extends Model implements Auditable 'postcode', 'latitude', 'longitude', - 'country', + 'country_code', 'free_text', 'facebook', 'wordpress_post_id', diff --git a/app/Helpers/Geocoder.php b/app/Helpers/Geocoder.php index eb2178e52b..6dea4b0f96 100644 --- a/app/Helpers/Geocoder.php +++ b/app/Helpers/Geocoder.php @@ -30,14 +30,14 @@ public function geocode($location) foreach ($decoded->{'address_components'} as $component) { if ($component->types && count($component->types) && $component->types[0] === 'country') { - $country = $component->long_name; + $country_code = $component->short_name; } } return [ 'latitude' => $latitude, 'longitude' => $longitude, - 'country' => $country, + 'country_code' => $country_code, ]; } } diff --git a/app/Http/Controllers/API/GroupController.php b/app/Http/Controllers/API/GroupController.php index eaddc820d0..d9219d574a 100644 --- a/app/Http/Controllers/API/GroupController.php +++ b/app/Http/Controllers/API/GroupController.php @@ -102,7 +102,7 @@ public static function getGroupsByUsersNetworks(Request $request) 'timezone' => $group->timezone, 'location' => [ 'value' => $group->location, - 'country' => Fixometer::translateCountry($group->country, $countries), + 'country' => Fixometer::translateCountry($group->country_code, $countries), 'latitude' => $group->latitude, 'longitude' => $group->longitude, 'area' => $group->area, @@ -606,7 +606,7 @@ public function createGroupv2(Request $request) { 'postcode' => $postcode, 'latitude' => $latitude, 'longitude' => $longitude, - 'country' => $country, + 'country_code' => $country, 'free_text' => $description, 'shareable_code' => Fixometer::generateUniqueShareableCode(\App\Group::class, 'shareable_code'), 'timezone' => $timezone, @@ -750,7 +750,7 @@ public function updateGroupv2(Request $request, $idGroup) { 'location' => $location, 'latitude' => $latitude, 'longitude' => $longitude, - 'country' => $country, + 'country_code' => $country, 'free_text' => $description, 'timezone' => $timezone, 'phone' => $phone, @@ -875,7 +875,7 @@ private function validateGroupParams(Request $request, $create): array { $latitude = null; $longitude = null; - $country = null; + $country_code = null; if ($timezone && !in_array($timezone, \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC))) { throw ValidationException::withMessages(['location ' => __('partials.validate_timezone')]); @@ -895,7 +895,7 @@ private function validateGroupParams(Request $request, $create): array { // Note that the country returned by the geocoder is already in English, which is what we need for the // value in the database. - $country = $geocoded['country']; + $country_code = $geocoded['country_code']; } return array( @@ -909,7 +909,7 @@ private function validateGroupParams(Request $request, $create): array { $timezone, $latitude, $longitude, - $country, + $country_code, $network_data, ); } diff --git a/app/Http/Controllers/API/UserGroupsController.php b/app/Http/Controllers/API/UserGroupsController.php index a6fb3b12ae..b6194192dd 100644 --- a/app/Http/Controllers/API/UserGroupsController.php +++ b/app/Http/Controllers/API/UserGroupsController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\API; use App\Group; +use App\Helpers\Fixometer; use App\Http\Controllers\Controller; use App\Role; use App\User; @@ -83,7 +84,7 @@ protected static function mapDetailsAndAuditToChange($userGroupAssociation, $aud $group = Group::find($userGroupAssociation->group); $userGroupChange['group_name'] = $group->name; $userGroupChange['group_area'] = $group->area; - $userGroupChange['group_country'] = $group->country; + $userGroupChange['group_country'] = Fixometer::getCountryFromCountryCode($group->country_code); return $userGroupChange; } diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 9006b809d0..9e606becc8 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -415,7 +415,7 @@ public function getTimeVolunteered(Request $request, $search = null, $export = f //country hours completed $country_hours_completed = clone $user_events; - $country_hours_completed = $country_hours_completed->groupBy('users.country')->select('users.country', DB::raw('SUM(TIMEDIFF(event_start_utc, event_end_utc)) as event_hours')); + $country_hours_completed = $country_hours_completed->groupBy('users.country_code')->select('users.country_code', DB::raw('SUM(TIMEDIFF(event_start_utc, event_end_utc)) as event_hours')); $all_country_hours_completed = $country_hours_completed->orderBy('event_hours', 'DESC')->get(); $country_hours_completed = $country_hours_completed->orderBy('event_hours', 'DESC')->take(5)->get(); diff --git a/app/Http/Controllers/GroupController.php b/app/Http/Controllers/GroupController.php index 4ea4f8ac75..c2b30cbdc9 100644 --- a/app/Http/Controllers/GroupController.php +++ b/app/Http/Controllers/GroupController.php @@ -513,7 +513,7 @@ public static function expandGroups($groups, $your_groupids, $nearby_groupids) asset('uploads/mid_'.$group_image->image->path) : null, 'location' => [ 'location' => rtrim($group->location), - 'country' => Fixometer::translateCountry($group->country, $countries), + 'country' => Fixometer::translateCountry($group->country_code, $countries), 'distance' => $distance, ], 'next_event' => $event ? $event->event_date_local : null, diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index d52114b66e..635e5e5251 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -157,7 +157,7 @@ public function postProfileInfoEdit(Request $request, App\Helpers\Geocoder $geoc User::find($id)->update([ 'email' => $request->input('email'), 'name' => $request->input('name'), - 'country' => $request->input('country'), + 'country_code' => $request->input('country'), 'location' => $request->input('townCity'), 'age' => $request->input('age'), 'gender' => $request->input('gender'), @@ -171,7 +171,7 @@ public function postProfileInfoEdit(Request $request, App\Helpers\Geocoder $geoc } if (! empty($user->location)) { - $geocoded = $geocoder->geocode("{$user->location}, {$user->country}"); + $geocoded = $geocoder->geocode("{$user->location}, " . Fixometer::getCountryFromCountryCode($user->country_code)); if (! empty($geocoded)) { $user->latitude = $geocoded['latitude']; $user->longitude = $geocoded['longitude']; @@ -536,7 +536,7 @@ public function all() $user['permissions'] = $User->getRolePermissions($user->role); $user['groups'] = $user->groups; $user['lastLogin'] = $user->lastLogin(); - $user['country'] = Fixometer::getCountryFromCountryCode($user->country); + $user['country'] = Fixometer::getCountryFromCountryCode($user->country_code); return $user; }); @@ -607,7 +607,7 @@ public function search(Request $request) $user['permissions'] = $User->getRolePermissions($user->role); $user['groups'] = $user->groups; $user['lastLogin'] = $user->lastLogin(); - $user['country'] = Fixometer::getCountryFromCountryCode($user->country); + $user['country'] = Fixometer::getCountryFromCountryCode($user->country_code); return $user; }); @@ -920,7 +920,7 @@ public function postRegister(Request $request, $hash = null) if (Auth::check()) { //Existing users are to update $user = User::find(Auth::user()->id); - $user->country = $request->input('country'); + $user->country_code = $request->input('country'); $user->location = $request->input('city'); $user->gender = $request->input('gender'); $user->age = $request->input('age'); @@ -935,7 +935,7 @@ public function postRegister(Request $request, $hash = null) 'role' => $role, 'recovery' => substr(bin2hex(openssl_random_pseudo_bytes(32)), 0, 24), 'recovery_expires' => strftime('%Y-%m-%d %X', time() + (24 * 60 * 60)), - 'country' => $request->input('country'), + 'country_code' => $request->input('country'), 'location' => $request->input('city'), 'gender' => $request->input('gender'), 'age' => $request->input('age'), diff --git a/app/Http/Resources/GroupLocation.php b/app/Http/Resources/GroupLocation.php index 2448761871..ec4f75d22d 100644 --- a/app/Http/Resources/GroupLocation.php +++ b/app/Http/Resources/GroupLocation.php @@ -30,6 +30,12 @@ * example="United Kingdom" * ), * @OA\Property( + * property="country_code", + * description="The two-letter ISO country code.", + * format="string", + * example="GB" + * ), + * @OA\Property( * property="lat", * title="lat", * description="Latitude of the group.", @@ -66,7 +72,8 @@ public function toArray($request) 'location' => $this->location, 'area' => $this->area, 'postcode' => $this->postcode, - 'country' => \App\Helpers\Fixometer::translateCountry($this->country), + 'country' => \App\Helpers\Fixometer::getCountryFromCountryCode($this->country_code), + 'country_code' => $this->country_code, 'lat' => $this->latitude, 'lng' => $this->longitude, ]; diff --git a/app/Listeners/CreateWordpressPostForEvent.php b/app/Listeners/CreateWordpressPostForEvent.php index 877a0a087e..1bf382cceb 100644 --- a/app/Listeners/CreateWordpressPostForEvent.php +++ b/app/Listeners/CreateWordpressPostForEvent.php @@ -80,7 +80,7 @@ public function createEventOnWordpress($theParty): void ['key' => 'party_venue', 'value' => $theParty->venue], ['key' => 'party_location', 'value' => $theParty->location], ['key' => 'party_time', 'value' => $theParty->getEventStartEndLocal()], - ['key' => 'party_groupcountry', 'value' => $group->country], + ['key' => 'party_groupcountry', 'value' => Fixometer::getCountryFromCountryCode($group->country_code)], ['key' => 'party_groupcity', 'value' => $group->area], ['key' => 'party_date', 'value' => $theParty->event_date_local], ['key' => 'party_timestamp', 'value' => $startTimestamp], diff --git a/app/Listeners/CreateWordpressPostForGroup.php b/app/Listeners/CreateWordpressPostForGroup.php index 3ecb87a679..12981061e6 100644 --- a/app/Listeners/CreateWordpressPostForGroup.php +++ b/app/Listeners/CreateWordpressPostForGroup.php @@ -72,7 +72,7 @@ public function createGroupOnWordpress($group): void if (!$group->wordpress_post_id) { $custom_fields = [ ['key' => 'group_city', 'value' => $group->area], - ['key' => 'group_country', 'value' => $group->country], + ['key' => 'group_country', 'value' => Fixometer::getCountryFromCountryCode($group->country_code)], ['key' => 'group_website', 'value' => $group->website], ['key' => 'group_hash', 'value' => $group->idgroups], ['key' => 'group_avatar_url', 'value' => $group->groupImagePath()], diff --git a/app/Listeners/EditWordpressPostForEvent.php b/app/Listeners/EditWordpressPostForEvent.php index 83d51ac11a..b91dc035c4 100644 --- a/app/Listeners/EditWordpressPostForEvent.php +++ b/app/Listeners/EditWordpressPostForEvent.php @@ -53,7 +53,7 @@ public function handle(EditEvent $event) $custom_fields = [ ['key' => 'party_grouphash', 'value' => $data['group']], - ['key' => 'party_groupcountry', 'value' => $group->country], + ['key' => 'party_groupcountry', 'value' => Fixometer::getCountryFromCountryCode($group->country_code)], ['key' => 'party_groupcity', 'value' => $group->area], ['key' => 'party_venue', 'value' => $data['venue']], ['key' => 'party_location', 'value' => $data['location']], diff --git a/app/Listeners/EditWordpressPostForGroup.php b/app/Listeners/EditWordpressPostForGroup.php index 3226b73b9e..2985613ed1 100644 --- a/app/Listeners/EditWordpressPostForGroup.php +++ b/app/Listeners/EditWordpressPostForGroup.php @@ -45,7 +45,7 @@ public function handle(EditGroup $event) if (is_numeric($group->wordpress_post_id)) { $custom_fields = [ ['key' => 'group_city', 'value' => $group->area], - ['key' => 'group_country', 'value' => $group->country], + ['key' => 'group_country', 'value' => Fixometer::getCountryFromCountryCode($group->country_code)], ['key' => 'group_website', 'value' => $data['website']], ['key' => 'group_hash', 'value' => $id], ['key' => 'group_avatar_url', 'value' => $data['group_avatar']], diff --git a/app/User.php b/app/User.php index 8c512a8e89..72651e4026 100644 --- a/app/User.php +++ b/app/User.php @@ -37,7 +37,7 @@ class User extends Authenticatable implements Auditable, HasLocalePreference * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'role', 'recovery', 'recovery_expires', 'language', 'repair_network', 'location', 'age', 'gender', 'country', 'newsletter', 'drip_subscriber_id', 'invites', 'biography', 'consent_future_data', 'consent_past_data', 'consent_gdpr', 'number_of_logins', 'latitude', 'longitude', 'last_login_at', 'api_token', 'access_group_tag_id', 'calendar_hash', 'repairdir_role', 'mediawiki', 'username', + 'name', 'email', 'password', 'role', 'recovery', 'recovery_expires', 'language', 'repair_network', 'location', 'age', 'gender', 'country_code', 'newsletter', 'drip_subscriber_id', 'invites', 'biography', 'consent_future_data', 'consent_past_data', 'consent_gdpr', 'number_of_logins', 'latitude', 'longitude', 'last_login_at', 'api_token', 'access_group_tag_id', 'calendar_hash', 'repairdir_role', 'mediawiki', 'username', ]; /** diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index f413454394..c151ae195e 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -38,7 +38,7 @@ public function definition() 'consent_gdpr' => new \DateTime(), 'number_of_logins' => 1, 'age' => $this->faker->year(), - 'country' => $this->faker->countryCode(), + 'country_code' => $this->faker->countryCode(), 'role' => Role::RESTARTER, 'invites' => 1, 'repairdir_role' => Role::REPAIR_DIRECTORY_NONE, diff --git a/database/migrations/2023_06_12_153317_country_codes.php b/database/migrations/2023_06_12_153317_country_codes.php new file mode 100644 index 0000000000..48311e598a --- /dev/null +++ b/database/migrations/2023_06_12_153317_country_codes.php @@ -0,0 +1,58 @@ +renameColumn('country', 'country_code'); + }); + + // Change the groups table to have country_code, not country. + Schema::table('groups', function (Blueprint $table) { + $table->string('country_code', 2)->after('area')->nullable(); + }); + + $groups = DB::select(DB::raw('SELECT idgroups, country FROM groups')); + + foreach ($groups as $g) { + // Countries are stored in English. + if ($g->country) { + $country = $g->country; + $group = Group::findOrFail($g->idgroups); + $group->country_code = $countries[$country]; + Log::debug('Country: ' . $group->country . ' => ' . $group->country_code); + $group->save(); + } + } + + Schema::table('groups', function (Blueprint $table) { + $table->dropColumn('country'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}; diff --git a/lang/en/countries.php b/lang/en/countries.php index 04059479bd..cd01f65f61 100644 --- a/lang/en/countries.php +++ b/lang/en/countries.php @@ -218,7 +218,7 @@ 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', - 'TW' => 'Taiwan, Province of China', + 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania, United Republic of', 'TH' => 'Thailand', diff --git a/lang/fr-BE/countries.php b/lang/fr-BE/countries.php index 137dbb9188..ccc369b13e 100644 --- a/lang/fr-BE/countries.php +++ b/lang/fr-BE/countries.php @@ -218,7 +218,7 @@ 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', - 'TW' => 'Taiwan, Province of China', + 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania, United Republic of', 'TH' => 'Thailand', diff --git a/resources/views/dashboard/blocks/groups-near-you.blade.php b/resources/views/dashboard/blocks/groups-near-you.blade.php index 1c85406446..aa232790ac 100644 --- a/resources/views/dashboard/blocks/groups-near-you.blade.php +++ b/resources/views/dashboard/blocks/groups-near-you.blade.php @@ -37,7 +37,7 @@ @if (is_null(Auth::user()->location)) @lang('dashboard.groups_near_you_set_location', ['profile_url' => '/profile/edit/'.Auth::user()->id]) @else - @lang('dashboard.groups_near_you_your_location_is', ['location' => Auth::user()->location.', '.Auth::user()->country]) + @lang('dashboard.groups_near_you_your_location_is', ['location' => Auth::user()->location.', '.\App\Helpers\Fixometer::getCountryFromCountryCode(Auth::user()->country_code)]) @endif

diff --git a/resources/views/user/all.blade.php b/resources/views/user/all.blade.php index 52859b72c5..0a1592cdfc 100644 --- a/resources/views/user/all.blade.php +++ b/resources/views/user/all.blade.php @@ -194,7 +194,7 @@ N/A @endif - {{ $u->country }} + {{ \App\Helpers\Fixometer::getCountryFromCountryCode($u->country_code) }} @if (isset($u->groups) && $u->groups->count() > 0) {{ $u->groups->count() }} diff --git a/resources/views/user/profile/profile.blade.php b/resources/views/user/profile/profile.blade.php index e35519cbc8..ba106d3590 100644 --- a/resources/views/user/profile/profile.blade.php +++ b/resources/views/user/profile/profile.blade.php @@ -28,7 +28,7 @@ - - @foreach($all_groups as $g) - @if(isset($groups) && in_array($g->idgroups, $groups)) - - @else - - @endif - @endforeach - - - -

- -
- -
-
- - @endif - - @lang('reporting.by_users') -
- - -
-
- -
- -
-
-
- - -
- - @lang('devices.by_date') -
- - -
-
- - -
- - @lang('reporting.by_location') -
- -
- -
-
- - @lang('reporting.miscellaneous') -
- -
- -
-
- - - - - - - -
- @else -
- @endif - -
    -
  • -
    -

    @lang('reporting.hours_volunteered')

    - {{ $hours_completed }} -
    -
  • -
  • -
    -

    @lang('reporting.average_age')

    - {{ $average_age }} -
    -
  • -
  • -
    -

    @lang('reporting.number_of_groups')

    - {{ $group_count }} -
    -
  • -
  • -
    -

    @lang('reporting.total_number_of_users')

    - {{ $total_users }} -
    -
  • -
  • -
    -

    @lang('reporting.number_of_anonymous_users')

    - {{ $anonymous_users }} -
    -
  • -
- -
- -
- -

@lang('reporting.breakdown_by_country') (@lang('reporting.see_all_results'))

- -
- - - - - - - - - @foreach($country_hours_completed as $country_hours) - - @if(!is_null($country_hours->country)) - - @else - - @endif - - - @endforeach - -
@lang('reporting.country_name')@lang('reporting.total_hours')
{{ FixometerHelper::getCountryFromCountryCode($country_hours->country) }}N/A{{ substr($country_hours->event_hours, 0, -4) }}
-
- -
-
- -

@lang('reporting.breakdown_by_city') (@lang('reporting.see_all_results'))

- -
- - - - - - - - - @foreach($city_hours_completed as $city_hours) - - @if(!is_null($city_hours->location)) - - @else - - @endif - - - @endforeach - -
@lang('reporting.town_city_name')@lang('reporting.total_hours')
{{ $city_hours->location }}N/A{{ substr($city_hours->event_hours, 0, -4) }}
-
-
- -
- -
- - - - - - - - - - - - - @foreach($user_events as $ue) - - - @php - $start_time = new DateTime($ue->start); - $diff = $start_time->diff(new DateTime($ue->end)); - @endphp - - - - - - @endforeach - -
@lang('reporting.restarter_name')@lang('reporting.hours')@lang('reporting.event_date')@lang('reporting.event_name')@lang('reporting.restart_group')
{{ $ue->username }}{{ $diff->h.'.'.sprintf("%02d", $diff->i/60 * 100) }}{{ date('d/m/Y', strtotime($ue->event_date)) }}{{ !is_null($ue->venue) ? $ue->venue : $ue->location }}{{ $ue->groupname }}
- - - - -
- -
-
- - - -
-
- - - -@include('includes.modals.time-reporting-1', ['all_country_hours_completed' => $all_country_hours_completed]) -@include('includes.modals.time-reporting-2', ['all_city_hours_completed' => $all_city_hours_completed]) - -@endsection diff --git a/routes/web.php b/routes/web.php index 3778eb232b..ada4d2f5dc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -385,9 +385,6 @@ //Export Controller Route::get('/export/parties', [ExportController::class, 'parties']); - Route::get('/export/time-volunteered', [ExportController::class, 'exportTimeVolunteered']); - Route::get('/reporting/time-volunteered', [ExportController::class, 'getTimeVolunteered']); - Route::get('/reporting/time-volunteered/{search}', [ExportController::class, 'getTimeVolunteered']); }); Route::middleware('ensureAPIToken')->group(function () { diff --git a/tests/Feature/Events/ExportTest.php b/tests/Feature/Events/ExportTest.php index 6e38a009ec..84fdac5e7d 100644 --- a/tests/Feature/Events/ExportTest.php +++ b/tests/Feature/Events/ExportTest.php @@ -231,19 +231,6 @@ public function testExport($role) fgetcsv($fh); $row2 = fgetcsv($fh); self::assertEquals(11, count($row2)); - - // Export time volunteered - first as a web page. - $response = $this->get("/reporting/time-volunteered?a"); - $response->assertSee($event1->getEventName()); - $response->assertSee($event2->getEventName()); - - // Now as a CSV. - $response = $this->get("/export/time-volunteered?a"); - $filename = 'time_reporting.csv'; - $fh = fopen($filename, 'r'); - $row1 = fgetcsv($fh); - $row2 = fgetcsv($fh); - $this->assertEquals('Hours Volunteered', $row2[0]); } public function roleProvider() { From e3e7db19ee0f9de5d6cc40753c83135dddf49679 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 10 Jul 2023 09:46:47 +0100 Subject: [PATCH 16/19] Review fixes --- app/Http/Controllers/API/GroupController.php | 5 ++--- app/Http/Controllers/GroupController.php | 5 ++--- .../migrations/2023_06_12_153317_country_codes.php | 10 +++++++++- tests/Feature/Networks/NetworkTest.php | 4 ++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/API/GroupController.php b/app/Http/Controllers/API/GroupController.php index d9219d574a..f7bc88f70d 100644 --- a/app/Http/Controllers/API/GroupController.php +++ b/app/Http/Controllers/API/GroupController.php @@ -86,8 +86,6 @@ public static function getGroupsByUsersNetworks(Request $request) // New Collection Instance $collection = collect([]); - $countries = array_flip(\App\Helpers\Fixometer::getAllCountries()); - foreach ($groups as $group) { // If we have a bounding box, check that the group is within it. if (! $bbox || ( @@ -102,7 +100,8 @@ public static function getGroupsByUsersNetworks(Request $request) 'timezone' => $group->timezone, 'location' => [ 'value' => $group->location, - 'country' => Fixometer::translateCountry($group->country_code, $countries), + 'country' => Fixometer::getCountryFromCountryCode($group->country_code), + 'country_code' => $group->country_code, 'latitude' => $group->latitude, 'longitude' => $group->longitude, 'area' => $group->area, diff --git a/app/Http/Controllers/GroupController.php b/app/Http/Controllers/GroupController.php index c2b30cbdc9..a6efa117e8 100644 --- a/app/Http/Controllers/GroupController.php +++ b/app/Http/Controllers/GroupController.php @@ -483,8 +483,6 @@ public static function expandGroups($groups, $your_groupids, $nearby_groupids) $user = Auth::user(); if ($groups) { - $countries = array_flip(Fixometer::getAllCountries('en')); - foreach ($groups as $group) { $group_image = $group->groupImage; @@ -513,7 +511,8 @@ public static function expandGroups($groups, $your_groupids, $nearby_groupids) asset('uploads/mid_'.$group_image->image->path) : null, 'location' => [ 'location' => rtrim($group->location), - 'country' => Fixometer::translateCountry($group->country_code, $countries), + 'country' => Fixometer::getCountryFromCountryCode($group->country_code), + 'country_code' => $group->country_code, 'distance' => $distance, ], 'next_event' => $event ? $event->event_date_local : null, diff --git a/database/migrations/2023_06_12_153317_country_codes.php b/database/migrations/2023_06_12_153317_country_codes.php index aca8e40087..971f927281 100644 --- a/database/migrations/2023_06_12_153317_country_codes.php +++ b/database/migrations/2023_06_12_153317_country_codes.php @@ -51,6 +51,14 @@ public function up() */ public function down() { - // + Schema::table('groups', function (Blueprint $table) { + $table->dropColumn('country_code'); + }); + + Schema::table('users', function (Blueprint $table) { + $table->renameColumn('country_code', 'country'); + }); + + DB::update(DB::raw("UPDATE users SET country = 'GBR' WHERE country = 'GB'")); } }; diff --git a/tests/Feature/Networks/NetworkTest.php b/tests/Feature/Networks/NetworkTest.php index 9b31092927..26415767b0 100644 --- a/tests/Feature/Networks/NetworkTest.php +++ b/tests/Feature/Networks/NetworkTest.php @@ -93,6 +93,8 @@ public function admins_can_associate_group_to_network() $group = Group::factory()->create([ 'latitude' => 51.5074, 'longitude' => -0.1278, + 'country_code' => 'GB', + 'country' => 'United Kingdom', ]); $network = Network::factory()->create(); @@ -131,6 +133,8 @@ public function admins_can_associate_group_to_network() $this->assertEquals(1, count($groups)); $this->assertEquals($group->idgroups, $groups[0]['id']); $this->assertEquals($group->name, $groups[0]['name']); + $this->assertEquals($group->country, $groups[0]['location']['country']); + $this->assertEquals($group->country_code, $groups[0]['location']['country_code']); // Check that the event is listed. $this->assertEquals(1, count($groups[0]['past_parties'])); From 7e82537d9aef9aa2d5388c082e2240e66a2f99b0 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 10 Jul 2023 11:08:03 +0100 Subject: [PATCH 17/19] Group table filter bugs. --- resources/js/app.js | 28 +++++++++++++++++++ resources/js/components/GroupsTable.vue | 4 ++- .../js/components/GroupsTableFilters.vue | 3 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/resources/js/app.js b/resources/js/app.js index d9957f1692..548b772219 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -734,6 +734,34 @@ function initAutocomplete() { } }); + function removeUser() { + + var id = jQuery(this).data('remove-volunteer'); + + $.ajax({ + headers: { + 'X-CSRF-TOKEN': $("input[name='_token']").val() + }, + type: 'post', + url: '/party/remove-volunteer', + data: { + id : id, + }, + datatype: 'json', + success: function(json) { + if( json.success ){ + jQuery('.volunteer-' + id).fadeOut(); + } else { + alert('Something has gone wrong'); + } + }, + error: function(error) { + alert('Something has gone wrong'); + } + }); + + } + jQuery('.js-remove').on('click', removeUser); jQuery(document).on('click', '[data-toggle="lightbox"]', function (event) { event.preventDefault(); diff --git a/resources/js/components/GroupsTable.vue b/resources/js/components/GroupsTable.vue index cfdf3159af..5de4605c6b 100644 --- a/resources/js/components/GroupsTable.vue +++ b/resources/js/components/GroupsTable.vue @@ -207,7 +207,9 @@ export default { } if (this.searchLocation) { - match &= g.location.toLowerCase().indexOf(this.searchLocation.toLowerCase()) !== -1 + if (g.location && g.location.location) { + match &= g.location.location.toLowerCase().indexOf(this.searchLocation.toLowerCase()) !== -1 + } } if (this.searchCountry) { diff --git a/resources/js/components/GroupsTableFilters.vue b/resources/js/components/GroupsTableFilters.vue index 203376c5cc..6a3c71dfdf 100644 --- a/resources/js/components/GroupsTableFilters.vue +++ b/resources/js/components/GroupsTableFilters.vue @@ -21,6 +21,7 @@ class="m-0 mb-1 mb-md-0" allow-empty :selectedLabel="__('partials.remove')" + open-direction="bottom" /> From e701f746150e4cbe932cdf00b9c6acd6e229525d Mon Sep 17 00:00:00 2001 From: Neil Mather Date: Tue, 1 Aug 2023 15:47:49 +0100 Subject: [PATCH 18/19] Escape group keyword --- database/migrations/2023_06_12_153317_country_codes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2023_06_12_153317_country_codes.php b/database/migrations/2023_06_12_153317_country_codes.php index 971f927281..789b2a855c 100644 --- a/database/migrations/2023_06_12_153317_country_codes.php +++ b/database/migrations/2023_06_12_153317_country_codes.php @@ -30,7 +30,7 @@ public function up() $table->string('country_code', 2)->after('area')->nullable(); }); - $groups = DB::select(DB::raw('SELECT idgroups, country FROM groups')); + $groups = DB::select(DB::raw('SELECT idgroups, country FROM `groups`')); foreach ($groups as $g) { // Countries are stored in English. From b81db471f8053838515ab84bf2a00121532771cb Mon Sep 17 00:00:00 2001 From: Neil Mather Date: Tue, 1 Aug 2023 15:52:45 +0100 Subject: [PATCH 19/19] Use country name matching results from geocoder --- lang/en/countries.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/en/countries.php b/lang/en/countries.php index cd01f65f61..5f1ce2e37e 100644 --- a/lang/en/countries.php +++ b/lang/en/countries.php @@ -119,7 +119,7 @@ 'KE' => 'Kenya', 'KI' => 'Kiribati', 'KP' => "Korea, Democratic People's Republic of", - 'KR' => 'Korea, Republic of', + 'KR' => 'South Korea', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => "Lao People's Democratic Republic", @@ -250,4 +250,4 @@ 'YE' => 'Yemen', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', -]; \ No newline at end of file +];