Skip to content

Commit fcd1158

Browse files
committed
last twig round
1 parent d2d9e17 commit fcd1158

13 files changed

+332
-229
lines changed

entities/GitHub/GitHubPatch.php

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ public function getPatchURL() : string {
148148
urlencode($this->repo_branch);
149149
}
150150

151+
public function getCommitURL(string $hash) : string {
152+
$repo = $this->group->getRepository();
153+
return 'https://github.com/' . $repo->name() . '/commit/' . $hash;
154+
}
155+
151156
public function setPR(\PullRequest $pr) {
152157
$this->pr_number = $pr->getNumber();
153158
}

entities/GitHub/GitHubPullRequest.php

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public function failedCIjobs(string $hash) : array {
125125
if ($check['state'] == 'failure') {
126126
$failed[] = [
127127
'name' => $check['context'],
128+
'url' => $check['target_url'],
128129
'time' => github_parse_date($check['updated_at'])
129130
];
130131
}
@@ -140,6 +141,7 @@ public function failedCIjobs(string $hash) : array {
140141
if ($job['conclusion'] == 'failure') {
141142
$failed[] = [
142143
'name' => $job['name'],
144+
'url' => $job['html_url'],
143145
'time' => github_parse_date($job['completed_at'])
144146
];
145147
}

entities/Patch.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ abstract class Patch
6161
/** @Column */
6262
public int $type;
6363

64-
/** @OneToMany(targetEntity="PatchComment", mappedBy="patch", cascade={"persist"})
64+
/** @OneToMany(targetEntity="PatchComment", mappedBy="patch", cascade={"persist", "remove"})
6565
* @OrderBy({"id" = "ASC"})
6666
*/
6767
public $comments;
6868

69-
/** @OneToMany(targetEntity="PatchCIError", mappedBy="patch", cascade={"persist"})
69+
/** @OneToMany(targetEntity="PatchCIError", mappedBy="patch", cascade={"persist", "remove"})
7070
* @OrderBy({"id" = "ASC"})
7171
*/
7272
public $ci_failures;
@@ -215,6 +215,7 @@ abstract protected function computeLinesAdded() : int;
215215
abstract protected function computeLinesDeleted() : int;
216216
abstract protected function computeFilesModified() : int;
217217
abstract public function getPatchURL() : string;
218+
abstract public function getCommitURL(string $hash) : string;
218219
abstract public function setPR(PullRequest $pr);
219220
abstract public function getPR() : ?PullRequest;
220221

entities/PatchCIError.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ class PatchCIError
2323
/** @Column(length=64) */
2424
public string $hash;
2525

26-
/** @Column(length=128) */
26+
/** @Column */
2727
public string $name;
2828

29-
public function __construct(Patch $patch, string $hash, string $name) {
29+
/** @Column */
30+
public string $url;
31+
32+
public function __construct(Patch $patch, string $hash, string $name,
33+
string $url) {
3034
$this->patch = $patch;
3135
$this->hash = $hash;
3236
$this->name = $name;
37+
$this->url = $url;
38+
}
39+
40+
public function getCommitURL() : string {
41+
return $this->patch->getCommitURL($this->hash);
3342
}
3443
}

entities/ProjGroup.php

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Doctrine\ORM\Mapping\Id;
99
use Doctrine\ORM\Mapping\ManyToMany;
1010
use Doctrine\ORM\Mapping\ManyToOne;
11+
use Doctrine\ORM\Mapping\Table;
12+
use Doctrine\ORM\Mapping\UniqueConstraint;
1113
use Doctrine\ORM\Mapping\OneToMany;
1214

1315
/** @Entity */

index.php

+11-104
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
require 'github.php';
1010
require 'validation.php';
1111

12-
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
13-
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
14-
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
15-
1612
$page = $_REQUEST['page'] ?? '';
1713

1814
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
@@ -24,6 +20,7 @@
2420
$custom_header = null;
2521
$form = null;
2622
$select_form = null;
23+
$comments_form = null;
2724
$embed_file = null;
2825
$info_message = null;
2926
$success_message = null;
@@ -35,6 +32,9 @@
3532
$monospace = null;
3633
$bottom_links = null;
3734
$refresh_url = null;
35+
$confirm = null;
36+
$comments = null;
37+
$ci_failures = null;
3838

3939
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
4040

@@ -59,7 +59,8 @@ function terminate($error_message = null, $template = 'main.html.twig',
5959
$extra_fields = []) {
6060
global $page, $deadline, $table, $lists, $info_box, $form, $select_form;
6161
global $embed_file, $info_message, $success_message, $monospace, $refresh_url;
62-
global $custom_header, $bottom_links, $top_box;
62+
global $custom_header, $bottom_links, $top_box, $confirm, $comments;
63+
global $comments_form, $ci_failures;
6364

6465
$appvar = new \ReflectionClass('\Symfony\Bridge\Twig\AppVariable');
6566
$loader = new \Twig\Loader\FilesystemLoader([
@@ -129,12 +130,17 @@ function terminate($error_message = null, $template = 'main.html.twig',
129130
'top_box' => $top_box,
130131
'info_box' => $info_box,
131132
'monospace' => $monospace,
133+
'confirm' => $confirm,
134+
'comments' => $comments,
135+
'ci_failures' => $ci_failures,
132136
'deadline' => $deadline ? $deadline->format('c') : null,
133137
'bottom_links' => $bottom_links,
134138
'refresh_url' => $refresh_url,
135139
'form' => $form === null ? null : $form->createView(),
136140
'select_form' => $select_form === null
137141
? null : $select_form->createView(),
142+
'comments_form' => $comments_form === null
143+
? null : $comments_form->createView(),
138144
];
139145

140146
if (!$error_message) {
@@ -144,103 +150,4 @@ function terminate($error_message = null, $template = 'main.html.twig',
144150
exit();
145151
}
146152

147-
function filter_by($filters) {
148-
global $page, $request, $formFactory, $select_form;
149-
$select_form = $formFactory->createNamedBuilder('',
150-
Symfony\Component\Form\Extension\Core\Type\FormType::class);
151-
152-
$select_form->add('page', HiddenType::class, [
153-
'data' => $page,
154-
]);
155-
156-
$selected_year = $request->query->get('year', db_get_group_years()[0]['year']);
157-
$selected_shift = $request->query->get('shift', null);
158-
$own_shifts_only = $request->query->get('own_shifts', false) ? true : false;
159-
$selected_group = $request->query->get('group', 'all');
160-
$selected_repo = $request->query->get('repo', 'all');
161-
$return = null;
162-
163-
$selected_shift_obj = $selected_shift && $selected_shift != 'all'
164-
? db_fetch_shift_id($selected_shift) : null;
165-
166-
if (in_array('year', $filters)) {
167-
$years = [];
168-
foreach (db_get_group_years() as $year) {
169-
$years[$year['year']] = $year['year'];
170-
}
171-
$select_form->add('year', ChoiceType::class, [
172-
'label' => 'Year',
173-
'choices' => $years,
174-
'data' => $selected_year,
175-
]);
176-
$return = $selected_year;
177-
}
178-
if (in_array('shift', $filters)) {
179-
$shifts = ['All' => 'all'];
180-
foreach (db_fetch_shifts($selected_year) as $shift) {
181-
if (!has_shift_permissions($shift))
182-
continue;
183-
if ($own_shifts_only && $shift->prof != get_user())
184-
continue;
185-
$shifts[$shift->name] = $shift->id;
186-
}
187-
$select_form->add('shift', ChoiceType::class, [
188-
'label' => 'Shift',
189-
'choices' => $shifts,
190-
'data' => $selected_shift,
191-
]);
192-
}
193-
if (in_array('group', $filters)) {
194-
$groups = ['All' => 'all'];
195-
$return = [];
196-
foreach (db_fetch_groups($selected_year) as $group) {
197-
if (!has_group_permissions($group))
198-
continue;
199-
if ($own_shifts_only && $group->prof() != get_user())
200-
continue;
201-
if ($selected_shift_obj && $group->shift != $selected_shift_obj)
202-
continue;
203-
if ($selected_repo != 'all' && $group->getRepositoryId() != $selected_repo)
204-
continue;
205-
206-
if ($selected_group == 'all' || $group->id == $selected_group)
207-
$return[] = $group;
208-
$groups[$group->group_number] = $group->id;
209-
}
210-
$select_form->add('group', ChoiceType::class, [
211-
'label' => 'Group',
212-
'choices' => $groups,
213-
'data' => $selected_group,
214-
]);
215-
}
216-
if (in_array('repo', $filters)) {
217-
$repos = [];
218-
foreach (db_fetch_groups($selected_year) as $group) {
219-
if (!has_group_permissions($group))
220-
continue;
221-
222-
if ($repo = $group->getRepositoryId())
223-
$repos[$repo] = true;
224-
}
225-
$repos = array_keys($repos);
226-
natsort($repos);
227-
228-
$repos = ['All' => 'all'] + array_combine($repos, $repos);
229-
$select_form->add('repo', ChoiceType::class, [
230-
'label' => 'Repository',
231-
'choices' => $repos,
232-
'data' => $selected_repo,
233-
]);
234-
}
235-
if (in_array('own_shifts', $filters)) {
236-
$select_form->add('own_shifts', CheckboxType::class, [
237-
'label' => 'Show only own shifts',
238-
'data' => $own_shifts_only,
239-
]);
240-
}
241-
$select_form = $select_form->getForm();
242-
$select_form->handleRequest($request);
243-
return $return;
244-
}
245-
246153
terminate();

pages/bugs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
'Project' => $repo ? dolink_ext($repo, $repo->name()) : '',
8686
'Student' => $bug->user->shortName(),
8787
'Issue' => dolink_ext($bug->issue_url, 'link'),
88-
'Description' => $bug->description,
88+
'Description' => ['longdata' => $bug->description],
8989
'Video' => ['html' => $video, 'width' => 100],
9090
'_large_table' => true,
9191
];

0 commit comments

Comments
 (0)