Skip to content

Commit

Permalink
fix: republishing bug dix and formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Apr 30, 2024
1 parent fbc7a7a commit a2df7f3
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class BioschemasController extends Controller
* @param Illuminate\Http\Request $request
* @param App\Models\User $username
* @param App\Models\Project $projectName
* @param App\Models\Study $studyName Optional
* @param App\Models\Dataset $datasetName Optional
* @param App\Models\Study $studyName Optional
* @param App\Models\Dataset $datasetName Optional
* @return object
*/
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class DataCiteController extends Controller
* @param Illuminate\Http\Request $request
* @param App\Models\User $username
* @param App\Models\Project $projectName
* @param App\Models\Study $studyName Optional
* @param App\Models\Dataset $datasetName Optional
* @param App\Models\Study $studyName Optional
* @param App\Models\Dataset $datasetName Optional
* @return object
*/
/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/API/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function search(Request $request)
$statement = $statement.')';
}
$statement = $statement.' LIMIT '.$limit;
// dd($statement );
// dd($statement );
} else {
if ($query) {
$query = str_replace("'", "''", $query);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function checkPassword(Request $request)
/**
* Delete the profile photo.
*
* @return \Illuminate\Http\RedirectResponse
* @return \Illuminate\Http\RedirectResponse
*/
public function destroyPhoto(User $user, Request $request)
{
Expand Down
136 changes: 70 additions & 66 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,83 +328,87 @@ public function publish(Request $request, Project $project, PublishProject $publ
if ($project) {
$input = $request->all();
$release_date = $input['release_date'];
if (! $project->is_public && ! is_null($project->doi) && ! is_null($release_date)) {
$release_date = Carbon::parse($release_date);
if ($release_date->isPast()) {
$updater->update($project, $request->all());
$publisher->publish($project);
$project->sendNotification('publish', $this->prepareSendList($project));
}
} else {

$enableProjectMode = $request->get('enableProjectMode');
if ($enableProjectMode) {
$validation = $project->validation;
$validation->process();
$validation = $validation->fresh();
if ($validation['report']['project']['status']) {
$project->release_date = $request->get('release_date');
$project->status = 'queued';
$project->save();

ProcessSubmission::dispatch($project);

return response()->json([
'project' => $project,
'validation' => $validation,
]);
} else {
return response()->json([
'errors' => 'Validation failing. Please provide all the required data and try again. If the problem persists, please contact us.',
'validation' => $validation,
], 422);
}
} else {
$draft = $project->draft;
$draft->project_enabled = false;
$draft->save();

// if (! $project->is_public && ! is_null($project->doi) && ! is_null($release_date)) {
// $release_date = Carbon::parse($release_date);
// if ($release_date->isPast()) {
// $updater->update($project, $input);
// $publisher->publish($project);
// $project->sendNotification('publish', $this->prepareSendList($project));
// $project->status = 'complete';
// $project->save();
// return response()->json([
// 'project' => $project
// ]);
// }
// } else {
$enableProjectMode = $request->get('enableProjectMode');
if ($enableProjectMode) {
$validation = $project->validation;
$validation->process();
$validation = $validation->fresh();
if ($validation['report']['project']['status']) {
$project->release_date = $request->get('release_date');
$project->status = 'queued';
$project->save();

$validation = $project->validation;
$validation->process();
$validation = $validation->fresh();

foreach ($project->studies as $study) {
$study->license_id = $project->license_id;
$study->save();
foreach ($study->datasets as $dataset) {
$dataset->license_id = $project->license_id;
$dataset->save();
}
ProcessSubmission::dispatch($project);

return response()->json([
'project' => $project,
'validation' => $validation,
]);
} else {
return response()->json([
'errors' => 'Validation failing. Please provide all the required data and try again. If the problem persists, please contact us.',
'validation' => $validation,
], 422);
}
} else {
$draft = $project->draft;
$draft->project_enabled = false;
$draft->save();

$project->release_date = $request->get('release_date');
$project->status = 'queued';
$project->save();

$validation = $project->validation;
$validation->process();
$validation = $validation->fresh();

foreach ($project->studies as $study) {
$study->license_id = $project->license_id;
$study->save();
foreach ($study->datasets as $dataset) {
$dataset->license_id = $project->license_id;
$dataset->save();
}
}

$status = true;
$status = true;

foreach ($validation['report']['project']['studies'] as $study) {
if (! $study['status']) {
$status = false;
}
}
// add license check
if ($status) {
ProcessSubmission::dispatch($project);

return response()->json([
'project' => $project,
'validation' => $validation,
]);
} else {
return response()->json([
'errors' => 'Validation failing. Please provide all the required data and try again. If the problem persists, please contact us.',
], 422);
foreach ($validation['report']['project']['studies'] as $study) {
if (! $study['status']) {
$status = false;
}
}

// add license check
if ($status) {
ProcessSubmission::dispatch($project);

return response()->json([
'project' => $project,
'validation' => $validation,
]);
} else {
return response()->json([
'errors' => 'Validation failing. Please provide all the required data and try again. If the problem persists, please contact us.',
], 422);
}
}

// }

}

}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function citations()
/**
* Send Notification via email.
*
* @param string $notifyType (deletion / deletionReminder / archival / archivalAdmin)
* @param string $notifyType (deletion / deletionReminder / archival / archivalAdmin)
* @param array sendTo
* @return void
*/
Expand Down
1 change: 0 additions & 1 deletion app/Models/Schemas/Study.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function studyDomain($studyDomain)
* drugs, etc. investigated by the study.
*
* @param \Spatie\SchemaOrg\Contracts\BioChemEntityContract|\Spatie\SchemaOrg\Contracts\MedicalEntityContract[] $studySubject
* @return static
*/
public function studySubject($studySubject)
Expand Down

0 comments on commit a2df7f3

Please sign in to comment.