Example #1
0
def update_chat(**kwargs):
    channel_layer = get_channel_layer()
    message = kwargs["instance"]
    response = {
        "item": get_model_serializer(Message, [])(message).data,
        "itemId": message.id,
        "itemIndex": message.id
    }
    async_to_sync(channel_layer.group_send)("participants", {"type": "send.json","text": json.dumps({"type": "CHAT_ITEMS_ADD", "payload": response})})
Example #2
0
def item_data(model, data, excluded = []):
    response = {
            "items": {},
            "itemsOrder": []
        }
    for item in data:
        response["items"][item.id] =  get_model_serializer(model, excluded)(item).data
        response["itemsOrder"].append(item.id)
    return(response)
Example #3
0
class ThresholdViewSet(viewsets.ModelViewSet):
    queryset = Threshold.objects.all()
    serializer_class = get_model_serializer(Threshold, field_exceptions)
Example #4
0
class EventViewSet(viewsets.ModelViewSet):
    queryset = Event.objects.all()
    serializer_class = get_model_serializer(Event, field_exceptions + ["threshold", "resourceeventstate"])
Example #5
0
class SessionViewSet(viewsets.ModelViewSet):
    queryset = Session.objects.all()
    serializer_class = get_model_serializer(Session, field_exceptions + ["participant", "resourceeventstate", "chatsession"])
Example #6
0
class ScoreViewSet(viewsets.ModelViewSet):
    queryset = Score.objects.all()
    serializer_class = get_model_serializer(Score, field_exceptions + ["participant"])
Example #7
0
class ScenarioViewSet(viewsets.ModelViewSet):
    queryset = Scenario.objects.all()
    serializer_class = get_model_serializer(Scenario, field_exceptions + ["briefing", "session"])
Example #8
0
class ResourceDepotViewSet(viewsets.ModelViewSet):
    queryset = ResourceDepot.objects.all()
    serializer_class = get_model_serializer(ResourceDepot, field_exceptions)