diff options
-rw-r--r-- | elm/ReleaseEdit.elm | 11 | ||||
-rw-r--r-- | lib/VNWeb/Releases/Edit.pm | 20 | ||||
-rw-r--r-- | lib/VNWeb/Releases/Page.pm | 4 | ||||
-rw-r--r-- | lib/VNWeb/Validation.pm | 2 | ||||
-rw-r--r-- | sql/schema.sql | 4 | ||||
-rw-r--r-- | util/updates/2021-11-29-release-unknown-uncensored.sql | 5 |
6 files changed, 33 insertions, 13 deletions
diff --git a/elm/ReleaseEdit.elm b/elm/ReleaseEdit.elm index 2a45e296..25d8f660 100644 --- a/elm/ReleaseEdit.elm +++ b/elm/ReleaseEdit.elm @@ -47,7 +47,7 @@ type alias Model = , catalog : String , released : D.RDate , minage : Maybe Int - , uncensored : Bool + , uncensored : Maybe Bool , resoX : Int , resoY : Int , reso : A.Model GApi.ApiResolutions @@ -169,7 +169,7 @@ type Msg | Catalog String | Released D.RDate | Minage (Maybe Int) - | Uncensored Bool + | Uncensored (Maybe Bool) | Resolution (A.Msg GApi.ApiResolutions) | Voiced Int | AniStory Int @@ -348,7 +348,12 @@ viewGen model = , if model.minage == Just 18 then inputSelect "" model.ani_ero AniEro [] GT.animated else text "" ] , if model.minage /= Just 18 then text "" else - formField "" [ label [] [ inputCheck "" model.uncensored Uncensored, text " Uncensored (No mosaic or other optical censoring, only check if this release has erotic content)" ] ] + formField "uncensored::Censoring" + [ inputSelect "uncensored" model.uncensored Uncensored [] + [ (Nothing, "Unknown") + , (Just False, "Censored graphics") + , (Just True, "Uncensored graphics") ] + , text " Whether erotic graphics are censored with mosaic or other optical censoring." ] , tr [ class "newpart" ] [ td [ colspan 2 ] [ text "External identifiers & links" ] ] , formField "gtin::JAN/UPC/EAN" 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() diff --git a/sql/schema.sql b/sql/schema.sql index c3e21354..c80b3e53 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -383,7 +383,7 @@ CREATE TABLE releases ( -- dbentry_type=r patch boolean NOT NULL DEFAULT FALSE, -- [pub] freeware boolean NOT NULL DEFAULT FALSE, -- [pub] doujin boolean NOT NULL DEFAULT FALSE, -- [pub] (deprecated) - uncensored boolean NOT NULL DEFAULT FALSE, -- [pub] + uncensored boolean, -- [pub] official boolean NOT NULL DEFAULT TRUE, -- [pub] locked boolean NOT NULL DEFAULT FALSE, hidden boolean NOT NULL DEFAULT FALSE, @@ -438,7 +438,7 @@ CREATE TABLE releases_hist ( patch boolean NOT NULL DEFAULT FALSE, freeware boolean NOT NULL DEFAULT FALSE, doujin boolean NOT NULL DEFAULT FALSE, - uncensored boolean NOT NULL DEFAULT FALSE, + uncensored boolean, official boolean NOT NULL DEFAULT TRUE, title varchar(300) NOT NULL DEFAULT '', original varchar(250) NOT NULL DEFAULT '', diff --git a/util/updates/2021-11-29-release-unknown-uncensored.sql b/util/updates/2021-11-29-release-unknown-uncensored.sql new file mode 100644 index 00000000..a3db3873 --- /dev/null +++ b/util/updates/2021-11-29-release-unknown-uncensored.sql @@ -0,0 +1,5 @@ +ALTER TABLE releases ALTER COLUMN uncensored DROP NOT NULL, ALTER COLUMN uncensored DROP DEFAULT; +ALTER TABLE releases_hist ALTER COLUMN uncensored DROP NOT NULL, ALTER COLUMN uncensored DROP DEFAULT; +\i sql/editfunc.sql +UPDATE releases SET uncensored = NULL WHERE minage <> 18; +UPDATE releases_hist SET uncensored = NULL WHERE minage <> 18; |