Source

iredadmin-ose / libs / pgsql / admin.py

Diff from to

libs/pgsql/admin.py

             )
 
         try:
-            result = self.conn.select('admin', what='COUNT(username) AS total')
-            if len(result) > 0:
-                total = result[0].total or 0
-        except Exception:
-            pass
+            # Get number of total accounts
+            # Separate admin accounts
+            admins_total = self.conn.select('admin', what='COUNT(username) AS total')
+            if admins_total:
+                admins_total = admins_total[0].total or 0
 
-        try:
-            result = self.conn.query(
+            # Users marked as admin
+            useradmins_total = self.conn.select(
+                'mailbox',
+                what='COUNT(username) AS total',
+                where='isadmin=1',
+            )
+            if useradmins_total:
+                useradmins_total = useradmins_total[0].total or 0
+
+            total = admins_total + useradmins_total
+
+            # Get records
+            # Separate admins
+            admins_records = self.conn.query(
                 """
                 SELECT name, username, language, active
                 FROM admin
                 %s
                 """ % (self.sql_limit)
             )
-            return (True, total, list(result))
+
+            useradmins_records = self.conn.query(
+                """
+                SELECT name, username, language, active, isadmin, isglobaladmin
+                FROM mailbox
+                ORDER BY username ASC
+                %s
+                """ % (self.sql_limit)
+            )
+            return (True, {'total': total, 'records': list(admins_records) + list(useradmins_records)})
         except Exception, e:
             return (False, str(e))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.