Add 'awaiting review' and 'reviewed' project statuses that update from GitHub; allow project owners to update their project statuses

This commit is contained in:
Alex Cabal 2025-01-27 15:38:47 -06:00
parent b48f3a5798
commit 6378d687d8
12 changed files with 204 additions and 21 deletions

View file

@ -28,7 +28,7 @@ try{
session_unset();
}
$inProgressProjects = Project::GetAllByStatus(Enums\ProjectStatusType::InProgress);
$inProgressProjects = Project::GetAllByStatuses([Enums\ProjectStatusType::InProgress, Enums\ProjectStatusType::AwaitingReview, Enums\ProjectStatusType::Reviewed]);
$stalledProjects = Project::GetAllByStatus(Enums\ProjectStatusType::Stalled);
}
catch(Exceptions\LoginRequiredException){

View file

@ -10,12 +10,12 @@ try{
throw new Exceptions\LoginRequiredException();
}
if(!Session::$User->Benefits->CanEditProjects){
throw new Exceptions\InvalidPermissionsException();
}
// POSTing a new `Project`.
if($httpMethod == Enums\HttpMethod::Post){
if(!Session::$User->Benefits->CanEditProjects){
throw new Exceptions\InvalidPermissionsException();
}
$project = new Project();
$project->FillFromHttpPost();
@ -69,6 +69,10 @@ try{
// PUTing a `Project`.
if($httpMethod == Enums\HttpMethod::Put){
if(!Session::$User->Benefits->CanEditProjects){
throw new Exceptions\InvalidPermissionsException();
}
$project = Project::Get(HttpInput::Int(GET, 'project-id'));
$exceptionRedirectUrl = $project->EditUrl;
@ -80,6 +84,32 @@ try{
http_response_code(Enums\HttpCode::SeeOther->value);
header('Location: ' . $project->Ebook->Url);
}
// PATCHing a `Project`.
if($httpMethod == Enums\HttpMethod::Patch){
$project = Project::Get(HttpInput::Int(GET, 'project-id'));
$exceptionRedirectUrl = $project->EditUrl;
if(
!Session::$User->Benefits->CanEditProjects
&&
(
$project->ManagerUserId != Session::$User->UserId
||
$project->ReviewerUserId != Session::$User->UserId
)
){
throw new Exceptions\InvalidPermissionsException();
}
$project->PropertyFromHttp('Status');
$project->Save();
$_SESSION['is-project-saved'] = true;
http_response_code(Enums\HttpCode::SeeOther->value);
header('Location: ' . $project->Ebook->Url);
}
}
catch(Exceptions\EbookNotFoundException){
Template::ExitWithCode(Enums\HttpCode::NotFound);