summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-07-09 12:57:41 +0200
committerYorhel <git@yorhel.nl>2020-07-09 12:57:41 +0200
commit9215c6eb5a0128a94a8511aeb72c0f95ab9f99fd (patch)
tree2791c99513cebff84bb50a5a9385619522fddf3c
parent73eb6385240d82424d13235f02822920f51e974b (diff)
User::Edit: Remove "show_nsfw" setting from profile + deprecate NSFW flags
-rw-r--r--elm/User/Edit.elm9
-rw-r--r--lib/VNWeb/Auth.pm2
-rw-r--r--lib/VNWeb/User/Edit.pm5
-rw-r--r--lib/VNWeb/Validation.pm2
-rw-r--r--sql/schema.sql6
5 files changed, 9 insertions, 15 deletions
diff --git a/elm/User/Edit.elm b/elm/User/Edit.elm
index c8ecdddb..c51f37b4 100644
--- a/elm/User/Edit.elm
+++ b/elm/User/Edit.elm
@@ -73,7 +73,6 @@ type AdminMsg
type PrefMsg
= EMail String
- | ShowNsfw Bool
| MaxSexual Int
| MaxViolence Int
| TraitsSexual Bool
@@ -123,7 +122,6 @@ updatePrefs : PrefMsg -> GUE.SendPrefs -> GUE.SendPrefs
updatePrefs msg model =
case msg of
EMail n -> { model | email = n }
- ShowNsfw b -> { model | show_nsfw = b }
MaxSexual n-> { model | max_sexual = n }
MaxViolence n -> { model | max_violence = n }
TraitsSexual b -> { model | traits_sexual = b }
@@ -231,11 +229,8 @@ view model =
prefsform m =
[ tr [ class "newpart" ] [ td [ colspan 2 ] [ text "Preferences" ] ]
- , formField "NSFW" [ label [] [ inputCheck "" m.show_nsfw (Prefs << ShowNsfw), text " Show NSFW images by default" ] ]
- , formField ""
- [ b [ class "grayedout" ] [ text "The two options below are only used for character images at the moment, they will eventually replace the above checkbox and apply to all images on the site." ]
- , br [] []
- , inputSelect "" m.max_sexual (Prefs << MaxSexual) [style "width" "400px"]
+ , formField "NSFW"
+ [ inputSelect "" m.max_sexual (Prefs << MaxSexual) [style "width" "400px"]
[ (-1,"Hide all images")
, (0, "Hide sexually suggestive or explicit images")
, (1, "Hide only sexually explicit images")
diff --git a/lib/VNWeb/Auth.pm b/lib/VNWeb/Auth.pm
index d93faa33..6e4d68c0 100644
--- a/lib/VNWeb/Auth.pm
+++ b/lib/VNWeb/Auth.pm
@@ -260,7 +260,7 @@ sub csrfcheck {
# TODO: Measure global usage of the pref() and prefSet() calls to see if this cache is actually necessary.
my @pref_columns = qw/
- email_confirmed skin customcss filter_vn filter_release show_nsfw notify_dbedit notify_announce
+ email_confirmed skin customcss filter_vn filter_release notify_dbedit notify_announce
vn_list_own vn_list_wish tags_all tags_cont tags_ero tags_tech spoilers traits_sexual
max_sexual max_violence nodistract_can nodistract_noads nodistract_nofancy
/;
diff --git a/lib/VNWeb/User/Edit.pm b/lib/VNWeb/User/Edit.pm
index e4cc2313..e48068e8 100644
--- a/lib/VNWeb/User/Edit.pm
+++ b/lib/VNWeb/User/Edit.pm
@@ -32,7 +32,6 @@ my $FORM = {
# Settings that can only be read/modified by the user itself or a perm_usermod
prefs => { required => 0, type => 'hash', keys => {
email => { email => 1 },
- show_nsfw => { anybool => 1 },
max_sexual => { int => 1, range => [-1, 2 ] },
max_violence => { uint => 1, range => [ 0, 2 ] },
traits_sexual => { anybool => 1 },
@@ -81,7 +80,7 @@ TUWF::get qr{/$RE{uid}/edit}, sub {
$u->{prefs} = $u->{id} == auth->uid || auth->permUsermod ?
tuwf->dbRowi(
- 'SELECT show_nsfw, max_sexual, max_violence, traits_sexual, tags_all, tags_cont, tags_ero, tags_tech, spoilers, skin, customcss
+ 'SELECT max_sexual, max_violence, traits_sexual, tags_all, tags_cont, tags_ero, tags_tech, spoilers, skin, customcss
, nodistract_noads, nodistract_nofancy, support_enabled, uniname, pubskin_enabled
FROM users WHERE id =', \$u->{id}
) : undef;
@@ -118,7 +117,7 @@ elm_api UserEdit => $FORM_OUT, $FORM_IN, sub {
return elm_Taken if $p->{uniname} && tuwf->dbVali('SELECT 1 FROM users WHERE id <>', \$data->{id}, 'AND username =', \lc($p->{uniname}));
$set{$_} = $p->{$_} for qw/
- show_nsfw max_sexual max_violence traits_sexual tags_all tags_cont tags_ero tags_tech spoilers skin customcss
+ max_sexual max_violence traits_sexual tags_all tags_cont tags_ero tags_tech spoilers skin customcss
nodistract_noads nodistract_nofancy support_enabled uniname pubskin_enabled
/;
}
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm
index caf6491d..e122a8be 100644
--- a/lib/VNWeb/Validation.pm
+++ b/lib/VNWeb/Validation.pm
@@ -242,7 +242,7 @@ sub viewget {
{
spoilers => $sp // auth->pref('spoilers') || 0,
traits_sexual => !$ts ? auth->pref('traits_sexual') : $ts eq 's',
- show_nsfw => !$ns ? auth->pref('show_nsfw') : $ns eq 'n',
+ show_nsfw => !$ns ? (auth->pref('max_sexual')||0)==2 && (auth->pref('max_violence')||0)>0 : $ns eq 'n',
}
};
tuwf->req->{view}
diff --git a/sql/schema.sql b/sql/schema.sql
index da475d5d..db1142c7 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -809,7 +809,7 @@ CREATE TABLE users (
customcss text NOT NULL DEFAULT '',
filter_vn text NOT NULL DEFAULT '',
filter_release text NOT NULL DEFAULT '',
- show_nsfw boolean NOT NULL DEFAULT FALSE,
+ show_nsfw boolean NOT NULL DEFAULT FALSE, -- Not used anymore, replaced by max_sexual and max_violence
notify_dbedit boolean NOT NULL DEFAULT TRUE,
notify_announce boolean NOT NULL DEFAULT FALSE,
vn_list_own boolean NOT NULL DEFAULT FALSE,
@@ -857,7 +857,7 @@ CREATE TABLE vn ( -- dbentry_type=v
original varchar(250) NOT NULL DEFAULT '', -- [pub]
alias varchar(500) NOT NULL DEFAULT '', -- [pub]
length smallint NOT NULL DEFAULT 0, -- [pub]
- img_nsfw boolean NOT NULL DEFAULT FALSE, -- [pub]
+ img_nsfw boolean NOT NULL DEFAULT FALSE, -- [pub] (deprecated)
image vndbid CONSTRAINT vn_image_check CHECK(vndbid_type(image) = 'cv'), -- [pub]
"desc" text NOT NULL DEFAULT '', -- [pub]
l_wp varchar(150) NOT NULL DEFAULT '', -- [pub] (deprecated)
@@ -929,7 +929,7 @@ CREATE TABLE vn_screenshots (
id integer NOT NULL, -- [pub]
scr vndbid NOT NULL CONSTRAINT vn_screenshots_scr_check CHECK(vndbid_type(scr) = 'sf'), -- [pub] images.id
rid integer, -- [pub] releases.id (only NULL for old revisions, nowadays not allowed anymore)
- nsfw boolean NOT NULL DEFAULT FALSE, -- [pub]
+ nsfw boolean NOT NULL DEFAULT FALSE, -- [pub] (deprecated)
PRIMARY KEY(id, scr)
);