summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-11-29 13:26:55 +0100
committerYorhel <git@yorhel.nl>2021-11-29 13:26:55 +0100
commitfa86ca885a5aa08543207ad8a64d42f05ab52caf (patch)
tree27415688dbf1bce388290fb55e3018ab16cfe981 /lib
parent29c0ce366ef7f089a72732cc7e9ae4f924ded7a3 (diff)
Releases: Allow "uncensored" flag to be unknownHEADmaster
Diffstat (limited to 'lib')
-rw-r--r--lib/VNWeb/Releases/Edit.pm20
-rw-r--r--lib/VNWeb/Releases/Page.pm4
-rw-r--r--lib/VNWeb/Validation.pm2
3 files changed, 18 insertions, 8 deletions
diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm
index fe69d1b6..65cff99e 100644
--- a/lib/VNWeb/Releases/Edit.pm
+++ b/lib/VNWeb/Releases/Edit.pm
@@ -24,7 +24,7 @@ my $FORM = {
catalog => { required => 0, default => '', maxlength => 50 },
released => { default => 99999999, min => 1, rdate => 1 },
minage => { required => 0, default => undef, int => 1, enum => \%AGE_RATING },
- uncensored => { anybool => 1 },
+ uncensored => { required => 0, jsonbool => 1 },
reso_x => { uint => 1, range => [0,32767] },
reso_y => { uint => 1, range => [0,32767] },
voiced => { uint => 1, enum => \%VOICED },
@@ -131,14 +131,24 @@ elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub {
my $e = $new ? { id => 0 } : db_entry $data->{id} or return tuwf->resNotFound;
return elm_Unauth if !can_edit r => $e;
+ $data->{uncensored} = $data->{uncensored}?1:0 if defined $data->{uncensored};
+
if(!auth->permDbmod) {
$data->{hidden} = $e->{hidden}||0;
$data->{locked} = $e->{locked}||0;
}
- $data->{doujin} = $data->{voiced} = $data->{ani_story} = $data->{ani_ero} = 0 if $data->{patch};
- $data->{reso_x} = $data->{reso_y} = 0 if $data->{patch};
- $data->{engine} = '' if $data->{patch};
- $data->{uncensored} = $data->{ani_ero} = 0 if !defined $data->{minage} || $data->{minage} != 18;
+
+ if($data->{patch}) {
+ $data->{doujin} = $data->{voiced} = $data->{ani_story} = $data->{ani_ero} = 0;
+ $data->{reso_x} = $data->{reso_y} = 0;
+ $data->{engine} = '';
+ }
+
+ if(!defined $data->{minage} || $data->{minage} != 18) {
+ $data->{uncensored} = undef;
+ $data->{ani_ero} = 0;
+ }
+
$_->{qty} = $MEDIUM{$_->{medium}}{qty} ? $_->{qty}||1 : 0 for $data->{media}->@*;
$data->{notes} = bb_subst_links $data->{notes};
die "No VNs selected" if !$data->{vn}->@*;
diff --git a/lib/VNWeb/Releases/Page.pm b/lib/VNWeb/Releases/Page.pm
index dbc799f7..5078376a 100644
--- a/lib/VNWeb/Releases/Page.pm
+++ b/lib/VNWeb/Releases/Page.pm
@@ -164,8 +164,8 @@ sub _infotable_ {
tr_ sub {
td_ 'Censoring';
- td_ $r->{uncensored} ? 'No optical censoring (e.g. mosaics)' : 'May include optical censoring (e.g. mosaics)';
- } if $r->{minage} && $r->{minage} == 18;
+ td_ $r->{uncensored} ? 'No optical censoring (like mosaics)' : 'Includes optical censoring (e.g. mosaics)';
+ } if defined $r->{uncensored};
for my $t (qw|developer publisher|) {
my @prod = grep $_->{$t}, @{$r->{producers}};
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm
index 2e3a5a97..9b5bb9c8 100644
--- a/lib/VNWeb/Validation.pm
+++ b/lib/VNWeb/Validation.pm
@@ -44,7 +44,7 @@ TUWF::set custom_validations => {
rdate => { uint => 1, func => \&_validate_rdate },
fuzzyrdate => { func => \&_validate_fuzzyrdate },
# A tri-state bool, returns undef if not present or empty, normalizes to 0/1 otherwise
- undefbool => { required => 0, default => undef, func => sub { $_[0] = $_[0] ? 1 : 0; 1 } },
+ undefbool => { required => 0, default => undef, anybool => 1, func => sub { $_[0] = $_[0] ? 1 : 0; 1 } },
# An array that may be either missing (returns undef), a single scalar (returns single-element array) or a proper array
undefarray => sub { +{ required => 0, default => undef, type => 'array', scalar => 1, values => $_[0] } },
# Accepts a user-entered vote string (or '-' or empty) and converts that into a DB vote number (or undef) - opposite of fmtvote()