Beispiel #1
0
    def __call__(klass, request, show_welcome):
        featured_channels = list(klass.get_featured_channels(request))
        categories = Category.objects.filter(
            on_frontpage=True).order_by('name')
        language = get_current_language(request)
        for category in categories:

            def popular_channels(category=category):
                return category.get_list_channels(True, klass.show_state,
                                                  language)

            category.popular_channels = popular_channels
        context = {
            'show_welcome':
            show_welcome,
            'new_channels':
            klass.get_new_channels(request, True, 20),
            'popular_channels':
            klass.get_popular_channels(request, 20),
            'popular_hd_channels':
            klass.get_popular_channels(request, 20, hi_def=True),
            'featured_channels':
            featured_channels[:2],
            'featured_channels_hidden':
            featured_channels[2:],
            'categories':
            categories,
            'language':
            language,
            'header':
            klass.get_header()
        }
        context.update(klass.additional_context)
        return util.render_to_response(request, 'frontpage.html', context)
Beispiel #2
0
def edit_header(request):
    Comment = comments.get_model()
    content_type = ContentType.objects.get_for_model(Site)
    site = Site.objects.get_current()
    headers = Comment.objects.filter(content_type=content_type,
                                     object_pk=site.pk,
                                     flags__flag='site header')
    if request.method == 'POST':
        header = request.POST.get('header')
        headers.delete()
        if header:
            obj = Comment.objects.create(site=site,
                                         user=request.user,
                                         comment=header,
                                         content_type=content_type,
                                         object_pk=site.pk,
                                         is_removed=True,
                                         is_public=False)
            comments.models.CommentFlag.objects.get_or_create(
                comment=obj, user=request.user, flag='site header')
        return util.redirect_to_referrer(request)

    if headers:
        header = headers[0].comment
    else:
        header = ''
    return util.render_to_response(request, 'edit-header.html',
                                   {'header': header})
Beispiel #3
0
def edit_header(request):
    Comment = comments.get_model()
    content_type = ContentType.objects.get_for_model(Site)
    site = Site.objects.get_current()
    headers = Comment.objects.filter(
        content_type=content_type,
        object_pk=site.pk,
        flags__flag='site header')
    if request.method == 'POST':
        header = request.POST.get('header')
        headers.delete()
        if header:
            obj = Comment.objects.create(
                site=site,
                user=request.user,
                comment=header,
                content_type=content_type,
                object_pk=site.pk,
                is_removed=True,
                is_public=False)
            comments.models.CommentFlag.objects.get_or_create(
                comment=obj,
                user=request.user,
                flag='site header')
        return util.redirect_to_referrer(request)

    if headers:
        header = headers[0].comment
    else:
        header = ''
    return util.render_to_response(request, 'edit-header.html',
                                   {'header': header})
Beispiel #4
0
def email_owners(request):
    if request.method != 'POST':
        form = forms.EmailChannelOwnersForm()
    else:
        form = forms.EmailChannelOwnersForm(request.POST)
        if form.is_valid():
            form.send_email(request.user)
            return util.redirect('moderate')
    return util.render_to_response(request, 'email-channel-owners.html',
                                   {'form': form})
Beispiel #5
0
def email_owners(request):
    if request.method != 'POST':
        form = forms.EmailChannelOwnersForm()
    else:
        form = forms.EmailChannelOwnersForm(request.POST)
        if form.is_valid():
            form.send_email(request.user)
            return util.redirect('moderate')
    return util.render_to_response(request, 'email-channel-owners.html', {
        'form': form})
Beispiel #6
0
 def __call__(klass, request, show_welcome):
     featured_channels = list(klass.get_featured_channels(request))
     categories = Category.objects.filter(
         on_frontpage=True).order_by('name')
     language = get_current_language(request)
     for category in categories:
         def popular_channels(category=category):
             return category.get_list_channels(True, klass.show_state,
                                               language)
         category.popular_channels = popular_channels
     context = {
         'show_welcome': show_welcome,
         'new_channels': klass.get_new_channels(request, True, 20),
         'popular_channels': klass.get_popular_channels(request, 20),
         'popular_hd_channels': klass.get_popular_channels(request, 20,
                                                           hi_def=True),
         'featured_channels': featured_channels[:2],
         'featured_channels_hidden': featured_channels[2:],
         'categories': categories,
         'language' : language,
         'header': klass.get_header()
     }
     context.update(klass.additional_context)
     return util.render_to_response(request, 'frontpage.html', context)
Beispiel #7
0
def item(request, id):
    item = get_object_or_404(Item, pk=id)
    return util.render_to_response(request, 'playback.html', {'item': item})
