From 097459d3b224fa20e12608747cfa1aba0be132e6 Mon Sep 17 00:00:00 2001
From: Jan Mach <jan.mach@cesnet.cz>
Date: Mon, 24 Feb 2020 10:29:37 +0100
Subject: [PATCH] Added base view DecoratedView for integration of plain view
 functions.

---
 lib/hawat/base.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/hawat/base.py b/lib/hawat/base.py
index 87ee99c1f..be579b44a 100644
--- a/lib/hawat/base.py
+++ b/lib/hawat/base.py
@@ -29,6 +29,7 @@ Module contents
 
 * :py:class:`SQLAlchemyMixin`
 * :py:class:`PsycopgMixin`
+* :py:class:`DecoratedView`
 * :py:class:`BaseView`
 
     * :py:class:`FileNameView`
@@ -972,6 +973,26 @@ class PsycopgMixin:
 #-------------------------------------------------------------------------------
 
 
+class DecoratedView:
+    """
+    Wrapper class for classical decorated view functions.
+    """
+    def __init__(self, view_function):
+        self.view_function = view_function
+
+    def get_view_name(self):
+        """Simple adapter method to enable support of classical decorated views."""
+        return self.view_function.__name__
+
+    def get_view_endpoint(self):
+        """Simple adapter method to enable support of classical decorated views."""
+        return self.get_view_name()
+
+    def get_view_icon(self):
+        """Simple adapter method to enable support of classical decorated views."""
+        return 'view-{}'.format(self.get_view_name())
+
+
 class BaseView(flask.views.View):
     """
     Base class for all custom Hawat application views.
-- 
GitLab