<commit_before>/*
 * Copyright 2013 agwlvssainokuni
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package controllers

import models._
import play.api.Play.current
import play.api.data._
import play.api.data.Forms._
import play.api.data.validation.Constraints._
import play.api.db.DB
import play.api.mvc._
import views.html.{ admin => view }
import routes.{ AdminController => route }

object AdminController extends Controller with CustomActionBuilder {

  val adminForm: Form[Admin] = Form(mapping(
    "loginId" -> nonEmptyText(1, 32),
    "nickname" -> nonEmptyText(1, 255))(Admin.apply)(Admin.unapply))

  val passwdForm: Form[Passwd] = Form(mapping(
    "passwd" -> nonEmptyText(1, 32),
    "passwdConf" -> nonEmptyText(1, 32))(Passwd.apply)(Passwd.unapply))

  def list(pn: Long = 0, ps: Long = 5) = AuthnCustomAction { (adminId, r, c) =>
    Ok(view.list())
  }

  def add() = AuthnCustomAction { (adminId, r, c) =>
    Ok(view.add())
  }

  def create() = AuthnCustomAction { (adminId, r, c) =>
    Redirect(route.edit(1L)).flashing(
      "success" -> "create")
  }

  def edit(id: Long) = AuthnCustomAction { (adminId, r, c) =>
    Ok(view.edit(id))
  }

  def update(id: Long) = AuthnCustomAction { (adminId, r, c) =>
    Redirect(route.edit(id)).flashing(
      "success" -> "update")
  }

  def editPw(id: Long) = AuthnCustomAction { (adminId, r, c) =>
    Ok(view.editPw(id))
  }

  def updatePw(id: Long) = AuthnCustomAction { (adminId, r, c) =>
    Redirect(route.edit(id)).flashing(
      "success" -> "updatePw")
  }

  def delete(id: Long) = AuthnCustomAction { (adminId, r, c) =>
    Redirect(route.list()).flashing(
      "success" -> "delete")
  }

}<commit_msg>lifelog - admin * CustomActionBuilderのカリー化に対応する。<commit_after>/*
 * Copyright 2013 agwlvssainokuni
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package controllers

import models._
import play.api.Play.current
import play.api.data._
import play.api.data.Forms._
import play.api.data.validation.Constraints._
import play.api.db.DB
import play.api.mvc._
import views.html.{ admin => view }
import routes.{ AdminController => route }

object AdminController extends Controller with CustomActionBuilder {

  val adminForm: Form[Admin] = Form(mapping(
    "loginId" -> nonEmptyText(1, 32),
    "nickname" -> nonEmptyText(1, 255))(Admin.apply)(Admin.unapply))

  val passwdForm: Form[Passwd] = Form(mapping(
    "passwd" -> nonEmptyText(1, 32),
    "passwdConf" -> nonEmptyText(1, 32))(Passwd.apply)(Passwd.unapply))

  def list(pn: Long = 0, ps: Long = 5) = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Ok(view.list())
  }

  def add() = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Ok(view.add())
  }

  def create() = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Redirect(route.edit(1L)).flashing(
        "success" -> "create")
  }

  def edit(id: Long) = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Ok(view.edit(id))
  }

  def update(id: Long) = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Redirect(route.edit(id)).flashing(
        "success" -> "update")
  }

  def editPw(id: Long) = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Ok(view.editPw(id))
  }

  def updatePw(id: Long) = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Redirect(route.edit(id)).flashing(
        "success" -> "updatePw")
  }

  def delete(id: Long) = AuthnCustomAction { adminId =>
    implicit req => implicit conn =>
      Redirect(route.list()).flashing(
        "success" -> "delete")
  }

}
{'fraction_non_alphanumeric': 0.13312034078807242, 'fraction_numerical': 0.010223642172523962, 'mean_word_length': 3.5240847784200384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5557839', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1476, 'n_words': 430}