Beispiel #8
0
def email(request, id):
    channel = get_object_or_404(Channel, pk=id)
    email_type = request.REQUEST['type']
    skipable = True
    if request.user.get_full_name():
        mod_name = '%s (%s)' % (request.user.get_full_name(),
                                request.user.username)
    else:
        mod_name = request.user.username
    common_body = """%s is in line to be featured on the Miro Channel Guide, which is great because 50,000-100,000 people see this page every day!""" % channel.name
    common_middle = """Depending on the number of channels in line, %s should appear on the front page in the next few days; it will remain in the spotlight for 4 full days at: https://miroguide.com/""" % channel.name
    common_footer = """If you want to show off your featured channel, you can link to this page: https://www.miroguide.com/featured/

Regards,
%s

PS. Miro 1-click links rock! They give your viewers a simple way to go directly
from your website to being subscribed to your feed in Miro:
http://subscribe.getmiro.com/""" % mod_name

    if channel.owner.username != 'freelance':
        if channel.owner.get_full_name():
            name = channel.owner.get_full_name()
        else:
            name = channel.owner.username
        body = """Hello %s,

%s

%s

Modify your channel and get stats here: %s#edit

%s""" % (name, common_body, common_middle, channel.get_absolute_url(),
         common_footer)
    else:
        body = """Hello,

%s  The Guide is part of Miro, the free internet TV application: http://www.getmiro.com/

%s

Currently we're managing your channel -- if you'd like to take control, view stggats, and be able to change the images and details associated with it, please contact us at: [email protected]

%s""" % (common_body, common_middle, common_footer)
    if email_type in ('Feature', 'Refeature'):
        action = 'feature'
    elif email_type == 'Approve & Feature':
        action = 'change-state'
    elif email_type == "Custom":
        email_type = 'Reject'
        action = 'reject'
        body = ''
        skipable = False
    elif email_type == 'Comment':
        action = 'editors_comment'
        email = True
        skipable = False
        Comment = comments.get_model()
        content_type = ContentType.objects.get_for_model(channel)
        try:
            body = Comment.objects.get(content_type=content_type,
                                       object_pk=channel.pk,
                                       flags__flag='editors comment').comment
        except Comment.DoesNotExist:
            body = ''
    else:
        raise Http404
    if action != 'reject' and channel.owner.email != '*****@*****.**':
        email = channel.owner.email
    else:
        email = ''
    return util.render_to_response(
        request, 'email-form.html', {
            'channel': channel,
            'type': email_type,
            'action': action,
            'body': body,
            'email': email,
            'skipable': skipable
        })
Beispiel #9
0
def item(request, id):
    item = get_object_or_404(Item, pk=id)
    return util.render_to_response(request, 'playback.html',
                                   {'item': item})
Beispiel #10
0
def email(request, id):
    channel = get_object_or_404(Channel, pk=id)
    email_type = request.REQUEST['type']
    skipable = True
    if request.user.get_full_name():
        mod_name = '%s (%s)' % (request.user.get_full_name(), request.user.username)
    else:
        mod_name = request.user.username
    common_body = """%s is in line to be featured on the Miro Channel Guide, which is great because 50,000-100,000 people see this page every day!""" % channel.name
    common_middle = """Depending on the number of channels in line, %s should appear on the front page in the next few days; it will remain in the spotlight for 4 full days at: https://miroguide.com/""" % channel.name
    common_footer ="""If you want to show off your featured channel, you can link to this page: https://www.miroguide.com/featured/

Regards,
%s

PS. Miro 1-click links rock! They give your viewers a simple way to go directly
from your website to being subscribed to your feed in Miro:
http://subscribe.getmiro.com/""" % mod_name

    if channel.owner.username != 'freelance':
        if channel.owner.get_full_name():
            name = channel.owner.get_full_name()
        else:
            name = channel.owner.username
        body  = """Hello %s,

%s

%s

Modify your channel and get stats here: %s#edit

%s""" % (name, common_body, common_middle, channel.get_absolute_url(),
        common_footer)
    else:
        body = """Hello,

%s  The Guide is part of Miro, the free internet TV application: http://www.getmiro.com/

%s

Currently we're managing your channel -- if you'd like to take control, view stggats, and be able to change the images and details associated with it, please contact us at: [email protected]

%s""" % (common_body, common_middle, common_footer)
    if email_type in ('Feature', 'Refeature'):
        action = 'feature'
    elif email_type == 'Approve & Feature':
        action = 'change-state'
    elif email_type == "Custom":
        email_type = 'Reject'
        action = 'reject'
        body = ''
        skipable = False
    elif email_type == 'Comment':
        action = 'editors_comment'
        email = True
        skipable = False
        Comment = comments.get_model()
        content_type = ContentType.objects.get_for_model(channel)
        try:
            body = Comment.objects.get(
                content_type=content_type,
                object_pk=channel.pk,
                flags__flag='editors comment').comment
        except Comment.DoesNotExist:
            body = ''
    else:
        raise Http404
    if action != 'reject' and channel.owner.email != '*****@*****.**':
        email = channel.owner.email
    else:
        email = ''
    return util.render_to_response(request, 'email-form.html',
                                   {'channel': channel,
                                    'type': email_type,
                                    'action': action,
                                    'body': body,
                                    'email': email,
                                    'skipable': skipable})