# Path: activity/models.py
# class Event(models.Model):
#     timestamp = models.DateTimeField(auto_now=True)
#     type = models.TextField(choices=(
#         ("chat", "Chat"), ("rpg", "RPG"), ("other", "Other"))
#     )
#     message = models.TextField()
#     user = models.ForeignKey(get_user_model())
# 
# Path: emergent/websockets.py
# class PusherWrapper(object):
#     def __init__(self):
#     def send(self, channel, event, msg):


import os
import random
import misaka as m
from django.conf import settings
from django.contrib.auth import get_user_model
from django.shortcuts import redirect
from django.views.generic import TemplateView, View
from braces.views import LoginRequiredMixin, JSONResponseMixin, AjaxResponseMixin
from activity.models import Event
from datetime import datetime
from emergent.websockets import Pusher
# Create your views here.from datetime import datetime



__all__ = (
    'StreamView',
    'ChatSendView',
    'HistoryView'
)


class StreamView(LoginRequiredMixin, TemplateView):
    template_name = 'activity/stream.html'

    def get_context_data(self, **kwargs):
        context = super(StreamView, self).get_context_data(**kwargs)
        return context


class HistoryView(LoginRequiredMixin, JSONResponseMixin, AjaxResponseMixin, View):
    def get_ajax(self, request, *args, **kwargs):

# Path: activity/models.py
# class Event(models.Model):
#     timestamp = models.DateTimeField(auto_now=True)
#     type = models.TextField(choices=(
#         ("chat", "Chat"), ("rpg", "RPG"), ("other", "Other"))
#     )
#     message = models.TextField()
#     user = models.ForeignKey(get_user_model())
# 
# Path: emergent/websockets.py
# class PusherWrapper(object):
#     def __init__(self):
#     def send(self, channel, event, msg):


# Path: activity/views.py
import os
import random
import misaka as m
from django.conf import settings
from django.contrib.auth import get_user_model
from django.shortcuts import redirect
from django.views.generic import TemplateView, View
from braces.views import LoginRequiredMixin, JSONResponseMixin, AjaxResponseMixin
from activity.models import Event
from datetime import datetime
from emergent.websockets import Pusher

# Create your views here.from datetime import datetime



__all__ = (
    'StreamView',
    'ChatSendView',
    'HistoryView'
)


class StreamView(LoginRequiredMixin, TemplateView):
    template_name = 'activity/stream.html'

    def get_context_data(self, **kwargs):
        context = super(StreamView, self).get_context_data(**kwargs)
        return context


class HistoryView(LoginRequiredMixin, JSONResponseMixin, AjaxResponseMixin, View):
    def get_ajax(self, request, *args, **kwargs):

        history = Event.objects.all().order_by("-timestamp")[:10]