From 8d4b15636d8c324e120c8c36964bdb47801bae9e Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 7 Oct 2024 10:01:10 +0300 Subject: [PATCH 1/6] Fixed tests --- .../CrowdSourcingProjectControllerTest.php | 40 ++++++++++++------- .../Controllers/FileControllerTest.php | 5 --- .../QuestionnaireReportControllerTest.php | 5 --- .../QuestionnaireResponseControllerTest.php | 5 --- .../QuestionnaireStatisticsControllerTest.php | 5 --- .../Controllers/UserControllerTest.php | 16 -------- tests/TestCase.php | 17 +++++++- .../QuestionnaireAnswerVoteRepositoryTest.php | 1 - 8 files changed, 41 insertions(+), 53 deletions(-) diff --git a/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php b/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php index 5dc8800a..de18595d 100644 --- a/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php +++ b/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php @@ -298,13 +298,18 @@ public function guestCannotStoreProject() { public function nonAdminUserCannotStoreProject() { $user = User::factory()->create(); $this->be($user); - + $faker = Faker::create(); + // we need a name with no special characters + $name = $faker->name; + $slug = str_replace(' ', '-', strtolower($name)); + // remove dots from the slug + $slug = str_replace('.', '', $slug); $response = $this->withoutMiddleware(VerifyCsrfToken::class) // Disable CSRF only ->post(route('projects.store'), [ - 'name' => 'Test Project ' . rand(1, 100), + 'name' => $name, 'description' => 'Test Description', 'status_id' => 1, - 'slug' => 'test-project-' . rand(1, 100), + 'slug' => $slug, 'language_id' => 1, ]); @@ -321,13 +326,15 @@ public function adminCanStoreProjectWithValidData() { $this->be($user); $faker = Faker::create(); + $name = $faker->name; + $slug = str_replace(' ', '-', strtolower($name)); $response = $this->withoutMiddleware(VerifyCsrfToken::class) ->post(route('projects.store'), [ - 'name' => 'Valid Project', + 'name' => $name, 'description' => 'Valid Description', 'status_id' => 1, - 'slug' => 'valid-project', + 'slug' => $slug, 'language_id' => 1, 'color_ids' => [1], 'color_names' => [$faker->name], @@ -338,10 +345,10 @@ public function adminCanStoreProjectWithValidData() { $response->assertStatus(302); $response->assertSessionHas('flash_message_success', 'The project has been successfully created'); $this->assertDatabaseHas('crowd_sourcing_projects', [ - 'slug' => 'valid-project', + 'slug' => $slug, ]); $this->assertDatabaseHas('crowd_sourcing_project_translations', [ - 'name' => 'Valid Project', + 'name' => $name, 'description' => 'Valid Description', ]); } @@ -416,12 +423,15 @@ public function authenticatedUserCannotUpdateProject() { $this->be($user); $project = CrowdSourcingProject::factory()->create(); - + $faker = Faker::create(); + $name = $faker->name; + $slug = str_replace(' ', '-', strtolower($name)); + $slug = str_replace('.', '', $slug); $response = $this->withoutMiddleware(VerifyCsrfToken::class)->put(route('projects.update', ['project' => $project->id]), [ - 'name' => 'Updated Project', + 'name' => $name, 'description' => 'Updated Description', 'status_id' => 1, - 'slug' => 'updated-project', + 'slug' => $slug, 'language_id' => 1, ]); @@ -439,11 +449,13 @@ public function adminCanUpdateProjectWithValidData() { $project = CrowdSourcingProject::factory()->create(); $faker = Faker::create(); + $name = $faker->name; + $slug = str_replace(' ', '-', strtolower($name)); $response = $this->withoutMiddleware(VerifyCsrfToken::class)->put(route('projects.update', ['project' => $project->id]), [ - 'name' => 'Updated Project', + 'name' => $name, 'description' => 'Updated Description', 'status_id' => 1, - 'slug' => 'updated-project', + 'slug' => $slug, 'language_id' => 1, 'color_ids' => [1], 'color_names' => [$faker->name], @@ -455,11 +467,11 @@ public function adminCanUpdateProjectWithValidData() { $response->assertSessionHas('flash_message_success', 'The project has been successfully updated'); $this->assertDatabaseHas('crowd_sourcing_projects', [ 'id' => $project->id, - 'slug' => 'updated-project', + 'slug' => $slug, ]); $this->assertDatabaseHas('crowd_sourcing_project_translations', [ 'project_id' => $project->id, - 'name' => 'Updated Project', + 'name' => $name, 'description' => 'Updated Description', ]); } diff --git a/tests/Feature/Controllers/FileControllerTest.php b/tests/Feature/Controllers/FileControllerTest.php index a01d8b86..8f98292a 100644 --- a/tests/Feature/Controllers/FileControllerTest.php +++ b/tests/Feature/Controllers/FileControllerTest.php @@ -3,16 +3,11 @@ namespace Tests\Feature\Controllers; use App\Http\Middleware\VerifyCsrfToken; -use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; use Tests\TestCase; class FileControllerTest extends TestCase { - use RefreshDatabase; - - protected $seed = true; - /** @test */ public function uploadFilesSuccessfullyUploadsFiles() { Storage::fake('s3'); diff --git a/tests/Feature/Controllers/Questionnaire/QuestionnaireReportControllerTest.php b/tests/Feature/Controllers/Questionnaire/QuestionnaireReportControllerTest.php index 5530fdc7..165c884d 100644 --- a/tests/Feature/Controllers/Questionnaire/QuestionnaireReportControllerTest.php +++ b/tests/Feature/Controllers/Questionnaire/QuestionnaireReportControllerTest.php @@ -9,14 +9,9 @@ use App\Repository\Questionnaire\QuestionnaireRepository; use Exception; use Illuminate\Database\QueryException; -use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class QuestionnaireReportControllerTest extends TestCase { - use RefreshDatabase; - - protected $seed = true; - /** @test */ public function viewReportsPageReturnsCorrectView() { $user = User::factory() diff --git a/tests/Feature/Controllers/Questionnaire/QuestionnaireResponseControllerTest.php b/tests/Feature/Controllers/Questionnaire/QuestionnaireResponseControllerTest.php index 1a4e270a..7d47361d 100644 --- a/tests/Feature/Controllers/Questionnaire/QuestionnaireResponseControllerTest.php +++ b/tests/Feature/Controllers/Questionnaire/QuestionnaireResponseControllerTest.php @@ -8,14 +8,9 @@ use App\Models\Questionnaire\Questionnaire; use App\Models\Questionnaire\QuestionnaireResponse; use App\Models\User; -use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class QuestionnaireResponseControllerTest extends TestCase { - use RefreshDatabase; - - protected $seed = true; - /** @test */ public function testStoreInvalidData() { $user = User::factory()->create(); diff --git a/tests/Feature/Controllers/Questionnaire/QuestionnaireStatisticsControllerTest.php b/tests/Feature/Controllers/Questionnaire/QuestionnaireStatisticsControllerTest.php index d27252f4..b8da749e 100644 --- a/tests/Feature/Controllers/Questionnaire/QuestionnaireStatisticsControllerTest.php +++ b/tests/Feature/Controllers/Questionnaire/QuestionnaireStatisticsControllerTest.php @@ -11,14 +11,9 @@ use App\Models\Questionnaire\Questionnaire; use App\Models\User; use App\Models\UserRole; -use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class QuestionnaireStatisticsControllerTest extends TestCase { - use RefreshDatabase; - - protected $seed = true; - /** @test */ public function showStatisticsPageForQuestionnaireReturnsCorrectView() { $user = User::factory()->create(); diff --git a/tests/Feature/Controllers/UserControllerTest.php b/tests/Feature/Controllers/UserControllerTest.php index 662038b7..6aee287b 100644 --- a/tests/Feature/Controllers/UserControllerTest.php +++ b/tests/Feature/Controllers/UserControllerTest.php @@ -10,7 +10,6 @@ use Tests\TestCase; class UserControllerTest extends TestCase { - use RefreshDatabase; protected $seed = true; @@ -103,21 +102,6 @@ public function patchHandlesInvalidDataCorrectly() { $response->assertSessionHasErrors(['password']); } - /** @test */ - public function cannotDeleteDeactivatesUserForNonAdminUser() { - $user = User::factory()->create(); - $this->be($user); - - $response = $this->withoutMiddleware(VerifyCsrfToken::class) - ->post(route('deleteUser'), ['id' => $user->id]); - - $response->assertStatus(403); - $this->assertDatabaseHas('users', [ - 'id' => $user->id, - 'deleted_at' => null, - ]); - } - /** @test */ public function deleteDeactivatesUserForAdminUser() { $user = User::factory() diff --git a/tests/TestCase.php b/tests/TestCase.php index e301d09b..f0f35221 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,12 +2,25 @@ namespace Tests; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Foundation\Testing\RefreshDatabaseState; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; + use RefreshDatabase; - protected function setUp(): void { - parent::setUp(); + protected function refreshTestDatabase() { + if (!RefreshDatabaseState::$migrated) { + // Run the database migrations specific to testing + $this->artisan('migrate:fresh', ['--env' => 'testing', '--database' => 'sqlite_testing']); + + // Run the database seeds specific to testing + $this->artisan('db:seed', ['--env' => 'testing', '--database' => 'sqlite_testing', '--class' => 'DatabaseSeeder']); + + RefreshDatabaseState::$migrated = true; + } + + $this->beginDatabaseTransaction(); } } diff --git a/tests/Unit/Repository/Questionnaire/QuestionnaireAnswerVoteRepositoryTest.php b/tests/Unit/Repository/Questionnaire/QuestionnaireAnswerVoteRepositoryTest.php index c38ad6db..ba4fcbb5 100644 --- a/tests/Unit/Repository/Questionnaire/QuestionnaireAnswerVoteRepositoryTest.php +++ b/tests/Unit/Repository/Questionnaire/QuestionnaireAnswerVoteRepositoryTest.php @@ -10,7 +10,6 @@ use Tests\TestCase; class QuestionnaireAnswerVoteRepositoryTest extends TestCase { - /** @test * @throws BindingResolutionException */ From 767f93c541841de3257041dde9d1d1b7945e72e8 Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 7 Oct 2024 11:45:23 +0300 Subject: [PATCH 2/6] Added the call-to-action button for problems, in the project landing page --- .../CrowdSourcingProjectManager.php | 21 ++++++++++--------- .../Problem/CrowdSourcingProjectProblem.php | 5 ++--- ...CrowdSourcingProjectProblemTranslation.php | 2 -- .../CrowdSourcingProjectProblemRepository.php | 10 +++++++++ .../CrowdSourcingProjectForLandingPage.php | 3 +++ resources/lang/bg/project-problems.php | 10 +++++++++ resources/lang/de/project-problems.php | 10 +++++++++ resources/lang/el/project-problems.php | 1 + resources/lang/en/project-problems.php | 1 + resources/lang/es/project-problems.php | 10 +++++++++ resources/lang/et/project-problems.php | 10 +++++++++ resources/lang/fr/project-problems.php | 10 +++++++++ resources/lang/hu/project-problems.php | 10 +++++++++ resources/lang/it/project-problems.php | 10 +++++++++ resources/lang/lv/project-problems.php | 10 +++++++++ resources/lang/nl/project-problems.php | 10 +++++++++ resources/lang/pt/project-problems.php | 10 +++++++++ resources/lang/sk/project-problems.php | 10 +++++++++ resources/lang/sr/project-problems.php | 10 +++++++++ .../partials/motto.blade.php | 6 +++++- 20 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 resources/lang/bg/project-problems.php create mode 100644 resources/lang/de/project-problems.php create mode 100644 resources/lang/es/project-problems.php create mode 100644 resources/lang/et/project-problems.php create mode 100644 resources/lang/fr/project-problems.php create mode 100644 resources/lang/hu/project-problems.php create mode 100644 resources/lang/it/project-problems.php create mode 100644 resources/lang/lv/project-problems.php create mode 100644 resources/lang/nl/project-problems.php create mode 100644 resources/lang/pt/project-problems.php create mode 100644 resources/lang/sk/project-problems.php create mode 100644 resources/lang/sr/project-problems.php diff --git a/app/BusinessLogicLayer/CrowdSourcingProject/CrowdSourcingProjectManager.php b/app/BusinessLogicLayer/CrowdSourcingProject/CrowdSourcingProjectManager.php index eeaee7ed..08e90996 100644 --- a/app/BusinessLogicLayer/CrowdSourcingProject/CrowdSourcingProjectManager.php +++ b/app/BusinessLogicLayer/CrowdSourcingProject/CrowdSourcingProjectManager.php @@ -10,6 +10,7 @@ use App\Notifications\QuestionnaireResponded; use App\Repository\CrowdSourcingProject\CrowdSourcingProjectRepository; use App\Repository\CrowdSourcingProject\CrowdSourcingProjectStatusHistoryRepository; +use App\Repository\CrowdSourcingProject\Problem\CrowdSourcingProjectProblemRepository; use App\Repository\LanguageRepository; use App\Repository\Questionnaire\QuestionnaireRepository; use App\Repository\Questionnaire\Responses\QuestionnaireResponseRepository; @@ -41,6 +42,7 @@ class CrowdSourcingProjectManager { protected CrowdSourcingProjectColorsManager $crowdSourcingProjectColorsManager; protected QuestionnaireResponseRepository $questionnaireResponseRepository; protected CrowdSourcingProjectTranslationManager $crowdSourcingProjectTranslationManager; + protected CrowdSourcingProjectProblemRepository $crowdSourcingProjectProblemRepository; public function __construct(CrowdSourcingProjectRepository $crowdSourcingProjectRepository, QuestionnaireRepository $questionnaireRepository, @@ -51,7 +53,8 @@ public function __construct(CrowdSourcingProjectRepository $crowdSourcingProject LanguageRepository $languageRepository, CrowdSourcingProjectColorsManager $crowdSourcingProjectColorsManager, QuestionnaireResponseRepository $questionnaireResponseRepository, - CrowdSourcingProjectTranslationManager $crowdSourcingProjectTranslationManager) { + CrowdSourcingProjectTranslationManager $crowdSourcingProjectTranslationManager, + CrowdSourcingProjectProblemRepository $crowdSourcingProjectProblemRepository) { $this->crowdSourcingProjectRepository = $crowdSourcingProjectRepository; $this->questionnaireRepository = $questionnaireRepository; $this->crowdSourcingProjectStatusManager = $crowdSourcingProjectStatusManager; @@ -62,6 +65,7 @@ public function __construct(CrowdSourcingProjectRepository $crowdSourcingProject $this->crowdSourcingProjectColorsManager = $crowdSourcingProjectColorsManager; $this->questionnaireResponseRepository = $questionnaireResponseRepository; $this->crowdSourcingProjectTranslationManager = $crowdSourcingProjectTranslationManager; + $this->crowdSourcingProjectProblemRepository = $crowdSourcingProjectProblemRepository; } public function getCrowdSourcingProjectsForHomePage(): Collection { @@ -94,15 +98,7 @@ public function getCrowdSourcingProjectBySlug($project_slug, $withRelationships public function getCrowdSourcingProjectViewModelForLandingPage( $questionnaireIdRequestedInTheURL, $project_slug): CrowdSourcingProjectForLandingPage { - $userId = null; - - // if the user is logged in, get the user id - if (Auth::check()) { - $userId = Auth::id(); - } // else, check if the user is anonymous (by checking the cookie) and get the user id - elseif (isset($_COOKIE[UserManager::$USER_COOKIE_KEY]) && intval($_COOKIE[UserManager::$USER_COOKIE_KEY])) { - $userId = intval($_COOKIE[UserManager::$USER_COOKIE_KEY]); - } + $userId = Auth::id() ?? intval($_COOKIE[UserManager::$USER_COOKIE_KEY] ?? 0); $project = $this->getCrowdSourcingProjectBySlug($project_slug); @@ -122,6 +118,7 @@ public function getCrowdSourcingProjectViewModelForLandingPage( $shareUrlForFacebook = ''; $shareUrlForTwitter = ''; $countAll = 0; + $projectHasPublishedProblems = false; if ($questionnaire) { $countAll = $this->questionnaireRepository->countAllResponsesForQuestionnaire($questionnaire->id); $questionnaireGoalVM = $this->questionnaireGoalManager->getQuestionnaireGoalViewModel($questionnaire, $countAll); @@ -131,6 +128,9 @@ public function getCrowdSourcingProjectViewModelForLandingPage( $shareButtonsModel = new QuestionnaireSocialShareButtons($questionnaire, $idOfUserThatCanShareTheQuestionnaire); $shareUrlForFacebook = $shareButtonsModel->getSocialShareURL($project, 'facebook'); $shareUrlForTwitter = $shareButtonsModel->getSocialShareURL($project, 'twitter'); + } else { + // if there is no questionnaire, we need to check if this project has published problems + $projectHasPublishedProblems = $this->crowdSourcingProjectProblemRepository->projectHasPublishedProblems($project->id); } if ($feedbackQuestionnaire) { $userFeedbackQuestionnaireResponse = @@ -143,6 +143,7 @@ public function getCrowdSourcingProjectViewModelForLandingPage( return new CrowdSourcingProjectForLandingPage($project, $questionnaire, $feedbackQuestionnaire, + $projectHasPublishedProblems, $userResponse, $userFeedbackQuestionnaireResponse, $countAll, diff --git a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php index 10950ba7..446194d8 100644 --- a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php +++ b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php @@ -3,7 +3,6 @@ namespace App\Models\CrowdSourcingProject\Problem; use Awobaz\Compoships\Compoships; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; @@ -11,7 +10,7 @@ class CrowdSourcingProjectProblem extends Model { use Compoships; - use HasFactory, SoftDeletes; + use SoftDeletes; protected $table = 'crowd_sourcing_project_problems'; protected $fillable = ['id', 'project_id', 'slug', 'status_id', 'img_url', 'default_language_id']; @@ -22,6 +21,6 @@ public function defaultTranslation(): HasOne { } public function translations(): HasMany { - return $this->hasMany(CrowdSourcingProjectProblemTranslation::class, 'project_id', 'id'); + return $this->hasMany(CrowdSourcingProjectProblemTranslation::class, 'problem_id', 'id'); } } diff --git a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php index 7f8931c6..e63ee730 100644 --- a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php +++ b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php @@ -5,12 +5,10 @@ use App\Models\CompositeKeysModel; use App\Models\Language; use Awobaz\Compoships\Compoships; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; class CrowdSourcingProjectProblemTranslation extends CompositeKeysModel { use Compoships; - use HasFactory; protected $table = 'crowd_sourcing_project_problem_translations'; protected $fillable = ['problem_id', 'language_id', 'title', 'description']; diff --git a/app/Repository/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemRepository.php b/app/Repository/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemRepository.php index 125ddd23..7f73786e 100644 --- a/app/Repository/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemRepository.php +++ b/app/Repository/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemRepository.php @@ -2,6 +2,7 @@ namespace App\Repository\CrowdSourcingProject\Problem; +use App\BusinessLogicLayer\lkp\CrowdSourcingProjectProblemStatusLkp; use App\Models\CrowdSourcingProject\CrowdSourcingProject; use App\Models\CrowdSourcingProject\Problem\CrowdSourcingProjectProblem; use App\Repository\Repository; @@ -17,4 +18,13 @@ public function getModelClassName() { public function getProjectWithProblemsByProjectSlug(string $project_slug): CrowdSourcingProject { return CrowdSourcingProject::where('slug', $project_slug)->with(['problems'])->first(); } + + public function projectHasPublishedProblems(int $project_id): bool { + $hasPublishedProblemsWithTranslations = CrowdSourcingProjectProblem::where('project_id', $project_id) + ->where('status_id', CrowdSourcingProjectProblemStatusLkp::PUBLISHED) + ->whereHas('translations') + ->exists(); + + return $hasPublishedProblemsWithTranslations; + } } diff --git a/app/ViewModels/CrowdSourcingProject/CrowdSourcingProjectForLandingPage.php b/app/ViewModels/CrowdSourcingProject/CrowdSourcingProjectForLandingPage.php index 07b2525f..bb2fd122 100644 --- a/app/ViewModels/CrowdSourcingProject/CrowdSourcingProjectForLandingPage.php +++ b/app/ViewModels/CrowdSourcingProject/CrowdSourcingProjectForLandingPage.php @@ -9,6 +9,7 @@ class CrowdSourcingProjectForLandingPage { public $project; public $questionnaire; public $feedbackQuestionnaire; + public $projectHasPublishedProblems; public $userResponse; public $userFeedbackQuestionnaireResponse; public $totalResponses; @@ -24,6 +25,7 @@ public function __construct( $project, $questionnaire, $feedbackQuestionnaire, + $projectHasPublishedProblems, $userResponse, $userFeedbackQuestionnaireResponse, $totalResponses, @@ -35,6 +37,7 @@ public function __construct( $this->project = $project; $this->questionnaire = $questionnaire; $this->feedbackQuestionnaire = $feedbackQuestionnaire; + $this->projectHasPublishedProblems = $projectHasPublishedProblems; $this->userResponse = $userResponse; $this->userFeedbackQuestionnaireResponse = $userFeedbackQuestionnaireResponse; $this->totalResponses = $totalResponses; diff --git a/resources/lang/bg/project-problems.php b/resources/lang/bg/project-problems.php new file mode 100644 index 00000000..701a6b89 --- /dev/null +++ b/resources/lang/bg/project-problems.php @@ -0,0 +1,10 @@ + 'Назад', + 'the_topic' => 'Темата:', + 'list_of_problems' => 'Списък с проблеми', + 'see_all_problems' => 'Виж всички проблеми', + 'solutions_for' => 'Решения за', + 'project_landing_page_problems_action_button' => 'Виж всички проблеми', +]; diff --git a/resources/lang/de/project-problems.php b/resources/lang/de/project-problems.php new file mode 100644 index 00000000..fc8a574f --- /dev/null +++ b/resources/lang/de/project-problems.php @@ -0,0 +1,10 @@ + 'Zurück', + 'the_topic' => 'Das Thema:', + 'list_of_problems' => 'Liste der Probleme', + 'see_all_problems' => 'Alle Probleme anzeigen', + 'solutions_for' => 'Lösungen für', + 'project_landing_page_problems_action_button' => 'Alle Probleme anzeigen', +]; diff --git a/resources/lang/el/project-problems.php b/resources/lang/el/project-problems.php index ec119597..19bfe79d 100644 --- a/resources/lang/el/project-problems.php +++ b/resources/lang/el/project-problems.php @@ -6,4 +6,5 @@ 'list_of_problems' => 'Λίστα Προβλημάτων', 'see_all_problems' => 'Δες όλα τα προβλήματα', 'solutions_for' => 'Λύσεις για', + 'project_landing_page_problems_action_button' => 'Δες όλα τα προβλήματα', ]; diff --git a/resources/lang/en/project-problems.php b/resources/lang/en/project-problems.php index 4c75bd70..e1435bbe 100644 --- a/resources/lang/en/project-problems.php +++ b/resources/lang/en/project-problems.php @@ -6,4 +6,5 @@ 'list_of_problems' => 'List of Problems', 'see_all_problems' => 'See all problems', 'solutions_for' => 'Solutions for', + 'project_landing_page_problems_action_button' => 'See all problems', ]; diff --git a/resources/lang/es/project-problems.php b/resources/lang/es/project-problems.php new file mode 100644 index 00000000..924b9dc7 --- /dev/null +++ b/resources/lang/es/project-problems.php @@ -0,0 +1,10 @@ + 'Atrás', + 'the_topic' => 'El tema:', + 'list_of_problems' => 'Lista de problemas', + 'see_all_problems' => 'Ver todos los problemas', + 'solutions_for' => 'Soluciones para', + 'project_landing_page_problems_action_button' => 'Ver todos los problemas', +]; diff --git a/resources/lang/et/project-problems.php b/resources/lang/et/project-problems.php new file mode 100644 index 00000000..75a54e30 --- /dev/null +++ b/resources/lang/et/project-problems.php @@ -0,0 +1,10 @@ + 'Tagasi', + 'the_topic' => 'Teema:', + 'list_of_problems' => 'Probleemide loetelu', + 'see_all_problems' => 'Vaata kõiki probleeme', + 'solutions_for' => 'Lahendused', + 'project_landing_page_problems_action_button' => 'Vaata kõiki probleeme', +]; diff --git a/resources/lang/fr/project-problems.php b/resources/lang/fr/project-problems.php new file mode 100644 index 00000000..af457be1 --- /dev/null +++ b/resources/lang/fr/project-problems.php @@ -0,0 +1,10 @@ + 'Retour', + 'the_topic' => 'Le sujet:', + 'list_of_problems' => 'Liste des problèmes', + 'see_all_problems' => 'Voir tous les problèmes', + 'solutions_for' => 'Solutions pour', + 'project_landing_page_problems_action_button' => 'Voir tous les problèmes', +]; diff --git a/resources/lang/hu/project-problems.php b/resources/lang/hu/project-problems.php new file mode 100644 index 00000000..f3f88903 --- /dev/null +++ b/resources/lang/hu/project-problems.php @@ -0,0 +1,10 @@ + 'Vissza', + 'the_topic' => 'A téma:', + 'list_of_problems' => 'Problémák listája', + 'see_all_problems' => 'Összes probléma megtekintése', + 'solutions_for' => 'Megoldások', + 'project_landing_page_problems_action_button' => 'Összes probléma megtekintése', +]; diff --git a/resources/lang/it/project-problems.php b/resources/lang/it/project-problems.php new file mode 100644 index 00000000..3dd60792 --- /dev/null +++ b/resources/lang/it/project-problems.php @@ -0,0 +1,10 @@ + 'Indietro', + 'the_topic' => 'L\'argomento:', + 'list_of_problems' => 'Elenco dei problemi', + 'see_all_problems' => 'Vedi tutti i problemi', + 'solutions_for' => 'Soluzioni per', + 'project_landing_page_problems_action_button' => 'Vedi tutti i problemi', +]; diff --git a/resources/lang/lv/project-problems.php b/resources/lang/lv/project-problems.php new file mode 100644 index 00000000..8113a3ff --- /dev/null +++ b/resources/lang/lv/project-problems.php @@ -0,0 +1,10 @@ + 'Atpakaļ', + 'the_topic' => 'Tēma:', + 'list_of_problems' => 'Problēmu saraksts', + 'see_all_problems' => 'Skatīt visas problēmas', + 'solutions_for' => 'Risinājumi', + 'project_landing_page_problems_action_button' => 'Skatīt visas problēmas', +]; diff --git a/resources/lang/nl/project-problems.php b/resources/lang/nl/project-problems.php new file mode 100644 index 00000000..2d57cda9 --- /dev/null +++ b/resources/lang/nl/project-problems.php @@ -0,0 +1,10 @@ + 'Terug', + 'the_topic' => 'Het onderwerp:', + 'list_of_problems' => 'Lijst met problemen', + 'see_all_problems' => 'Bekijk alle problemen', + 'solutions_for' => 'Oplossingen voor', + 'project_landing_page_problems_action_button' => 'Bekijk alle problemen', +]; diff --git a/resources/lang/pt/project-problems.php b/resources/lang/pt/project-problems.php new file mode 100644 index 00000000..eed0ab4d --- /dev/null +++ b/resources/lang/pt/project-problems.php @@ -0,0 +1,10 @@ + 'Voltar', + 'the_topic' => 'O tópico:', + 'list_of_problems' => 'Lista de problemas', + 'see_all_problems' => 'Ver todos os problemas', + 'solutions_for' => 'Soluções para', + 'project_landing_page_problems_action_button' => 'Ver todos os problemas', +]; diff --git a/resources/lang/sk/project-problems.php b/resources/lang/sk/project-problems.php new file mode 100644 index 00000000..1592d910 --- /dev/null +++ b/resources/lang/sk/project-problems.php @@ -0,0 +1,10 @@ + 'Späť', + 'the_topic' => 'Téma:', + 'list_of_problems' => 'Zoznam problémov', + 'see_all_problems' => 'Zobraziť všetky problémy', + 'solutions_for' => 'Riešenia pre', + 'project_landing_page_problems_action_button' => 'Zobraziť všetky problémy', +]; diff --git a/resources/lang/sr/project-problems.php b/resources/lang/sr/project-problems.php new file mode 100644 index 00000000..eeab4969 --- /dev/null +++ b/resources/lang/sr/project-problems.php @@ -0,0 +1,10 @@ + 'Nazad', + 'the_topic' => 'Tema:', + 'list_of_problems' => 'Lista problema', + 'see_all_problems' => 'Pogledaj sve probleme', + 'solutions_for' => 'Rešenja za', + 'project_landing_page_problems_action_button' => 'Pogledaj sve probleme', +]; diff --git a/resources/views/crowdsourcing-project/partials/motto.blade.php b/resources/views/crowdsourcing-project/partials/motto.blade.php index 44ddb313..c7fc34d8 100644 --- a/resources/views/crowdsourcing-project/partials/motto.blade.php +++ b/resources/views/crowdsourcing-project/partials/motto.blade.php @@ -94,8 +94,12 @@ class="btn btn-primary w-100 respond-questionnaire call-to-action @endif + @elseif($viewModel->projectHasPublishedProblems) + + {{__("project-problems.project_landing_page_problems_action_button")}} @else - {{-- PROJECT DOES NOT HAVE AN ACTIVE QUESTIONNAIRE --}} @include('crowdsourcing-project.partials.external-url') @endif From 019ccc05f7578290a30fec7f69c2509c05747d14 Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 7 Oct 2024 12:03:53 +0300 Subject: [PATCH 3/6] Added a separate seeder for the Air Quality project --- database/seeders/AirQualityProjectSeeder.php | 99 ++++++++++++++++++++ database/seeders/DatabaseSeeder.php | 1 + database/seeders/DefaultProjectSeeder.php | 54 ----------- 3 files changed, 100 insertions(+), 54 deletions(-) create mode 100644 database/seeders/AirQualityProjectSeeder.php diff --git a/database/seeders/AirQualityProjectSeeder.php b/database/seeders/AirQualityProjectSeeder.php new file mode 100644 index 00000000..ee66b506 --- /dev/null +++ b/database/seeders/AirQualityProjectSeeder.php @@ -0,0 +1,99 @@ +projectRepository = $crowdSourcingProjectRepository; + $this->projectTranslationRepository = $crowdSourcingProjectTranslationRepository; + } + + /** + * Run the database seeds. + */ + public function run(): void { + $project = [ + 'id' => 4, + 'slug' => 'air-quality-europe', + 'external_url' => 'https://www.scify.gr/site/en/', + 'img_path' => '/images/projects/air-quality-europe/logo-bg.webp', + 'logo_path' => '/images/projects/air-quality-europe/logo.webp', + 'user_creator_id' => 1, + 'language_id' => 6, + 'should_send_email_after_questionnaire_response' => 1, + 'lp_primary_color' => '#707070', + 'lp_questionnaire_image_path' => '/images/projects/air-quality-europe/logo.webp', + 'lp_show_speak_up_btn' => 1, + 'sm_featured_img_path' => '/images/projects/air-quality-europe/logo.webp', + 'display_landing_page_banner' => 1, + 'status_id' => CrowdSourcingProjectStatusLkp::PUBLISHED, + ]; + + $project_translations = [ + [ + 'id' => 6, + 'language_id' => 6, + 'project_id' => 4, + 'name' => 'Air Quality in Europe', + 'motto_title' => 'Please share with us your opinion on the air quality in Europe. Your voice matters!', + 'motto_subtitle' => 'You can make an impact! Share your opinion with us!', + 'description' => 'Lorem ipsum dolor site amet', + 'about' => '

Contribute to solving air quality problems in Athens and across Europe. Write points for and against the proposed solutions. Your contributions will be a valuable contribution to official policy to improve air quality in Athens and across Europe.

', + 'footer' => '

© SCIFY ' . now()->year . ' |  + Terms of use |  + Privacy Policy |  + Cookie Policy', + 'sm_title' => 'Air Quality in Europe', + 'sm_description' => 'Please share with us your opinion on the air quality in Europe. Your voice matters!', + 'sm_keywords' => 'Social Media Keywords', + 'questionnaire_response_email_intro_text' => '

Thanks to your contribution we are one step closer to understanding the problem.

', + 'questionnaire_response_email_outro_text' => '

Thank you for your time and effort.

', + ], + [ + 'id' => 7, + 'language_id' => 12, + 'project_id' => 4, + 'name' => 'Η Ποιότητα του Αέρα στην Ευρώπη', + 'motto_title' => 'Παρακαλούμε μοιραστείτε μαζί μας την άποψή σας για την ποιότητα του αέρα στην Ευρώπη. Η φωνή σας μετράει!', + 'motto_subtitle' => 'Μπορείς να κάνεις διαφορά! Μοιραστείτε την άποψή σας μαζί μας!', + 'description' => 'Lorem ipsum dolor site amet', + 'about' => '

Συμβάλλετε στην επίλυση των προβλημάτων ποιότητας του αέρα στην Αθήνα και σε όλη την Ευρώπη. Γράψτε επιχειρήματα υπέρ και κατά των προτεινόμενων λύσεων. Η συμβολή σας θα είναι πολύτιμη για τη διαμόρφωση επίσημης πολιτικής για τη βελτίωση της ποιότητας του αέρα στην Αθήνα και σε όλη την Ευρώπη.

', + 'footer' => '

© SCIFY ' . now()->year . ' |  + Πολιτική Ορθής Χρήσης |  + Πολιτική Ιδιωτικότητας |  + Πολιτική Cookies', + 'sm_title' => 'Η Ποιότητα του Αέρα στην Ευρώπη', + 'sm_description' => 'Παρακαλούμε μοιραστείτε μαζί μας την άποψή σας για την ποιότητα του αέρα στην Ευρώπη. Η φωνή σας μετράει!', + 'sm_keywords' => 'Social Media Keywords', + 'questionnaire_response_email_intro_text' => '

Χάρη στη συνεισφορά σας είμαστε ένα βήμα πιο κοντά στην κατανόηση του προβλήματος.

', + 'questionnaire_response_email_outro_text' => '

Σας ευχαριστούμε για το χρόνο και την προσπάθειά σας.

', + ], + ]; + + $project = $this->projectRepository->updateOrCreate(['id' => $project['id']], + Helpers::getFilteredAttributes($project, (new CrowdSourcingProject)->getFillable())); + if (app()->environment() !== 'testing') { + echo "\nAdded Project: " . $project['name'] . ' with slug: ' . $project->slug . "\n"; + } + + foreach ($project_translations as $project_translation) { + $this->projectTranslationRepository->updateOrCreate(['id' => $project_translation['id']], + Helpers::getFilteredAttributes($project_translation, (new CrowdSourcingProjectTranslation)->getFillable())); + if (app()->environment() !== 'testing') { + echo "\nAdded Project Translation: " . $project_translation['name'] . ' with id: ' . $project_translation['id'] . "\n"; + } + } + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 8b17afcb..dfa49cb7 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -18,6 +18,7 @@ public function run() { LanguagesLkpTableSeeder::class, CrowdSourcingProjectStatusesLkpTableSeeder::class, DefaultProjectSeeder::class, + AirQualityProjectSeeder::class, QuestionnaireStatusesLkpTableSeeder::class, QuestionnaireStatisticsPageVisibilityLkpSeeder::class, MailChimpListsTableSeeder::class, diff --git a/database/seeders/DefaultProjectSeeder.php b/database/seeders/DefaultProjectSeeder.php index 6e8d77e5..4aabb242 100644 --- a/database/seeders/DefaultProjectSeeder.php +++ b/database/seeders/DefaultProjectSeeder.php @@ -75,22 +75,6 @@ public function run() { 'display_landing_page_banner' => 1, 'status_id' => CrowdSourcingProjectStatusLkp::DRAFT, ], - [ - 'id' => 4, - 'slug' => 'air-quality-europe', - 'external_url' => 'https://www.scify.gr/site/en/', - 'img_path' => '/images/projects/air-quality-europe/logo-bg.webp', - 'logo_path' => '/images/projects/air-quality-europe/logo.webp', - 'user_creator_id' => 1, - 'language_id' => 6, - 'should_send_email_after_questionnaire_response' => 1, - 'lp_primary_color' => '#707070', - 'lp_questionnaire_image_path' => '/images/projects/air-quality-europe/logo.webp', - 'lp_show_speak_up_btn' => 1, - 'sm_featured_img_path' => '/images/projects/air-quality-europe/logo.webp', - 'display_landing_page_banner' => 1, - 'status_id' => CrowdSourcingProjectStatusLkp::PUBLISHED, - ], ]; $project_translations = [ @@ -191,44 +175,6 @@ public function run() { 'questionnaire_response_email_intro_text' => '

Thanks to your contribution we are one step closer to understanding the problem.

', 'questionnaire_response_email_outro_text' => '

Thank you for your time and effort.

', ], - [ - 'id' => 6, - 'language_id' => 6, - 'project_id' => 4, - 'name' => 'Air Quality in Europe', - 'motto_title' => 'Please share with us your opinion on the air quality in Europe. Your voice matters!', - 'motto_subtitle' => 'You can make an impact! Share your opinion with us!', - 'description' => 'Lorem ipsum dolor site amet', - 'about' => '

Contribute to solving air quality problems in Athens and across Europe. Write points for and against the proposed solutions. Your contributions will be a valuable contribution to official policy to improve air quality in Athens and across Europe.

', - 'footer' => '

© SCIFY ' . now()->year . ' |  - Terms of use |  - Privacy Policy |  - Cookie Policy', - 'sm_title' => 'Air Quality in Europe', - 'sm_description' => 'Please share with us your opinion on the air quality in Europe. Your voice matters!', - 'sm_keywords' => 'Social Media Keywords', - 'questionnaire_response_email_intro_text' => '

Thanks to your contribution we are one step closer to understanding the problem.

', - 'questionnaire_response_email_outro_text' => '

Thank you for your time and effort.

', - ], - [ - 'id' => 7, - 'language_id' => 12, - 'project_id' => 4, - 'name' => 'Η Ποιότητα του Αέρα στην Ευρώπη', - 'motto_title' => 'Παρακαλούμε μοιραστείτε μαζί μας την άποψή σας για την ποιότητα του αέρα στην Ευρώπη. Η φωνή σας μετράει!', - 'motto_subtitle' => 'Μπορείς να κάνεις διαφορά! Μοιραστείτε την άποψή σας μαζί μας!', - 'description' => 'Lorem ipsum dolor site amet', - 'about' => '

Συμβάλλετε στην επίλυση των προβλημάτων ποιότητας του αέρα στην Αθήνα και σε όλη την Ευρώπη. Γράψτε επιχειρήματα υπέρ και κατά των προτεινόμενων λύσεων. Η συμβολή σας θα είναι πολύτιμη για τη διαμόρφωση επίσημης πολιτικής για τη βελτίωση της ποιότητας του αέρα στην Αθήνα και σε όλη την Ευρώπη.

', - 'footer' => '

© SCIFY ' . now()->year . ' |  - Πολιτική Ορθής Χρήσης |  - Πολιτική Ιδιωτικότητας |  - Πολιτική Cookies', - 'sm_title' => 'Η Ποιότητα του Αέρα στην Ευρώπη', - 'sm_description' => 'Παρακαλούμε μοιραστείτε μαζί μας την άποψή σας για την ποιότητα του αέρα στην Ευρώπη. Η φωνή σας μετράει!', - 'sm_keywords' => 'Social Media Keywords', - 'questionnaire_response_email_intro_text' => '

Χάρη στη συνεισφορά σας είμαστε ένα βήμα πιο κοντά στην κατανόηση του προβλήματος.

', - 'questionnaire_response_email_outro_text' => '

Σας ευχαριστούμε για το χρόνο και την προσπάθειά σας.

', - ], ]; foreach ($data as $project) { From 082aca1cea46dcf95be99bdc8ad8ee8828a666a8 Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 7 Oct 2024 12:06:48 +0300 Subject: [PATCH 4/6] Renamed Action --- .github/workflows/{deploy.yml => deploy-secondary-staging.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{deploy.yml => deploy-secondary-staging.yml} (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy-secondary-staging.yml similarity index 100% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy-secondary-staging.yml From 3a3e57df649adbc3bd56100c4fa6416f41868563 Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 7 Oct 2024 12:50:17 +0300 Subject: [PATCH 5/6] - Fixed slug generator - Added missing chapter in ToC --- README.md | 3 +++ .../CrowdSourcingProjectControllerTest.php | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 82083dc2..f4274846 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,9 @@ This is a [Laravel](https://laravel.com/) Web Application for Crowdsourcing Proj - [Related HTML Template](#related-html-template) - [PHP code style - Laravel Pint](#php-code-style---laravel-pint) - [Installation-specific resources](#installation-specific-resources) +- [Development Guidelines](#development-guidelines) + - [Directory Structure](#directory-structure) + - [About the Repository Pattern](#about-the-repository-pattern) - [Run Tests](#run-tests) - [How to debug](#how-to-debug) - [Troubleshooting](#troubleshooting) diff --git a/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php b/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php index de18595d..0c9ac171 100644 --- a/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php +++ b/tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php @@ -12,6 +12,7 @@ use App\Repository\CrowdSourcingProject\CrowdSourcingProjectRepository; use Faker\Factory as Faker; use Tests\TestCase; +use Illuminate\Support\Str; class CrowdSourcingProjectControllerTest extends TestCase { protected CrowdSourcingProjectRepository $crowdSourcingProjectRepository; @@ -301,9 +302,7 @@ public function nonAdminUserCannotStoreProject() { $faker = Faker::create(); // we need a name with no special characters $name = $faker->name; - $slug = str_replace(' ', '-', strtolower($name)); - // remove dots from the slug - $slug = str_replace('.', '', $slug); + $slug = Str::slug($name); $response = $this->withoutMiddleware(VerifyCsrfToken::class) // Disable CSRF only ->post(route('projects.store'), [ 'name' => $name, @@ -327,7 +326,7 @@ public function adminCanStoreProjectWithValidData() { $faker = Faker::create(); $name = $faker->name; - $slug = str_replace(' ', '-', strtolower($name)); + $slug = Str::slug($name); $response = $this->withoutMiddleware(VerifyCsrfToken::class) ->post(route('projects.store'), [ @@ -425,8 +424,7 @@ public function authenticatedUserCannotUpdateProject() { $project = CrowdSourcingProject::factory()->create(); $faker = Faker::create(); $name = $faker->name; - $slug = str_replace(' ', '-', strtolower($name)); - $slug = str_replace('.', '', $slug); + $slug = Str::slug($name); $response = $this->withoutMiddleware(VerifyCsrfToken::class)->put(route('projects.update', ['project' => $project->id]), [ 'name' => $name, 'description' => 'Updated Description', @@ -450,7 +448,7 @@ public function adminCanUpdateProjectWithValidData() { $project = CrowdSourcingProject::factory()->create(); $faker = Faker::create(); $name = $faker->name; - $slug = str_replace(' ', '-', strtolower($name)); + $slug = Str::slug($name); $response = $this->withoutMiddleware(VerifyCsrfToken::class)->put(route('projects.update', ['project' => $project->id]), [ 'name' => $name, 'description' => 'Updated Description', From da154691897eebf44d65f11db470ae0f0de6271c Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 7 Oct 2024 13:20:16 +0300 Subject: [PATCH 6/6] Added action to deploy to staging --- .../workflows/deploy-secondary-staging.yml | 2 +- .github/workflows/deploy-staging.yml | 137 ++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-staging.yml diff --git a/.github/workflows/deploy-secondary-staging.yml b/.github/workflows/deploy-secondary-staging.yml index adb279a5..a5a513d3 100644 --- a/.github/workflows/deploy-secondary-staging.yml +++ b/.github/workflows/deploy-secondary-staging.yml @@ -1,4 +1,4 @@ -name: Deploy to Secondary Staging Server +name: Deploy to Secondary Staging Server (ECAS Installation) on: workflow_dispatch: diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml new file mode 100644 index 00000000..a831038c --- /dev/null +++ b/.github/workflows/deploy-staging.yml @@ -0,0 +1,137 @@ +name: Deploy to Staging Server (SciFY Installation - "Together") + +on: + workflow_dispatch: + push: + branches: + - staging_scify_org + +env: + PHP_VERSION: '8.2' + SERVER_HOSTNAME: 'staging.scify.org' + REMOTE_USER: 'project_crowdsourcing' + PROJECT_URL: 'crowdsourcing.scify.org' + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3.2.0 + + - name: Install wireguard + run: sudo apt install wireguard + + - name: Create wg0 file + uses: cuchi/jinja2-action@v1.2.0 + with: + template: .github/templates/wg0.j2 + output_file: wg0.conf + variables: | + WIREGUARD_PRIVATE_KEY=${{ secrets.WIREGUARD_PRIVATE_KEY }} + VPN_SERVER_PUBLIC_KEY=${{ secrets.VPN_SERVER_PUBLIC_KEY }} + + + + - name: Move wg0.conf to /etc/wireguard + run: sudo mv wg0.conf /etc/wireguard/wg0.conf + + - name: Start wireguard + run: sudo wg-quick up wg0 + + - name: Checkout repo + uses: actions/checkout@v3.2.0 + + - name: Add frodo to etc hosts + run: echo "10.10.0.100 frodo.scify.org" | sudo tee -a /etc/hosts + + - name: read password from vault + uses: hashicorp/vault-action@v2 + with: + url: https://frodo.scify.org:8200 + caCertificate: ${{ secrets.VAULT_CA_CERT }} + method: userpass + username: ${{ secrets.VAULT_USER }} + password: ${{ secrets.VAULT_PASSWORD }} + secrets: | + Projects/data/crowdsourcing/scify-installation-together/staging/database db_name | DB_NAME ; + Projects/data/crowdsourcing/scify-installation-together/staging/database db_user | DB_USER ; + Projects/data/crowdsourcing/scify-installation-together/staging/database password | DB_PASSWORD ; + Projects/data/crowdsourcing/staging_sec_data/google_client_secrets google_client_id | GOOGLE_CLIENT_ID ; + Projects/data/crowdsourcing/production/email/laravel_mailgun_env_variables MAILGUN_SECRET | MAILGUN_SECRET ; + + + + + + - name: Create .env file + uses: cuchi/jinja2-action@v1.2.0 + with: + template: .github/templates/.env.j2 + output_file: .env + variables: | + DB_NAME=${{ env.DB_NAME }} + DB_USER=${{ env.DB_USER }} + DB_PASSWORD=${{ env.DB_PASSWORD }} + LARAVEL_STAGING_SCIFY_APP_KEY=${{ secrets.LARAVEL_STAGING_SCIFY_APP_KEY }} + PROJECT_URL=${{ env.PROJECT_URL }} + MAILGUN_SECRET=${{ env.MAILGUN_SECRET }} + PERSONAL_CLIENT_ID=${{ secrets.PERSONAL_CLIENT_ID }} + PERSONAL_CLIENT_SECRET=${{ secrets.PERSONAL_CLIENT_SECRET }} + PASSWORD_CLIENT_SECRET=${{ secrets.PASSWORD_CLIENT_SECRET }} + FACEBOOK_CLIENT_ID=${{ secrets.FACEBOOK_CLIENT_ID }} + FACEBOOK_CLIENT_SECRET=${{ secrets.FACEBOOK_CLIENT_SECRET }} + TWITTER_CLIENT_ID=${{ secrets.TWITTER_CLIENT_ID }} + TWITTER_CLIENT_SECRET=${{ secrets.TWITTER_CLIENT_SECRET }} + GOOGLE_CLIENT_ID=${{ env.GOOGLE_CLIENT_ID }} + GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} + MICROSOFT_CLIENT_ID=${{ secrets.MICROSOFT_CLIENT_ID }} + MICROSOFT_CLIENT_SECRET=${{ secrets.MICROSOFT_CLIENT_SECRET }} + LINKEDIN_CLIENT_ID=${{ secrets.LINKEDIN_CLIENT_ID }} + LINKEDIN_CLIENT_SECRET=${{ secrets.LINKEDIN_CLIENT_SECRET }} + DEFAULT_ADMIN_USER_PASSWORD_FOR_SEED=${{ secrets.DEFAULT_ADMIN_USER_PASSWORD_FOR_SEED }} + GOOGLE_TRANSLATE_KEY=${{ secrets.GOOGLE_TRANSLATE_KEY }} + MAILCHIMP_API_KEY=${{ secrets.MAILCHIMP_API_KEY }} + SENTRY_LARAVEL_DSN=${{ secrets.SENTRY_LARAVEL_DSN }} + API_AUTH_TOKEN=${{ secrets.API_AUTH_TOKEN }} + USERWAY_ID=${{ secrets.USERWAY_ID }} + AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} + + + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - name: Install node dependencies + run: npm install + + - name: Build assets + run: npm run build + + + - name: SCP files to staging server + uses: easingthemes/ssh-deploy@v3.0.1 + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY_STAGING_SERVER }} + REMOTE_PORT: 222 + SOURCE: "./" + REMOTE_HOST: ${{ env.SERVER_HOSTNAME }} + REMOTE_USER: ${{ env.REMOTE_USER }} + TARGET: "/home/${{ env.REMOTE_USER }}/www/${{ env.PROJECT_URL }}" + + + - name: Run composer install on remote server + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ env.SERVER_HOSTNAME }} + port: 222 + username: ${{ env.REMOTE_USER }} + key: ${{ secrets.SSH_KEY_STAGING_SERVER }} + script: | + source /home/${{ env.REMOTE_USER }}/.profile + cd /home/${{ env.REMOTE_USER }}/www/${{ env.PROJECT_URL }} + composer install --no-interaction --no-progress --optimize-autoloader + # --no-dev \ No newline at end of file