def read(self, request, workspace_id): get_user_authentication(request) wiring = {} try: igadgets = IGadget.objects.filter(tab__workspace__pk=workspace_id) igadget_data_list = get_wiring_data(igadgets) wiring['iGadgetList'] = igadget_data_list tabs = Tab.objects.filter(workspace__pk=workspace_id) wiring['tabList'] = [get_tab_data(tab) for tab in tabs] except WorkSpace.DoesNotExist: wiring['iGadgetList'] = [] wiring['tabList'] = [] # InOut list inouts = InOut.objects.filter(workspace__pk=workspace_id) wiring['inOutList'] = [get_inout_data(inout) for inout in inouts] # Filter list filters = Filter.objects.all() wiring['filterList'] = [get_filter_data(f) for f in filters] return HttpResponse(json_encode(wiring), mimetype='application/json; charset=UTF-8')
def read(self, request, user_name, screen_id=1): user = user_authentication(user_name) wiring = {} # IGadgets list if not screen_id: screen_id = 1 try: screen = Screen.objects.get(user=user, code=screen_id) igadgets = IGadget.objects.filter(screen=screen) igadget_data_list = get_wiring_data(igadgets) wiring['iGadgetList'] = igadget_data_list except Screen.DoesNotExist: wiring['iGadgetList'] = [] # InOut list inouts = InOut.objects.filter(user=user) inout_data = serializers.serialize('python', inouts, ensure_ascii=False) inout_data_list = [get_inout_data(d) for d in inout_data] wiring['inOutList'] = inout_data_list return HttpResponse(json_encode(wiring), mimetype='application/json; charset=UTF-8')
def read(self, request, workspace_id): user = get_user_authentication(request) wiring = {} try: igadgets = IGadget.objects.filter(tab__workspace__pk=workspace_id) igadget_data_list = get_wiring_data(igadgets) wiring['iGadgetList'] = igadget_data_list tabs = Tab.objects.filter(workspace__pk=workspace_id) tab_data = serializers.serialize('python', tabs, ensure_ascii=False) wiring['tabList'] = [get_tab_data(d) for d in tab_data] except WorkSpace.DoesNotExist: wiring['iGadgetList'] = [] wiring['tabList'] = [] # InOut list inouts = InOut.objects.filter(workspace__pk=workspace_id) inout_data = serializers.serialize('python', inouts, ensure_ascii=False) wiring['inOutList'] = [get_inout_data(d) for d in inout_data] # Filter list filters = Filter.objects.all() filter_data = serializers.serialize('python', filters, ensure_ascii=False) wiring['filterList'] = [get_filter_data(d) for d in filter_data] return HttpResponse(json_encode(wiring), mimetype='application/json; charset=UTF-8')
def read(self, request, user_name, screen_id=1): user = user_authentication(user_name) wiring = {} # IGadgets list if not screen_id: screen_id=1 try: screen = Screen.objects.get(user=user, code=screen_id) igadgets = IGadget.objects.filter(screen=screen) igadget_data_list = get_wiring_data(igadgets) wiring['iGadgetList'] = igadget_data_list except Screen.DoesNotExist: wiring['iGadgetList'] = [] # InOut list inouts = InOut.objects.filter(user=user) inout_data = serializers.serialize('python', inouts, ensure_ascii=False) inout_data_list = [get_inout_data(d) for d in inout_data] wiring['inOutList'] = inout_data_list return HttpResponse(json_encode(wiring), mimetype='application/json; charset=UTF-8')