Fixed archive

This commit is contained in:
Dmitry Khomutov 2017-01-15 22:35:42 +07:00
commit 18ac9fadaf
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
12 changed files with 93 additions and 66 deletions

View file

@ -93,8 +93,13 @@ class BuildController extends Controller
$delete = Lang::get('delete_build');
$deleteLink = APP_URL . 'build/delete/' . $build->getId();
$project = b8\Store\Factory::getStore('Project')->getByPrimaryKey($build->getProjectId());
$actions = "<a class=\"btn btn-default\" href=\"{$rebuildLink}\">{$rebuild}</a> ";
$actions = '';
if (!$project->getArchived()) {
$actions .= "<a class=\"btn btn-default\" href=\"{$rebuildLink}\">{$rebuild}</a> ";
}
if ($this->currentUserIsAdmin()) {
$actions .= " <a class=\"btn btn-danger\" id=\"delete-build\" href=\"{$deleteLink}\">{$delete}</a>";
@ -157,9 +162,10 @@ class BuildController extends Controller
*/
public function rebuild($buildId)
{
$copy = BuildFactory::getBuildById($buildId);
$copy = BuildFactory::getBuildById($buildId);
$project = b8\Store\Factory::getStore('Project')->getByPrimaryKey($copy->getProjectId());
if (empty($copy)) {
if (empty($copy) || $project->getArchived()) {
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
}

View file

@ -53,9 +53,11 @@ class GroupController extends Controller
'title' => $group->getTitle(),
'id' => $group->getId(),
];
$projects = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId());
$thisGroup['projects'] = $projects['items'];
$groups[] = $thisGroup;
$projects_active = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), false);
$projects_archived = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), true);
$thisGroup['projects'] = array_merge($projects_active['items'], $projects_archived['items']);
$groups[] = $thisGroup;
}
$this->layout->title = Lang::get('group_projects');

View file

@ -110,6 +110,7 @@ class HomeController extends Controller
/**
* Get a summary of the project groups we have, and what projects they have in them.
*
* @return array
*/
protected function getGroupInfo()
@ -119,7 +120,7 @@ class HomeController extends Controller
foreach ($groups['items'] as $group) {
$thisGroup = ['title' => $group->getTitle()];
$projects = $this->projectStore->getByGroupId($group->getId());
$projects = $this->projectStore->getByGroupId($group->getId(), false);
$thisGroup['projects'] = $projects['items'];
$thisGroup['summary'] = $this->getSummaryHtml($thisGroup['projects']);
$rtn[] = $thisGroup;

View file

@ -111,7 +111,7 @@ class ProjectController extends PHPCensor\Controller
$branch = $project->getBranch();
}
if (empty($project)) {
if (empty($project) || $project->getArchived()) {
throw new NotFoundException(Lang::get('project_x_not_found', $projectId));
}

View file

@ -13,6 +13,7 @@ namespace PHPCensor\Controller;
use b8;
use b8\Store;
use Exception;
use PHPCensor\Helper\Lang;
use PHPCensor\Model\Project;
use PHPCensor\Service\BuildService;
use PHPCensor\Store\BuildStore;
@ -20,6 +21,7 @@ use PHPCensor\Store\ProjectStore;
use b8\Controller;
use b8\Config;
use b8\HttpClient;
use b8\Exception\HttpException\NotFoundException;
/**
* Webhook Controller - Processes webhook pings from BitBucket, Github, Gitlab, etc.
@ -444,6 +446,10 @@ class WebhookController extends Controller
$commitMessage,
array $extra = null
) {
if ($project->getArchived()) {
throw new NotFoundException(Lang::get('project_x_not_found', $project->getId()));
}
// Check if a build already exists for this commit ID:
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);