src/web: ModelAction can search mentities by full_name
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 19 May 2016 23:32:51 +0000 (19:32 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 20 May 2016 00:18:54 +0000 (20:18 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/web/web_base.nit

index ecf639e..0671cb6 100644 (file)
@@ -92,10 +92,15 @@ class ModelAction
        # Model to use.
        var model: Model
 
+       # Find the MEntity ` with `full_name`.
+       fun find_mentity(model: ModelView, full_name: nullable String): nullable MEntity do
+               if full_name == null then return null
+               return model.mentity_by_full_name(full_name.from_percent_encoding)
+       end
+
        # Init the model view from the `req` uri parameters.
        fun init_model_view(req: HttpRequest): ModelView do
                var view = new ModelView(model)
-
                var show_private = req.bool_arg("private") or else false
                if not show_private then view.min_visibility = protected_visibility