def handle(self, *args, **options):
        ti = models.TierInfo.objects.get_current()
        if ti.already_sent_tiers_compliance_email:
            return

        warnings = tiers.user_warnings_for_downgrade(ti.tier_name)
        ### Hack
        ### Override the customtheme warning for this email with custom code
        if 'customtheme' in warnings:
            warnings.remove('customtheme')
        default_non_bundled_themes = uploadtemplate.models.Theme.objects.filter(default=True, bundled=False)
        if default_non_bundled_themes:
            warnings.add('customtheme')

        tier = ti.get_tier()
        ### Hack
        ### override the customdomain warning, too
        if (ti.site_settings.site.domain
            and not ti.site_settings.site.domain.endswith('mirocommunity.org')
            and not tier.permits_custom_domain()):
            warnings.add('customdomain')

        data = {'warnings': warnings}
        data['would_lose_admin_usernames'] = tiers.push_number_of_admins_down(
            tier.admins_limit())
        data['videos_over_limit'] = tiers.hide_videos_above_limit(tier)
        data['video_count'] = tiers.current_videos_that_count_toward_limit().count()
        tiers.send_tiers_related_multipart_email(
            'Changes to your Miro Community site',
            'mirocommunity_saas/tiers_emails/too_big_for_your_tier.txt',
            ti,
            extra_context=data)
        ti.already_sent_tiers_compliance_email = True
        ti.save()
Exemplo n.º 2
0
def downgrade_confirm(request):
    target_tier_name = request.POST.get('target_tier_name', None)
    # validate
    if target_tier_name in dict(tiers.CHOICES):
        target_tier_obj = tiers.Tier(target_tier_name)

        would_lose = tiers.user_warnings_for_downgrade(target_tier_name)
        data = {}
        data['tier_name'] = target_tier_name
        data['paypal_sandbox'] = getattr(settings, 'PAYPAL_TEST', False)
        data['can_modify'] = _generate_can_modify()[target_tier_name]
        data['paypal_url'] = get_paypal_form_submission_url()
        data['paypal_email'] = tiers.get_paypal_email_address()
        data['paypal_email_acct'] = tiers.get_paypal_email_address()
        data['target_tier_obj'] = target_tier_obj
        data['would_lose_admin_usernames'] = tiers.push_number_of_admins_down(target_tier_obj.admins_limit())
        data['customtheme_nag'] = ('customtheme' in would_lose)
        data['advertising_nag'] = ('advertising' in would_lose)
        data['customdomain_nag'] = ('customdomain' in would_lose)
        data['css_nag'] = ('css' in would_lose)
        data['videos_nag'] = ('videos' in would_lose)
        data['videos_over_limit'] = tiers.hide_videos_above_limit(target_tier_obj)
        data['new_theme_name'] = tiers.switch_to_a_bundled_theme_if_necessary(target_tier_obj)
        data['payment_secret'] = SiteSettings.objects.get_current().tierinfo.get_payment_secret()
        return render_to_response('localtv/admin/downgrade_confirm.html', data,
                                  context_instance=RequestContext(request))

    # In some weird error case, redirect back to tiers page
    return HttpResponseRedirect(reverse('localtv_admin_tier'))