Skip to content

Commit

Permalink
Merge branch 'release/v2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
appsol committed May 14, 2024
2 parents 9995d62 + 469834e commit c124b30
Show file tree
Hide file tree
Showing 41 changed files with 755 additions and 221 deletions.
2 changes: 1 addition & 1 deletion app/Docs/ExternalDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public static function create(string $objectId = null): BaseObject
{
return parent::create($objectId)
->description('GitHub Wiki')
->url('https://github.com/LondonBoroughSutton/helpyourselfsutton-api/wiki');
->url('https://github.com/Connected-Places/api/wiki');
}
}
2 changes: 1 addition & 1 deletion app/Docs/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function create(string $objectId = null): BaseObject
->version('v1')
->contact(
Contact::create()
->name('Ayup Digital')
->name('Ayup Connect')
->url('https://ayup.agency')
);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Docs/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ public static function create(string $objectId = null): BaseObject
Tags\TaxonomyOrganisationsTag::create(),
Tags\UpdateRequestsTag::create(),
Tags\UsersTag::create()
)
->externalDocs(ExternalDocs::create());
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ public static function create(string $objectId = null): BaseObject
StartsAfterParameter::create(),
EndsBeforeParameter::create(),
EndsAfterParameter::create(),
FilterParameter::create(null, 'wheelchair')
FilterParameter::create(null, 'has_wheelchair_access')
->description('Has a wheelchair accessible location')
->schema(
Schema::boolean()
),
FilterParameter::create(null, 'induction-loop')
FilterParameter::create(null, 'has_induction_loop')
->description('Has a location with an induction loop')
->schema(
Schema::boolean()
),
FilterParameter::create(null, 'has_accessible_toilet')
->description('Has a location with an accessible toilet')
->schema(
Schema::boolean()
),
FilterParameter::create(null, 'organisation_id')
->description('Comma separated list of organisation IDs to filter by')
->schema(
Expand Down
1 change: 0 additions & 1 deletion app/Docs/Schemas/Organisation/UpdateOrganisationSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static function create(string $objectId = null): BaseObject
'name',
'slug',
'description',
'url'
)
->properties(
Schema::string('name'),
Expand Down
1 change: 0 additions & 1 deletion app/Docs/Schemas/Page/PageListItemSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static function create(string $objectId = null): BaseObject
Schema::string('slug'),
Schema::string('title'),
Schema::string('excerpt'),
Schema::string('content'),
Schema::integer('order'),
Schema::boolean('enabled'),
Schema::string('page_type')
Expand Down
2 changes: 2 additions & 0 deletions app/Docs/Schemas/Page/PageSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static function create(string $objectId = null): BaseObject
PageListItemSchema::create('parent'),
Schema::array('children')
->items(PageListItemSchema::create()),
Schema::array('ancestors')
->items(PageListItemSchema::create()),
Schema::array('collection_categories')
->items(CollectionCategorySchema::create()),
Schema::array('collection_personas')
Expand Down
3 changes: 0 additions & 3 deletions app/Docs/Schemas/Service/UpdateServiceSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public static function create(string $objectId = null): BaseObject
'fees_url',
'testimonial',
'video_embed',
'url',
'contact_name',
'contact_phone',
'contact_email',
'show_referral_disclaimer',
'referral_method',
'referral_button_text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function index(IndexRequest $request): AnonymousResourceCollection
AllowedFilter::scope('ends_after'),
AllowedFilter::scope('has_wheelchair_access', 'hasWheelchairAccess'),
AllowedFilter::scope('has_induction_loop', 'hasInductionLoop'),
AllowedFilter::scope('has_accessible_toilet', 'hasAccessibleToilet'),
AllowedFilter::scope('collections', 'inCollections'),
AllowedFilter::custom('has_permission', new HasPermissionFilter()),
])
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Core/V1/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function index(IndexRequest $request): AnonymousResourceCollection
->allowedIncludes([
'parent',
'children',
'ancestors',
AllowedInclude::relationship('landingPageAncestors', 'landingPageAncestors'),
])
->allowedFilters([
Expand Down Expand Up @@ -82,7 +83,7 @@ public function store(StoreRequest $request, PagePersistenceService $persistence

event(EndpointHit::onCreate($request, "Created page [{$entity->id}]", $entity));

$entity->load('landingPageAncestors', 'parent', 'children', 'collectionCategories', 'collectionPersonas');
$entity->load('landingPageAncestors', 'parent', 'children', 'ancestors', 'collectionCategories', 'collectionPersonas');

return new PageResource($entity);
}
Expand All @@ -93,7 +94,7 @@ public function store(StoreRequest $request, PagePersistenceService $persistence
public function show(ShowRequest $request, Page $page): PageResource
{
$baseQuery = Page::query()
->with(['landingPageAncestors', 'parent', 'children', 'collectionCategories', 'collectionPersonas'])
->with(['landingPageAncestors', 'parent', 'children', 'ancestors', 'collectionCategories', 'collectionPersonas'])
->where('id', $page->id);

$page = QueryBuilder::for($baseQuery)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Core/V1/Service/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function validateSpreadsheet(string $filePath)
),
],
'intro' => ['required', 'string', 'min:1', 'max:300'],
'description' => ['required', 'string', new MarkdownMinLength(1), new MarkdownMaxLength(1600)],
'description' => ['required', 'string', new MarkdownMinLength(1), new MarkdownMaxLength(config('local.service_description_max_chars'))],
'wait_time' => ['present', 'nullable', Rule::in([
Service::WAIT_TIME_ONE_WEEK,
Service::WAIT_TIME_TWO_WEEKS,
Expand Down
8 changes: 7 additions & 1 deletion app/Http/Filters/Organisation/HasPermissionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ class HasPermissionFilter implements Filter
{
public function __invoke(Builder $query, $value, string $property): Builder
{
$organisationIds = [];
$user = request()->user('api');

// If Global or Super Admin, apply no filter
if ($user && $user->isGlobalAdmin()) {
return $query;
}

$organisationIds = [];

if ($user) {
$userOrganisationIds = $user->organisations()
->pluck(table(Organisation::class, 'id'))
Expand Down
8 changes: 7 additions & 1 deletion app/Http/Filters/OrganisationEvent/HasPermissionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ class HasPermissionFilter implements Filter
{
public function __invoke(Builder $query, $value, string $property): Builder
{
$organisationIds = [];
$user = request()->user('api');

// If Global or Super Admin, apply no filter
if ($user && $user->isGlobalAdmin()) {
return $query;
}

$organisationIds = [];

if ($user && $user->isOrganisationAdmin()) {
$organisationIds = $user->organisations()
->pluck(table(Organisation::class, 'id'))
Expand Down
13 changes: 10 additions & 3 deletions app/Http/Filters/Service/HasPermissionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ class HasPermissionFilter implements Filter
{
public function __invoke(Builder $query, $value, string $property): Builder
{
$serviceIds = request()->user('api')
? request()->user('api')->services()->pluck(table(Service::class, 'id'))->toArray()
: [];
$user = request()->user('api');

// If Global or Super Admin, apply no filter
if ($user && $user->isGlobalAdmin()) {
return $query;
}

$serviceIds = $user
? $user->services()->pluck(table(Service::class, 'id'))->toArray()
: [];

return $query->whereIn(table(Service::class, 'id'), $serviceIds);
}
Expand Down
9 changes: 8 additions & 1 deletion app/Http/Requests/Organisation/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use App\Models\Taxonomy;
use App\Rules\FileIsMimeType;
use App\Rules\FileIsPendingAssignment;
use App\Rules\MarkdownMaxLength;
use App\Rules\MarkdownMinLength;
use App\Rules\RootTaxonomyIs;
use App\Rules\Slug;
use App\Rules\UkPhoneNumber;
Expand Down Expand Up @@ -46,7 +48,12 @@ public function rules(): array
new Slug(),
],
'name' => ['required', 'string', 'min:1', 'max:255'],
'description' => ['required', 'string', 'min:1', 'max:10000'],
'description' => [
'required',
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(config('local.organisation_description_max_chars'), 'Description tab - The long description must be ' . config('local.organisation_description_max_chars') . ' characters or fewer.'),
],
'url' => ['present', 'nullable', 'url', 'max:255'],
'email' => ['present', 'nullable', 'email', 'max:255'],
'phone' => [
Expand Down
21 changes: 10 additions & 11 deletions app/Http/Requests/Organisation/UpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
use App\Rules\CanUpdateCategoryTaxonomyRelationships;
use App\Rules\FileIsMimeType;
use App\Rules\FileIsPendingAssignment;
use App\Rules\NullableIf;
use App\Rules\MarkdownMaxLength;
use App\Rules\MarkdownMinLength;
use App\Rules\RootTaxonomyIs;
use App\Rules\Slug;
use App\Rules\UkPhoneNumber;
Expand Down Expand Up @@ -48,24 +49,22 @@ public function rules(): array
new Slug(),
],
'name' => ['string', 'min:1', 'max:255'],
'description' => ['string', 'min:1', 'max:10000'],
'description' => [
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(config('local.organisation_description_max_chars'), 'Description tab - The long description must be ' . config('local.organisation_description_max_chars') . ' characters or fewer.'),
],
'url' => [
new NullableIf(function () {
return $this->user()->isGlobalAdmin();
}),
'nullable',
'url',
'max:255'],
'email' => [
new NullableIf(function () {
return $this->user()->isGlobalAdmin() || $this->input('phone', $this->organisation->phone) !== null;
}),
'nullable',
'email',
'max:255',
],
'phone' => [
new NullableIf(function () {
return $this->user()->isGlobalAdmin() || $this->input('email', $this->organisation->email) !== null;
}),
'nullable',
'string',
'min:1',
'max:255',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/OrganisationEvent/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ($attribute, $value, $fail) {
'required',
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(3000, 'Description tab - The long description must be 3000 characters or fewer.'),
new MarkdownMaxLength(config('local.event_description_max_chars'), 'Description tab - The long description must be ' . config('local.event_description_max_chars') . ' characters or fewer.'),
],
'is_free' => ['required', 'boolean'],
'fees_text' => [
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/OrganisationEvent/UpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function rules(): array
'description' => [
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(3000, 'Description tab - The long description must be 3000 characters or fewer.'),
new MarkdownMaxLength(config('local.event_description_max_chars'), 'Description tab - The long description must be ' . config('local.event_description_max_chars') . ' characters or fewer.'),
],
'is_free' => ['boolean'],
'fees_text' => ['nullable', 'string', 'min:1', 'max:255', 'required_if:is_free,false'],
Expand Down
24 changes: 13 additions & 11 deletions app/Http/Requests/OrganisationSignUpForm/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,23 @@ public function rules(): array
new Slug(),
],
'organisation.name' => ['required_without:organisation.id', 'nullable', 'string', 'min:1', 'max:255'],
'organisation.description' => ['required_without:organisation.id', 'nullable', 'string', 'min:1', 'max:10000'],
'organisation.url' => ['required_without:organisation.id', 'nullable', 'url', 'max:255'],
'organisation.description' => [
'required_without:organisation.id',
'nullable',
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(config('local.organisation_description_max_chars'), 'Description tab - The long description must be ' . config('local.organisation_description_max_chars') . ' characters or fewer.'),
],
'organisation.url' => ['sometimes', 'nullable', 'url', 'max:255'],
'organisation.email' => [
'sometimes',
'nullable',
'required_without_all:organisation.id,organisation.phone',
'email',
'max:255',
],
'organisation.phone' => [
'sometimes',
'nullable',
'required_without_all:organisation.id,organisation.email',
'string',
'min:1',
'max:255',
Expand Down Expand Up @@ -121,7 +127,7 @@ public function rules(): array
'required',
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(3000),
new MarkdownMaxLength(config('local.service_description_max_chars'), 'Description tab - The long description must be ' . config('local.service_description_max_chars') . ' characters or fewer.'),
],
'service.wait_time' => ['sometimes', 'present', 'nullable', Rule::in([
Service::WAIT_TIME_ONE_WEEK,
Expand All @@ -135,7 +141,7 @@ public function rules(): array
'service.fees_url' => ['sometimes', 'present', 'nullable', 'url', 'max:255'],
'service.testimonial' => ['sometimes', 'present', 'nullable', 'string', 'min:1', 'max:255'],
'service.video_embed' => ['sometimes', 'present', 'nullable', 'url', 'max:255', new VideoEmbed()],
'service.url' => ['sometimes', 'required', 'url', 'max:255'],
'service.url' => ['sometimes', 'present', 'nullable', 'url', 'max:255'],
'service.contact_name' => ['sometimes', 'present', 'nullable', 'string', 'min:1', 'max:255'],
'service.contact_phone' => ['sometimes', 'present', 'nullable', 'string', 'min:1', 'max:255'],
'service.contact_email' => ['sometimes', 'present', 'nullable', 'email', 'max:255'],
Expand All @@ -151,7 +157,7 @@ public function rules(): array
'required_with:service.useful_infos.*',
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(10000),
new MarkdownMaxLength(config('local.useful_info_description_max_chars')),
],
'service.useful_infos.*.order' => [
'required_with:service.useful_infos.*',
Expand Down Expand Up @@ -210,18 +216,14 @@ public function messages(): array
'organisation.slug.unique' => '3. Organisation - The organisation is already listed. Please contact us for help logging in ' . config('local.global_admin.email') . '.',
'organisation.name.required' => '3. Organisation - Please enter the organisation name.',
'organisation.description.required' => '3. Organisation - Please enter a one-line summary of the organisation.',
'organisation.url.required' => '3. Organisation - Please enter a valid web address in the correct format (starting with https:// or http://).',
'organisation.url.url' => '3. Organisation - Please enter a valid web address in the correct format (starting with https:// or http://).',
'organisation.email.required_without' => '3. Organisation - Please enter a public email address and/or a public phone number.',
'organisation.phone.required_without' => '3. Organisation - Please enter a public phone number and/or public email address.',
'organisation.email.email' => '3. Organisation - Please enter the email for your organisation (eg. [email protected]).',

'service.slug.required' => "4. Service, Details tab - Please enter the name of your {$type}.",
'service.name.required' => "4. Service, Details tab - Please enter the name of your {$type}.",
'service.video_embed.url' => '4. Service, Additional info tab - Please enter a valid video link (eg. https://www.youtube.com/watch?v=JyHR_qQLsLM).',
'service.intro.required' => "4. Service, Description tab - Please enter a brief description of the {$type}.",
'service.description.required' => "4. Service, Description tab - Please enter all the information someone should know about your {$type}.",
'service.url.required' => "4. Service, Details tab - Please provide the web address for your {$type}.",
'service.url.url' => '4. Service, Details tab - Please enter a valid web address in the correct format (starting with https:// or http://).',
'service.contact_email.email' => "4. Service, Additional Info tab - Please enter an email address users can use to contact your {$type} (eg. [email protected]).",
];
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Requests/Service/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function ($attribute, $value, $fail) {
'required',
'string',
new MarkdownMinLength(1),
new MarkdownMaxLength(3000, 'Description tab - The long description must be 3000 characters or fewer.'),
new MarkdownMaxLength(config('local.service_description_max_chars'), 'Description tab - The long description must be ' . config('local.service_description_max_chars') . ' characters or fewer.'),
],
'wait_time' => ['present', 'nullable', Rule::in([
Service::WAIT_TIME_ONE_WEEK,
Expand All @@ -99,7 +99,7 @@ function ($attribute, $value, $fail) {
'fees_url' => ['present', 'nullable', 'url', 'max:255'],
'testimonial' => ['present', 'nullable', 'string', 'min:1', 'max:255'],
'video_embed' => ['present', 'nullable', 'url', 'max:255', new VideoEmbed()],
'url' => ['required', 'url', 'max:255'],
'url' => ['present', 'nullable', 'url', 'max:255'],
'contact_name' => ['present', 'nullable', 'string', 'min:1', 'max:255'],
'contact_phone' => [
'present',
Expand Down Expand Up @@ -188,7 +188,7 @@ function ($attribute, $value, $fail) {
'useful_infos' => ['present', 'array'],
'useful_infos.*' => ['array'],
'useful_infos.*.title' => ['required_with:useful_infos.*', 'string', 'min:1', 'max:255'],
'useful_infos.*.description' => ['required_with:useful_infos.*', 'string', new MarkdownMinLength(1), new MarkdownMaxLength(10000)],
'useful_infos.*.description' => ['required_with:useful_infos.*', 'string', new MarkdownMinLength(1), new MarkdownMaxLength(config('local.useful_info_description_max_chars'))],
'useful_infos.*.order' => ['required_with:useful_infos.*', 'integer', 'min:1', new InOrder(array_pluck_multi($this->useful_infos, 'order'))],

'offerings' => ['present', 'array'],
Expand Down
Loading

0 comments on commit c124b30

Please sign in to comment.