Source

django-live / live / frontend_views.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2010 Nicolás Echániz
# All rights reserved.
#
# This file is part of django-live.
#
# Django-Live is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Django-Live is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from django.utils.translation import ugettext_lazy as _
from cyclope.core import frontend

from models import Channel
from views import chat_html

class ChannelWindow(frontend.FrontendView):
    """Show a chat window

    To use this view you must provide a live/base.html template that works with Cyclope.
    There's a model under templates/live/cyclope_base.html

    And define your own CSS styles.
    """

    name='detail'
    verbose_name=_('view of the selected chat channel')
    is_default = True
    is_instance_view = True
    is_content_view = True

    def get_response(self, request, req_context, options, content_object):
        if request.user:
            nickname = request.user.username
        channel = content_object
        return chat_channel(request, channel.slug, extra_context=req_context)
    
frontend.site.register_view(Channel, ChannelWindow)