diff roundup/rest.py @ 5658:3401daf8613b

Fix hardcoded /data Now we return one entry for each class the user may view.
author Ralf Schlatterbeck <rsc@runtux.com>
date Thu, 21 Mar 2019 11:23:09 +0100
parents 207e0f5d551c
children 1e51a709431c
line wrap: on
line diff
--- a/roundup/rest.py	Tue Mar 19 22:01:13 2019 -0400
+++ b/roundup/rest.py	Thu Mar 21 11:23:09 2019 +0100
@@ -1221,19 +1221,15 @@
     @Routing.route("/data")
     @_data_decorator
     def data(self, input):
-        """Describe the sublements of data
+        """Describe the subelements of data
 
-           FIXME: should have a key for every element under data in
-                  the schema the user can access.
-           This is just an example.
+           One entry for each class the user may view
         """
-        result = {
-            "issue": { "link": self.base_path + "/data/" + "issue" },
-            "status": { "link": self.base_path + "/data/" + "status" },
-            "keyword": { "link": self.base_path + "/data/" + "keyword" },
-            "user": { "link": self.base_path + "/data/" + "user" }
-        }
-
+        result = {}
+        uid = self.db.getuid ()
+        for cls in sorted (self.db.classes) :
+            if self.db.security.hasPermission('View', uid, cls) :
+                result [cls] = dict(link = self.base_path + '/data/' + cls)
         return 200, result
 
     @Routing.route("/summary")

Roundup Issue Tracker: http://roundup-tracker.org/