Beispiel #1
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.units = InternalApi.get_units(token, self.hub, self.device['pk'])
     return super(ConnectUnitSelectUnitView,
                  self).get(request, *args, **kwargs)
Beispiel #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)
Beispiel #3
0
 def get(self, request, *args, **kwargs):
     hub = AuthServiceApi.get_hub(self.kwargs.get('hub'))
     self.device = InternalApi.get_device(
         self.request.COOKIES.get('user_token'), hub, self.kwargs.get('pk'))
     self.units = InternalApi.get_units(
         self.request.COOKIES.get('user_token'), hub, self.kwargs.get('pk'))
     self.user = AuthServiceApi.get_me(
         self.request.COOKIES.get('user_token'))
     return super(DeviceUnitsView, self).get(request, *args, **kwargs)
Beispiel #4
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)
Beispiel #5
0
 def get(self, request, *args, **kwargs):
     token = self.request.COOKIES.get('user_token')
     hub = AuthServiceApi.get_hub(kwargs['hub'])
     device = InternalApi.get_device(token, hub, kwargs['pk'])
     self.device = device
     self.users = AuthServiceApi.get_users()
     self.groups = AuthServiceApi.get_groups()
     self.user_permissions = AuthServiceApi.get_device_user_permissions(
         hub['pk'], device['pk'])
     self.group_permissions = AuthServiceApi.get_device_group_permissions(
         hub['pk'], device['pk'])
     return super(DevicePermissionsView, self).get(request, *args, **kwargs)
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
0
 def get(self, request, *args, **kwargs):
     token = self.request.COOKIES.get('user_token')
     hub = AuthServiceApi.get_hub(kwargs['hub'])
     self.object = InternalApi.get_device(token, hub, kwargs['pk'])
     return super(UpdateDeviceView, self).get(request, *args, **kwargs)