diff options
author | Yorhel <git@yorhel.nl> | 2021-08-05 14:06:19 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-08-05 14:09:16 +0200 |
commit | a85c9ac3683cd2aae8745b43c86fd1f066c93819 (patch) | |
tree | 8e8715d9468b8fcc4e1eb6c3ed2836dfd1df5043 | |
parent | 2e288f7946cd302a610c623937f18dd988753b94 (diff) |
VNLengthVote: Add mod option to delete votes
This is more hard-handed than I'd like, but I'm also not a fan of having
to implement a proper 'ignore' flag.
-rw-r--r-- | css/v2.css | 1 | ||||
-rw-r--r-- | elm/VNLengthVote.elm | 2 | ||||
-rw-r--r-- | lib/VNWeb/VN/Length.pm | 28 |
3 files changed, 30 insertions, 1 deletions
@@ -879,6 +879,7 @@ div.lengthlist { .tc3 { width: 60px; white-space: nowrap } .tc4 { width: 100px; padding-left: 10px } .tc5 { width: 50px } + .tc7 { width: 10px; text-align: right; padding: 0 } } diff --git a/elm/VNLengthVote.elm b/elm/VNLengthVote.elm index 0f799854..48fddcb2 100644 --- a/elm/VNLengthVote.elm +++ b/elm/VNLengthVote.elm @@ -142,7 +142,7 @@ view model = div [class "lengthvotefrm"] <| , inputSelect "" model.speed Speed [style "width" "100%"] [ (-1, "-- how do you estimate your read/play speed? --") , (0, "Slow (e.g. low language proficiency or extra time spent on gameplay)") - , (1, "Normal") + , (1, "Normal (no content skipped, all voices listened to end)") , (2, "Fast (e.g. fast reader or skipping through voices and gameplay)") ] , inputTextArea "" model.notes Notes diff --git a/lib/VNWeb/VN/Length.pm b/lib/VNWeb/VN/Length.pm index b041f8bd..56f32668 100644 --- a/lib/VNWeb/VN/Length.pm +++ b/lib/VNWeb/VN/Length.pm @@ -24,6 +24,11 @@ sub listing_ { my sub url { '?'.query_encode %$opt, @_ } + if(auth->permDbmod) { + form_ method => 'post', action => '/lengthvotes-edit'; + input_ type => 'hidden', class => 'hidden', name => 'url', value => tuwf->reqPath.tuwf->reqQuery, undef; + } + paginate_ \&url, $opt->{p}, [$count, $opt->{s}->results], 't'; div_ class => 'mainbox browse lengthlist', sub { table_ class => 'stripe', sub { @@ -35,6 +40,9 @@ sub listing_ { td_ class => 'tc4', sub { txt_ 'Speed'; sortable_ 'speed', $opt, \&url }; td_ class => 'tc5', 'Rel'; td_ class => 'tc6', 'Notes'; + td_ class => 'tc7', sub { + input_ type => 'submit', class => 'submit', value => 'Del', undef; + } if auth->permDbmod; } }; tr_ sub { td_ class => 'tc1', fmtdate $_->{date}; @@ -46,10 +54,15 @@ sub listing_ { td_ class => 'tc4', ['Slow','Normal','Fast']->[$_->{speed}]; td_ class => 'tc5', sub { a_ href => "/$_->{rid}", $_->{rid} }; td_ class => 'tc6', sub { lit_ bb_format $_->{notes}, inline => 1 }; + td_ class => 'tc7', sub { + input_ type => 'checkbox', name => 'del', value => "$_->{vid}-$_->{uid}", undef + } if auth->permDbmod; } for @$list; }; }; paginate_ \&url, $opt->{p}, [$count, $opt->{s}->results], 'b'; + + end_ 'form' if auth->permDbmod; } @@ -91,6 +104,21 @@ TUWF::get qr{/(?:(?<thing>$RE{vid}|$RE{uid})/)?lengthvotes}, sub { }; +TUWF::post '/lengthvotes-edit', sub { + return tuwf->resDenied if !auth->permDbmod || !samesite; + my $frm = tuwf->validate(post => + url => {}, + del => { required => 0, type => 'array', scalar => 1, values => { regex => "$RE{vid}-$RE{uid}" } } + )->data; + tuwf->dbExeci('DELETE FROM vn_length_votes WHERE', { + vid => (split /-/)[0], + uid => (split /-/)[1], + }) for $frm->{del}->@*; + auth->audit(undef, 'lengthvote-del', join ', ', sort $frm->{del}->@*) if $frm->{del}->@*; + tuwf->resRedirect($frm->{url}, 'post'); +}; + + our $LENGTHVOTE = form_compile any => { uid => { vndbid => 'u' }, vid => { vndbid => 'v' }, |