OSDN Git Service

Implementation the Authentication Error.
[open-pdm-light/PartList.git] / PartsList / PartsList / app / controllers / PartsMasterController.scala
index 4cd5b99..1cb34c4 100644 (file)
@@ -23,13 +23,20 @@ object PartsMasterController extends Controller{
            "atach" -> mapping(
                "grpName" -> text
              )(AtachForm.apply)(AtachForm.unapply),
-           "projectName" -> nonEmptyText
+           "projectName" -> nonEmptyText,
+           "cost" -> longNumber
         )(PartForm.apply)(PartForm.unapply)
     )
 
-       def create = Action { implicit request =>
-         Ok(views.html.createPartForm(partRegistForm))
-       }
+       def create = AuthAction {
+     Action { implicit request =>
+       if(request == null) {
+         Ok(views.html.errors.errorNotAuthentication())
+       } else {
+         Ok(views.html.createPartForm(partRegistForm))
+       }
+        }
+    }
 
        def partRegistration() = Action(parse.multipartFormData) { implicit request =>
          partRegistForm.bindFromRequest.fold(
@@ -47,11 +54,17 @@ object PartsMasterController extends Controller{
          )
        }
 
-       def update(id:Long) = Action { implicit request =>
-         inTransaction {
-           val part = PartManager().getById(id)
-           val partForm = PartForm(part.name, null, part.project.assign(part.project.head).name)
-               Ok(views.html.updatePartForm(partRegistForm.fill(partForm), id, part))
+       def update(id:Long) = AuthAction {
+         Action { implicit request =>
+           if(request == null) {
+         Ok(views.html.errors.errorNotAuthentication())
+           } else {
+             inTransaction {
+               val part = PartManager().getById(id)
+               val partForm = PartForm(part.name, null, part.project.assign(part.project.head).name, part.price)
+               Ok(views.html.updatePartForm(partRegistForm.fill(partForm), id, part))
+             }
+           }
          }
        }
 
@@ -70,10 +83,16 @@ object PartsMasterController extends Controller{
          )
        }
 
-       def partDelete(id:Long) = Action {
-         inTransaction {
-           PartManager().delete(id)
-           Home.flashing("success" -> "Part %s has been created".format(id))
+       def partDelete(id:Long) = AuthAction {
+         Action {implicit request =>
+           if(request == null) {
+         Ok(views.html.errors.errorNotAuthentication())
+           } else {
+             inTransaction {
+               PartManager().delete(id)
+               Home.flashing("success" -> "Part %s has been created".format(id))
+               }
+           }
          }
        }