Created
July 10, 2011 09:17
-
-
Save k4200/1074400 to your computer and use it in GitHub Desktop.
A trait that can be mixed in a model that only admin users can do CRUD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file is distributed under the same license as that of Lift. | |
// | |
package com.example { | |
package lib { | |
import net.liftweb._ | |
import common._; | |
import http._; | |
import mapper._ | |
import sitemap._; | |
import Loc._; | |
import proto.{ProtoUser => GenProtoUser} | |
//import util.Helpers.tryo | |
trait AdminEditableCRUDify [KeyType, | |
CrudType <: AdminEditableKeyedMapper[KeyType, CrudType]] | |
extends MegaCRUDify [KeyType, CrudType] { | |
self: CrudType with KeyedMetaMapper[KeyType, CrudType] => | |
val superUser_? = If(() => self.userObject.superUser_? , | |
() => RedirectResponse("/user_mgt/login")); | |
override def showAllMenuLocParams: List[Loc.AnyLocParam] = List(superUser_?); | |
override def viewMenuLocParams: List[Loc.AnyLocParam] = List(superUser_?) | |
override def createMenuLocParams: List[Loc.AnyLocParam] = List(superUser_?); | |
override def editMenuLocParams: List[Loc.AnyLocParam] = List(superUser_?); | |
override def deleteMenuLocParams: List[Loc.AnyLocParam] = List(superUser_?); | |
//override def deleteMenuLoc: Box[Menu] = Empty; | |
} | |
trait AdminEditableKeyedMapper[KeyType, OwnerType <: KeyedMapper[KeyType, OwnerType]] | |
extends KeyedMapper[KeyType, OwnerType] { | |
self: OwnerType => | |
val userObject: GenProtoUser | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MegaCRUDify is here.
https://gist.github.com/1074403