<commit_before>package views.html.user

import play.api.i18n.Lang

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.evaluation.Display
import lila.security.{ FingerHash, Permission }
import lila.playban.RageSit
import lila.user.User

import controllers.routes

object mod {

  def menu(u: User)(implicit ctx: Context) = div(id := "mz_menu")(
    div(cls := "inner")(
      a(href := "#mz_actions")("Actions"),
      canViewRoles(u) option a(href := "#mz_roles")("Roles"),
      a(href := "#mz_irwin")("Irwin"),
      a(href := "#mz_assessments")("Evaluation"),
      a(href := "#mz_plan", cls := "mz_plan")("Patron"),
      a(href := "#mz_mod_log")("Mod log"),
      a(href := "#mz_reports_out")("Reports sent"),
      a(href := "#mz_reports_in")("Reports received"),
      a(href := "#mz_others")("Accounts"),
      a(href := "#mz_identification")("Identification"),
      a(href := "#us_profile")("Profile")
    )
  )

  def actions(u: User, emails: User.Emails, erased: User.Erased)(implicit ctx: Context): Frag =
    div(id := "mz_actions")(
      isGranted(_.UserEvaluate) option div(cls := "btn-rack")(
        postForm(action := routes.Mod.spontaneousInquiry(u.username), title := "Start an inquiry")(
          submitButton(cls := "btn-rack__btn inquiry")(i)
        ),
        postForm(
          action := routes.Mod.refreshUserAssess(u.username),
          title := "Collect data and ask irwin",
          cls := "xhr"
        )(
          submitButton(cls := "btn-rack__btn")("Evaluate")
        ),
        isGranted(_.Shadowban) option {
          a(
            cls := "btn-rack__btn",
            href := routes.Mod.communicationPublic(u.id),
            title := "View communications"
          )("Comms")
        },
        postForm(action := routes.Mod.notifySlack(u.id), title := "Notify #tavern", cls := "xhr")(
          submitButton(cls := "btn-rack__btn")("Slack")
        )
      ),
      div(cls := "btn-rack")(
        isGranted(_.CloseAccount) option {
          postForm(
            action := routes.Mod.alt(u.username, !u.marks.alt),
            title := "Preemptively close unauthorized alt.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.alt))("Alt")
          )
        },
        isGranted(_.MarkEngine) option {
          postForm(
            action := routes.Mod.engine(u.username, !u.marks.engine),
            title := "This user is clearly cheating.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.engine))("Engine")
          )
        },
        isGranted(_.MarkBooster) option {
          postForm(
            action := routes.Mod.booster(u.username, !u.marks.boost),
            title := "Marks the user as a booster or sandbagger.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.boost))("Booster")
          )
        },
        isGranted(_.Shadowban) option {
          postForm(
            action := routes.Mod.troll(u.username, !u.marks.troll),
            title := "Enable/disable communication features for this user.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.troll))("Shadowban")
          )
        },
        u.marks.troll option {
          postForm(
            action := routes.Mod.deletePmsAndChats(u.username),
            title := "Delete all PMs and public chat messages",
            cls := "xhr"
          )(
            submitButton(cls := "btn-rack__btn confirm")("Clear PMs & chats")
          )
        },
        isGranted(_.RemoveRanking) option {
          postForm(<commit_msg>only show clearPMs button to SB mods - closes lichess-org/talk#42<commit_after>package views.html.user

import play.api.i18n.Lang

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.evaluation.Display
import lila.security.{ FingerHash, Permission }
import lila.playban.RageSit
import lila.user.User

import controllers.routes

object mod {

  def menu(u: User)(implicit ctx: Context) = div(id := "mz_menu")(
    div(cls := "inner")(
      a(href := "#mz_actions")("Actions"),
      canViewRoles(u) option a(href := "#mz_roles")("Roles"),
      a(href := "#mz_irwin")("Irwin"),
      a(href := "#mz_assessments")("Evaluation"),
      a(href := "#mz_plan", cls := "mz_plan")("Patron"),
      a(href := "#mz_mod_log")("Mod log"),
      a(href := "#mz_reports_out")("Reports sent"),
      a(href := "#mz_reports_in")("Reports received"),
      a(href := "#mz_others")("Accounts"),
      a(href := "#mz_identification")("Identification"),
      a(href := "#us_profile")("Profile")
    )
  )

  def actions(u: User, emails: User.Emails, erased: User.Erased)(implicit ctx: Context): Frag =
    div(id := "mz_actions")(
      isGranted(_.UserEvaluate) option div(cls := "btn-rack")(
        postForm(action := routes.Mod.spontaneousInquiry(u.username), title := "Start an inquiry")(
          submitButton(cls := "btn-rack__btn inquiry")(i)
        ),
        postForm(
          action := routes.Mod.refreshUserAssess(u.username),
          title := "Collect data and ask irwin",
          cls := "xhr"
        )(
          submitButton(cls := "btn-rack__btn")("Evaluate")
        ),
        isGranted(_.Shadowban) option {
          a(
            cls := "btn-rack__btn",
            href := routes.Mod.communicationPublic(u.id),
            title := "View communications"
          )("Comms")
        },
        postForm(action := routes.Mod.notifySlack(u.id), title := "Notify #tavern", cls := "xhr")(
          submitButton(cls := "btn-rack__btn")("Slack")
        )
      ),
      div(cls := "btn-rack")(
        isGranted(_.CloseAccount) option {
          postForm(
            action := routes.Mod.alt(u.username, !u.marks.alt),
            title := "Preemptively close unauthorized alt.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.alt))("Alt")
          )
        },
        isGranted(_.MarkEngine) option {
          postForm(
            action := routes.Mod.engine(u.username, !u.marks.engine),
            title := "This user is clearly cheating.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.engine))("Engine")
          )
        },
        isGranted(_.MarkBooster) option {
          postForm(
            action := routes.Mod.booster(u.username, !u.marks.boost),
            title := "Marks the user as a booster or sandbagger.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.boost))("Booster")
          )
        },
        isGranted(_.Shadowban) option {
          postForm(
            action := routes.Mod.troll(u.username, !u.marks.troll),
            title := "Enable/disable communication features for this user.",
            cls := "xhr"
          )(
            submitButton(cls := List("btn-rack__btn" -> true, "active" -> u.marks.troll))("Shadowban")
          )
        },
        (u.marks.troll && isGranted(_.Shadowban)) option {
          postForm(
            action := routes.Mod.deletePmsAndChats(u.username),
            title := "Delete all PMs and public chat messages",
            cls := "xhr"
          )(
            submitButton(cls := "btn-rack__btn confirm")("Clear PMs & chats")
          )
        },
        isGranted(_.RemoveRanking) option {
          postForm(
{'fraction_non_alphanumeric': 0.16105208603265095, 'fraction_numerical': 0.0007774034724021767, 'mean_word_length': 2.1870355078447563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4086290', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2396, 'n_words': 456}