(self)
Returns groups of synced devices and a unsynced group
Returns groups of synced devices and a unsynced group
Returns groups of synced devices and a unsynced group
def get_grouped_devices(self):
        """Returns groups of synced devices and a unsynced group"""

        clients = (
            Client.objects.filter(user=self, deleted=False)
            .order_by("-sync_group")
            .prefetch_related("sync_group")
        )

        last_group = object()
        group = None

        for client in clients:
            # check if we have just found a new group
            if last_group != client.sync_group:
                if group is not None:
                    yield group

                group = GroupedDevices(client.sync_group is not None, [])

            last_group = client.sync_group
            group.devices.append(client)

        # yield remaining group
        if group is not None:
            yield group
def get_grouped_devices ( self ) : clients = ( Client . objects . filter ( user = self , deleted = False ) . order_by ( "-sync_group" ) . prefetch_related ( "sync_group" ) ) last_group = object ( ) group = None for client in clients : # check if we have just found a new group if last_group != client . sync_group : if group is not None : yield group group = GroupedDevices ( client . sync_group is not None , [ ] ) last_group = client . sync_group group . devices . append ( client ) # yield remaining group if group is not None : yield group