Skip to content

Commit

Permalink
Console: Fix console event type filters. See klenin#242
Browse files Browse the repository at this point in the history
  • Loading branch information
klenin committed Mar 1, 2018
1 parent 1fb3496 commit ef94e96
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
10 changes: 8 additions & 2 deletions cgi-bin/CATS/Router.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ BEGIN {
}

sub bool() { qr/^1$/ }
sub bool0() { qr/^[01]$/ }
sub integer() { qr/^[0-9]+$/ } # 'int' is reserved.
sub fixed() { qr/^[+-]?([0-9]*[.])?[0-9]+$/ }
sub sha() { qr/^[a-h0-9]+$/ }
Expand All @@ -36,6 +37,11 @@ BEGIN {

# Separate BEGIN block to allow prototypes to have effect.
BEGIN {
my %console_params = (
selection => clist_of integer,
show_contests => bool0, show_messages => bool0, show_results => bool0,
);

$main_routes = {
login => [ \&CATS::UI::LoginLogout::login_frame,
logout => bool, login => str, passwd => str, redir => str, cid => integer, ],
Expand Down Expand Up @@ -63,11 +69,11 @@ $main_routes = {
save => bool, ],

console_content => [ \&CATS::UI::Console::console_content_frame,
selection => clist_of integer,
%console_params,
],
console => [ \&CATS::UI::Console::console_frame,
delete_question => integer, delete_message => integer, send_question => bool, question_text => str,
selection => clist_of integer,
%console_params,
],
console_export => \&CATS::UI::Console::export_frame,
console_graphs => \&CATS::UI::Console::graphs_frame,
Expand Down
16 changes: 6 additions & 10 deletions cgi-bin/CATS/UI/Console.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ sub send_question_to_jury {
}

sub _get_settings {
my ($lv) = @_;
my ($p, $lv) = @_;
my $s = $lv->settings;
$s->{i_value} = param('i_value') // $s->{i_value} // 1;
$s->{i_unit} = param('i_unit') || $s->{i_unit} || 'hours';
$s->{show_results} = param('show_results') // $s->{show_results} // 1;
$s->{show_messages} = param('show_messages') // $s->{show_messages} // 0;
$s->{show_contests} = param('show_contests') // $s->{show_contests} // 0;
if ($is_jury) {
$s->{$_} = $lv->submitted ? ($p->{$_} ? 1 : 0) : ($p->{$_} // $s->{$_} // 1)
for qw(show_contests show_messages show_results);
}
$s;
}

Expand Down Expand Up @@ -100,12 +101,7 @@ sub _console_content {
group_submissions($p->{selection}, param('by_reference')) if defined param('create_group');
}

my $s = _get_settings($lv);

if (grep defined param($_), qw(search filter visible)) {
$s->{$_} = param($_) ? 1 : !$is_jury
for qw(show_contests show_messages show_results);
}
my $s = _get_settings($p, $lv);

$t->param($_ => $s->{$_}) for qw(show_contests show_messages show_results i_value);

Expand Down
6 changes: 3 additions & 3 deletions tt/console.html.tt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function get_element(name) {
[% ELSE %]<a href="[% href_my_events_only %]">[% capt.filter_my %]</a>[% END %]
[% IF user.is_jury %]
<span class="nobr">
<label title="[% capt.contests %]">[% checkbox('show_contests', show_contests) %] [% capt.contests_short %]</label>
<label title="[% capt.messages %]">[% checkbox('show_messages', show_messages) %] [% capt.messages_short %]</label>
<label title="[% capt.results %]">[% checkbox('show_results', show_results) %] [% capt.results_short %]</label>
<label title="[% capt.contests %]">[% checkbox_1('show_contests', show_contests) %] [% capt.contests_short %]</label>
<label title="[% capt.messages %]">[% checkbox_1('show_messages', show_messages) %] [% capt.messages_short %]</label>
<label title="[% capt.results %]">[% checkbox_1('show_results', show_results) %] [% capt.results_short %]</label>
</span>
[% END %]
<span class="nobr">[% capt.for %] [% select_value('i_value', i_values, i_value) %] [% select('i_unit', i_units) %]</span>
Expand Down

0 comments on commit ef94e96

Please sign in to comment.