SHOW:
|
|
- or go back to the newest paste.
| 1 | @[Controller("thing")]
| |
| 2 | @[VirtualAction("new", "create", Protect(Role("admin")))]
| |
| 3 | @[VirtualAction("edit", "update", Protect(OwnerRelation))]
| |
| 4 | class ThingController : ApplicationController {
| |
| 5 | ||
| 6 | @[Action, Protect(Role("admin"))]
| |
| 7 | void create ( Request req, Response res ) {...}
| |
| 8 | ||
| 9 | @[Action] | |
| 10 | void index ( Request req, Response res ) {...}
| |
| 11 | ||
| 12 | @[Action, Protect(Role("member"))]
| |
| 13 | void show ( Request req, Response res ) {...}
| |
| 14 | ||
| 15 | @[Action, Protect(OwnerRelation)] | |
| 16 | void update ( Request req, Response res ) {...}
| |
| 17 | ||
| 18 | @[Action("delete"), Protect(Role("admin"))]
| |
| 19 | void remove ( Request req, Response res ) {...}
| |
| 20 | ||
| 21 | } | |
| 22 | ||
| 23 | ||
| 24 | @[Model("thing")]
| |
| 25 | @[ForbidMassAssignment] | |
| 26 | class Thing : Model {
| |
| 27 | ||
| 28 | @[Attr, Shallow] | |
| 29 | @[Validate( Present, Unique, Length("<=", 128) )]
| |
| 30 | A!string name; | |
| 31 | ||
| 32 | @[Attr, Shallow] | |
| 33 | @[Validate( Length("[]", 16, 256) )]
| |
| 34 | A!string description; | |
| 35 | ||
| 36 | @[Attr(BelongsTo, User), Shallow] | |
| 37 | @[Validate( Present )] | |
| 38 | A!User user; | |
| 39 | ||
| 40 | @[Attr(HasMany, Tag, Through(Tagging))] | |
| 41 | @[Validate( NoDuplicate )] | |
| 42 | A!(Tagging[]) tags; | |
| 43 | ||
| 44 | @[Attr] | |
| 45 | @[Validate( Present )] | |
| 46 | A!ulong size; | |
| 47 | ||
| 48 | @[Attr] | |
| 49 | @[Validate( Present )] | |
| 50 | A!ulong weight; | |
| 51 | ||
| 52 | @property | |
| 53 | ulong ratio () {...}
| |
| 54 | ||
| 55 | } |