示例#1
0
 def post(self, request, *args, **kwargs):
     hub = AuthServiceApi.get_hub(self.kwargs.get('hub'))
     device_id = self.kwargs.get('device')
     token = self.request.COOKIES.get('user_token')
     self.object = InternalApi.get_unit(token, hub, device_id,
                                        self.kwargs.get('pk'))
     return super(UpdateDeviceUnitView, self).post(request, *args, **kwargs)
示例#2
0
 def get(self, request, *args, **kwargs):
     token = self.request.COOKIES.get('user_token')
     self.hub = AuthServiceApi.get_hub(self.kwargs.get('dest_hub'))
     self.device = InternalApi.get_device(token, self.hub,
                                          self.kwargs.get('dest_device'))
     self.unit = InternalApi.get_unit(token, self.hub, self.device['pk'],
                                      self.kwargs.get('dest_unit'))
     context = self.get_context_data()
     return self.render_to_response(context)
示例#3
0
 def get(self, request, *args, **kwargs):
     token = self.request.COOKIES.get('user_token')
     self.hub = AuthServiceApi.get_hub(self.kwargs.get('hub'))
     self.device = InternalApi.get_device(token, self.hub,
                                          self.kwargs.get('device'))
     self.unit = InternalApi.get_unit(token, self.hub, self.device['pk'],
                                      self.kwargs.get('pk'))
     self.connected_units = InternalApi.get_connected_units_with_unit(
         token, self.hub, self.unit['pk'])
     return super(ConnectedUnitList, self).get(request, *args, **kwargs)
示例#4
0
 def get(self, request, *args, **kwargs):
     hub = AuthServiceApi.get_hub(self.kwargs.get('hub'))
     self.hub = hub
     token = self.request.COOKIES.get('user_token')
     self.device = InternalApi.get_device(token, self.hub,
                                          self.kwargs.get('device'))
     self.unit = InternalApi.get_unit(token, hub, self.kwargs.get('device'),
                                      self.kwargs.get('pk'))
     self.data = InternalApi.get_data_from_unit(token, hub,
                                                self.kwargs.get('device'),
                                                self.kwargs.get('pk'))
     self.has_write_perms = AuthServiceApi.has_write_permission(
         hub['pk'], self.kwargs.get('device'), self.user['pk'])
     return super(UnitDataView, self).get(request, *args, **kwargs)
示例#5
0
 def post(self, request, *args, **kwargs):
     self.hub = AuthServiceApi.get_hub(self.kwargs.get('hub'))
     self.token = self.request.COOKIES.get('user_token')
     self.device = InternalApi.get_device(self.token, self.hub,
                                          self.kwargs.get('device'))
     self.unit = InternalApi.get_unit(self.token, self.hub,
                                      self.kwargs.get('device'),
                                      self.kwargs.get('pk'))
     self.data = InternalApi.get_data_from_unit(self.token, self.hub,
                                                self.kwargs.get('device'),
                                                self.kwargs.get('pk'))
     self.has_write_perms = AuthServiceApi.has_write_permission(
         self.hub['pk'], self.kwargs.get('device'), self.user['pk'])
     if not self.has_write_perms['has_write_perm']:
         return HttpResponseRedirect(self.get_success_url())
     return super(UnitDataView, self).post(request, *args, **kwargs)