Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP-327: fix bug when a content-manager changes status of problem #244

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions app/BusinessLogicLayer/Problem/ProblemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,23 @@ public function getCreateEditProblemViewModel(?int $id = null): CreateEditProble
}

public function storeProblem(array $attributes): int {
if (isset($attributes['problem-image']) && $attributes['problem-image']->isValid()) {
$imgPath = FileHandler::uploadAndGetPath($attributes['problem-image'], 'problem_img');
}

$crowdSourcingProjectProblem = Problem::create([
'project_id' => $attributes['problem-owner-project'],
'user_creator_id' => Auth::id(),
'slug' => Str::random(16), // temporary - will be changed after record creation
'status_id' => $attributes['problem-status'],
'img_url' => $imgPath,
'default_language_id' => $attributes['problem-default-language'],
]);

$crowdSourcingProjectProblem->slug = Str::slug($attributes['problem-title'] . '-' . $crowdSourcingProjectProblem->id);
$crowdSourcingProjectProblem->save();

if (isset($attributes['problem-image']) && $attributes['problem-image']->isValid()) {
$imgPath = FileHandler::uploadAndGetPath($attributes['problem-image'], 'problem_img');
$crowdSourcingProjectProblem->img_url = $imgPath;
$crowdSourcingProjectProblem->save();
}

$crowdSourcingProjectProblem->defaultTranslation()->create([
'title' => $attributes['problem-title'],
'description' => $attributes['problem-description'],
Expand All @@ -104,15 +105,16 @@ public function storeProblem(array $attributes): int {
* @throws RepositoryException
*/
public function updateProblem(int $id, array $attributes) {
if (isset($attributes['problem-image']) && $attributes['problem-image']->isValid()) {
$imgPath = FileHandler::uploadAndGetPath($attributes['problem-image'], 'problem_img');
}

$modelAttributes['project_id'] = $attributes['problem-owner-project'];
$modelAttributes['slug'] = $attributes['problem-slug'];
$modelAttributes['status_id'] = $attributes['problem-status'];
$modelAttributes['img_url'] = $imgPath;
$modelAttributes['default_language_id'] = $attributes['problem-default-language'];

if (isset($attributes['problem-image']) && $attributes['problem-image']->isValid()) {
$imgPath = FileHandler::uploadAndGetPath($attributes['problem-image'], 'problem_img');
$modelAttributes['img_url'] = $imgPath;
}

$this->problemRepository->update($modelAttributes, $id);

$defaultTranslation = [
Expand Down
Loading