mirror of https://github.com/interlegis/sapl.git
AlGouvea
3 years ago
3 changed files with 34 additions and 23 deletions
@ -1,29 +1,42 @@ |
|||||
import json |
import json |
||||
import requests |
import requests |
||||
|
from asgiref.sync import async_to_sync |
||||
from channels.generic.websocket import AsyncJsonWebsocketConsumer |
from channels.generic.websocket import AsyncJsonWebsocketConsumer |
||||
|
from sapl.sessao.models import (ExpedienteMateria, OradorExpediente, OrdemDia, |
||||
|
PresencaOrdemDia, RegistroVotacao, |
||||
|
SessaoPlenaria, SessaoPlenariaPresenca, |
||||
|
VotoParlamentar, RegistroLeitura) |
||||
|
|
||||
|
|
||||
class PainelConsumer(AsyncJsonWebsocketConsumer): |
class PainelConsumer(AsyncJsonWebsocketConsumer): |
||||
async def connect (self): |
async def connect (self): |
||||
|
print('Conectado') |
||||
await self.accept() |
await self.accept() |
||||
|
|
||||
async def disconnect(self, close_code): |
async def disconnect(self, close_code): |
||||
|
print('Disconectado:', close_code) |
||||
pass |
pass |
||||
|
|
||||
async def receive(self, text_data): |
async def join_group(self): |
||||
print('Received Message') |
print('Group') |
||||
|
await self.channel_layer.group_add('painel', self.channel_name) |
||||
print('Enviando...') |
|
||||
url_dados = 'http://localhost:8000/painel/786/dados' |
|
||||
|
|
||||
#response = requests.get(url_dados) |
async def receive(self, text_data): |
||||
#print(response) |
print('Received Message:' + text_data) |
||||
|
|
||||
await self.send_json({ |
await self.send_data(786) |
||||
'message': 'teste' |
|
||||
}) |
async def send_data(self, id): |
||||
|
sessao = SessaoPlenaria.objects.get(id=id) |
||||
async def send(self, event): |
|
||||
print('Entrou') |
response = { |
||||
|
'sessao_plenaria': str(sessao), |
||||
|
'sessao_plenaria_data': sessao.data_inicio.strftime('%d/%m/%Y'), |
||||
|
'sessao_plenaria_hora_inicio': sessao.hora_inicio, |
||||
|
'sessao_solene': sessao.tipo.nome == "Solene", |
||||
|
'sessao_finalizada': sessao.finalizada, |
||||
|
'tema_solene': sessao.tema_solene, |
||||
|
'status_painel': sessao.painel_aberto, |
||||
|
} |
||||
|
await self.send_json(response) |
||||
|
|
Loading…
Reference in new issue