Skip to content

Commit

Permalink
Merge pull request #341 from canyongbs/develop
Browse files Browse the repository at this point in the history
1.0-rc10
  • Loading branch information
Orrison authored Dec 7, 2023
2 parents 15b3870 + 30d5a1d commit c41adb6
Show file tree
Hide file tree
Showing 214 changed files with 8,134 additions and 730 deletions.
311 changes: 300 additions & 11 deletions _ide_helper_models.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

/*
<COPYRIGHT>
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved.
Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace Assist\Application\Database\Factories;

use Assist\Prospect\Models\Prospect;
use Illuminate\Support\Facades\Hash;
use Assist\Application\Models\Application;
use Assist\AssistDataModel\Models\Student;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Relations\Relation;

/**
* @extends Factory<Application>
*/
class ApplicationAuthenticationFactory extends Factory
{
public function definition(): array
{
return [
'author_type' => fake()->randomElement([
(new Student())->getMorphClass(),
(new Prospect())->getMorphClass(),
]),
'author_id' => function (array $attributes) {
$senderClass = Relation::getMorphedModel($attributes['author_type']);

/** @var Student|Prospect $senderModel */
$senderModel = new $senderClass();

$sender = $senderClass === Student::class
? Student::inRandomOrder()->first() ?? Student::factory()->create()
: $senderModel::factory()->create();

return $sender->getKey();
},
'code' => Hash::make(random_int(100000, 999999)),
'application_id' => Application::factory(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
*/
class ApplicationSubmissionFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
Expand Down
7 changes: 6 additions & 1 deletion app-modules/application/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@

use Assist\Application\Http\Controllers\ApplicationWidgetController;
use Assist\Form\Http\Middleware\EnsureSubmissibleIsEmbeddableAndAuthorized;
use Assist\Application\Http\Middleware\EnsureOnlineAdmissionsFeatureIsActive;

Route::prefix('api')
->middleware(['api', EnsureSubmissibleIsEmbeddableAndAuthorized::class . ':application'])
->middleware([
'api',
EnsureOnlineAdmissionsFeatureIsActive::class,
EnsureSubmissibleIsEmbeddableAndAuthorized::class . ':application',
])
->group(function () {
Route::prefix('applications')
->name('applications.')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
<COPYRIGHT>
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved.
Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace Assist\Application\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use App\Settings\LicenseSettings;
use Symfony\Component\HttpFoundation\Response;

class EnsureOnlineAdmissionsFeatureIsActive
{
public function handle(Request $request, Closure $next): Response
{
if (! app(LicenseSettings::class)->data->addons->onlineAdmissions) {
return response()->json(['error' => 'Online Admissions is not enabled.'], 403);
}

return $next($request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
<COPYRIGHT>
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved.
Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace Assist\Application\Listeners;

use Assist\Prospect\Models\Prospect;
use Assist\AssistDataModel\Models\Student;
use Illuminate\Contracts\Queue\ShouldQueue;
use Assist\Notifications\Models\Subscription;
use Assist\Application\Events\ApplicationSubmissionCreated;
use Assist\Application\Notifications\AuthorLinkedApplicationSubmissionCreatedNotification;

class NotifySubscribersOfApplicationSubmission implements ShouldQueue
{
public function handle(ApplicationSubmissionCreated $event): void
{
/** @var Student|Prospect|null $author */
$author = $event->submission->author;

$author?->subscriptions?->each(function (Subscription $subscription) use ($event) {
$subscription->user->notify(new AuthorLinkedApplicationSubmissionCreatedNotification(submission: $event->submission));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

/*
<COPYRIGHT>
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved.
Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace Assist\Application\Notifications;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Filament\Facades\Filament;
use Illuminate\Support\HtmlString;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Assist\Application\Models\ApplicationSubmission;
use Filament\Notifications\Notification as FilamentNotification;

class AuthorLinkedApplicationSubmissionCreatedNotification extends Notification implements ShouldQueue
{
use Queueable;

public function __construct(public ApplicationSubmission $submission) {}

public function via(User $notifiable): array
{
return ['database'];
}

public function toDatabase(User $notifiable): array
{
$author = $this->submission->author;

$name = $author->{$author->displayNameKey()};

$target = resolve(Filament::getModelResource($author));

$applicationSubmissionUrl = $target::getUrl('manage-application-submissions', ['record' => $author]);

$applicationSubmissionLink = new HtmlString("<a href='{$applicationSubmissionUrl}' target='_blank' class='underline'>application submission</a>");

$morph = str($author->getMorphClass());

$morphUrl = $target::getUrl('view', ['record' => $author]);

$morphLink = new HtmlString("<a href='{$morphUrl}' target='_blank' class='underline'>{$name}</a>");

return FilamentNotification::make()
->warning()
->title("An {$applicationSubmissionLink} has been submitted by {$morph} {$morphLink}")
->getDatabaseMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace Assist\Application\Observers;

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
use Assist\Application\Models\ApplicationSubmission;
use Assist\Application\Events\ApplicationSubmissionCreated;
Expand All @@ -47,5 +48,12 @@ public function created(ApplicationSubmission $submission): void
Event::dispatch(
event: new ApplicationSubmissionCreated(submission: $submission)
);

if (! is_null($submission->author)) {
Cache::tags('application-submission-count')
->forget(
"application-submission-count-{$submission->author->getKey()}"
);
}
}
}
12 changes: 11 additions & 1 deletion app-modules/application/src/Policies/ApplicationPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@
namespace Assist\Application\Policies;

use App\Models\User;
use App\Enums\Feature;
use Illuminate\Auth\Access\Response;
use Assist\Application\Models\Application;
use App\Concerns\FeatureAccessEnforcedPolicyBefore;
use App\Policies\Contracts\FeatureAccessEnforcedPolicy;

class ApplicationPolicy
class ApplicationPolicy implements FeatureAccessEnforcedPolicy
{
use FeatureAccessEnforcedPolicyBefore;

public function viewAny(User $user): Response
{
return $user->canOrElse(
Expand Down Expand Up @@ -97,4 +102,9 @@ public function forceDelete(User $user, Application $application): Response
denyResponse: 'You do not have permission to permanently delete this application.'
);
}

protected function requiredFeatures(): array
{
return [Feature::OnlineAdmissions];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
namespace Assist\Application\Providers;

use Filament\Panel;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Assist\Application\ApplicationPlugin;
use Assist\Application\Models\Application;
Expand All @@ -47,7 +48,9 @@
use Illuminate\Database\Eloquent\Relations\Relation;
use Assist\Application\Models\ApplicationAuthentication;
use Assist\Authorization\AuthorizationPermissionRegistry;
use Assist\Application\Events\ApplicationSubmissionCreated;
use Assist\Application\Observers\ApplicationSubmissionObserver;
use Assist\Application\Listeners\NotifySubscribersOfApplicationSubmission;

class ApplicationServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -78,11 +81,10 @@ public function registerObservers(): void

public function registerEvents(): void
{
//Event::listen(
// events: ApplicationSubmissionCreated::class,
// // TODO: Swap out for the correct listener
// listener: NotifySubscribersOfFormSubmission::class
//);
Event::listen(
events: ApplicationSubmissionCreated::class,
listener: NotifySubscribersOfApplicationSubmission::class
);
}

protected function registerRolesAndPermissions()
Expand Down
Loading

0 comments on commit c41adb6

Please sign in to comment.