Skip to content

Commit

Permalink
Merge branch 'develop' into RES-1885_vue_event_create_edit
Browse files Browse the repository at this point in the history
# Conflicts:
#	resources/js/app.js
  • Loading branch information
edwh committed Aug 2, 2023
2 parents c8fe687 + 1abc978 commit 88a79e3
Show file tree
Hide file tree
Showing 97 changed files with 359 additions and 894 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/CheckGroupLocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/CheckTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function handle()
// This is probably a special case used for form validation. It throws up many errors, and these
// are at best not visible and at worst not too bad given that they only occur in error cases. So
// ignore it.
} else if ($file == 'countries.php') {
// This is a special case used for country names.
} else if ($file == 'pagination.php') {
// This is probably a special case used for paging through data.
} else if (strpos($file, '-audits')) {
Expand Down
45 changes: 0 additions & 45 deletions app/Console/Commands/FixLatitudeLongitude.php

This file was deleted.

39 changes: 39 additions & 0 deletions app/Console/Commands/GroupCountryField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Console\Commands;

use App\Group;
use App\Helpers\Fixometer;
use Illuminate\Console\Command;

class GroupCountryField extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'groups:country';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Set the group country field from the country_code field';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$groups = Group::all();

foreach ($groups as $group) {
$group->country = Fixometer::getCountryFromCountryCode($group->country_code);
$group->save();
}
}
}
4 changes: 2 additions & 2 deletions app/Console/Commands/ImportGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion app/Console/Commands/SyncEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use App\Group;
use App\Helpers\Fixometer;
use App\Party;
use DateTime;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -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],
Expand Down
3 changes: 2 additions & 1 deletion app/Console/Commands/SyncGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use App\Group;
use App\Helpers\Fixometer;
use Illuminate\Console\Command;

class SyncGroups extends Command
Expand Down Expand Up @@ -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],
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ protected function schedule(Schedule $schedule)
->daily()
->sendOutputTo(storage_path().'/logs/discourse_usernames.log')
->emailOutputTo(env('SEND_COMMAND_LOGS_TO'), '[email protected]');

$schedule->command('groups:country')->hourly();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Group extends Model implements Auditable
'postcode',
'latitude',
'longitude',
'country',
'country_code',
'free_text',
'facebook',
'wordpress_post_id',
Expand Down
4 changes: 2 additions & 2 deletions app/Helpers/Geocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/API/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ function ($attribute, $value, $fail) use ($request) {
$geocoded = $geocoder->geocode($location);

if (empty($geocoded)) {
throw ValidationException::withMessages(['location ' => __('groups.geocode_failed')]);
throw ValidationException::withMessages(['location ' => __('events.geocode_failed')]);
}

$latitude = $geocoded['latitude'];
Expand Down
15 changes: 7 additions & 8 deletions app/Http/Controllers/API/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 || (
Expand All @@ -102,7 +100,8 @@ public static function getGroupsByUsersNetworks(Request $request)
'timezone' => $group->timezone,
'location' => [
'value' => $group->location,
'country' => Fixometer::translateCountry($group->country, $countries),
'country' => Fixometer::getCountryFromCountryCode($group->country_code),
'country_code' => $group->country_code,
'latitude' => $group->latitude,
'longitude' => $group->longitude,
'area' => $group->area,
Expand Down Expand Up @@ -606,7 +605,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,
Expand Down Expand Up @@ -750,7 +749,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,
Expand Down Expand Up @@ -875,7 +874,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')]);
Expand All @@ -895,7 +894,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(
Expand All @@ -909,7 +908,7 @@ private function validateGroupParams(Request $request, $create): array {
$timezone,
$latitude,
$longitude,
$country,
$country_code,
$network_data,
);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/API/UserGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 88a79e3

Please sign in to comment.