Skip to content

Commit

Permalink
IP-312: A content manager can declare how many votes per problem the …
Browse files Browse the repository at this point in the history
…user has, through the edit project page
  • Loading branch information
PavlosIsaris committed Dec 12, 2024
1 parent cb62d5a commit 12f07b7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ protected function setDefaultValuesForSocialMediaFields(array $attributes): arra
}

public function populateInitialValuesForProjectIfNotSet(CrowdSourcingProject $project): CrowdSourcingProject {
$project->lp_show_speak_up_btn = true;
$project->lp_show_speak_up_btn = $project->lp_show_speak_up_btn ?? true;
$project->max_votes_per_user_for_solutions = $project->max_votes_per_user_for_solutions ?? 10;
$project = $this->populateInitialFileValuesForProjectIfNotSet($project);

return $this->populateInitialColorValuesForProjectIfNotSet($project);
Expand Down
4 changes: 3 additions & 1 deletion app/Models/CrowdSourcingProject/CrowdSourcingProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @property string $logo_path
* @property int $user_creator_id
* @property int $language_id
* @property int $max_votes_per_user_for_solutions
* @property int $status_id
* @property string $sm_featured_img_path
* @property string $lp_questionnaire_img_path
Expand Down Expand Up @@ -56,7 +57,8 @@ class CrowdSourcingProject extends Model {
*/
protected $fillable = [
'slug', 'external_url', 'img_path',
'logo_path', 'user_creator_id', 'language_id', 'status_id',
'logo_path', 'user_creator_id', 'language_id',
'max_votes_per_user_for_solutions', 'status_id',
'sm_featured_img_path', 'lp_questionnaire_img_path',
'lp_show_speak_up_btn', 'lp_primary_color', 'lp_btn_text_color_theme',
'should_send_email_after_questionnaire_response',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void {
Schema::table('crowd_sourcing_projects', function (Blueprint $table) {
$table->integer('max_votes_per_user_for_solutions')->after('language_id')->default(5);
});
}

/**
* Reverse the migrations.
*/
public function down(): void {
Schema::table('crowd_sourcing_projects', function (Blueprint $table) {
//
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@

<br>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="max_votes_per_user_for_solutions">
Number of votes per user (for solutions)
</label>
<input id="max_votes_per_user_for_solutions" type="number" class="form-control"
name="max_votes_per_user_for_solutions"
value="{{ old('max_votes_per_user_for_solutions') ? old('max_votes_per_user_for_solutions') : $viewModel->project->max_votes_per_user_for_solutions }}">
</div>
</div>

<br>
</div>
<div class="row">
<label class="col-sm-12 control-label" for="name">Project Name (<span
class="red">*</span>)</label>
Expand Down

0 comments on commit 12f07b7

Please sign in to comment.