def preferences(module=None, preference=None): """Fetch all/or requested preferences of pgAdmin IV.""" if module is not None and preference is not None: try: m = Preferences.module(module, create=False) if m is None: return Response(status=404) p = m.preference(preference) if p is None: return Response(status=404) return ajax_response(response=p.to_json(), status=200) except Exception as e: return internal_server_error(errormsg=str(e)) # Load Preferences pref = Preferences.preferences() res = [] def label(p): return gettext(p['label']) _group_pref_by_categories(pref, res, label) return ajax_response(response=sorted(res, key=label), status=200)
def preferences(module=None, preference=None): """Fetch all/or requested preferences of pgAdmin IV.""" if module is not None and preference is not None: try: m = Preferences.module(module, create=False) if m is None: return Response(status=404) p = m.preference(preference) if p is None: return Response(status=404) return ajax_response(response=p.to_json(), status=200) except Exception as e: return internal_server_error(errormsg=str(e)) # Load Preferences pref = Preferences.preferences() res = [] def label(p): return gettext(p['label']) for m in pref: if len(m['categories']): om = { "id": m['id'], "label": gettext(m['label']), "inode": True, "open": True, "branch": [] } for c in m['categories']: for p in c['preferences']: if 'label' in p and p['label'] is not None: p['label'] = gettext(p['label']) if 'help_str' in p and p['help_str'] is not None: p['help_str'] = gettext(p['help_str']) oc = { "id": c['id'], "mid": m['id'], "label": gettext(c['label']), "inode": False, "open": False, "preferences": sorted(c['preferences'], key=label) } (om['branch']).append(oc) om['branch'] = sorted(om['branch'], key=label) res.append(om) return ajax_response(response=sorted(res, key=label), status=200)
def preferences_s(): """Fetch all preferences for caching.""" # Load Preferences pref = Preferences.preferences() res = [] for m in pref: if len(m['categories']): for c in m['categories']: for p in c['preferences']: p['module'] = m['name'] res.append(p) return ajax_response(response=res, status=200)
def preferences_s(): """Fetch all preferences for caching.""" # Load Preferences pref = Preferences.preferences() res = [] for m in pref: if len(m['categories']): for c in m['categories']: for p in c['preferences']: p['module'] = m['name'] res.append(p) return ajax_response( response=res, status=200 )
def preferences(): """Fetch all the preferences of pgAdmin IV.""" # Load Preferences preferences = Preferences.preferences() res = [] def label(p): return p['label'] for m in preferences: if len(m['categories']): om = { "id": m['id'], "label": m['label'], "inode": True, "open": True, "branch": [] } for c in m['categories']: oc = { "id": c['id'], "mid": m['id'], "label": c['label'], "inode": False, "open": False, "preferences": sorted(c['preferences'], key=label) } (om['branch']).append(oc) om['branch'] = sorted(om['branch'], key=label) res.append(om) return ajax_response(response=sorted(res, key=label), status=200)
def preferences(module=None, preference=None): """Fetch all/or requested preferences of pgAdmin IV.""" if module is not None and preference is not None: try: m = Preferences.module(module, create=False) if m is None: return Response(status=404) p = m.preference(preference) if p is None: return Response(status=404) return ajax_response( response=p.to_json(), status=200 ) except Exception as e: return internal_server_error(errormsg=str(e)) # Load Preferences pref = Preferences.preferences() res = [] def label(p): return gettext(p['label']) for m in pref: if len(m['categories']): om = { "id": m['id'], "label": gettext(m['label']), "inode": True, "open": True, "branch": [] } for c in m['categories']: for p in c['preferences']: if 'label' in p and p['label'] is not None: p['label'] = gettext(p['label']) if 'help_str' in p and p['help_str'] is not None: p['help_str'] = gettext(p['help_str']) oc = { "id": c['id'], "mid": m['id'], "label": gettext(c['label']), "inode": False, "open": False, "preferences": sorted(c['preferences'], key=label) } (om['branch']).append(oc) om['branch'] = sorted(om['branch'], key=label) res.append(om) return ajax_response( response=sorted(res, key=label), status=200 )