def oups(request): from project.rent.models import MemberRentalPlan ctx = { 'CATALOG_CATEGORIES': Category.list_names(), 'SITE_URL': 'http://%s' % Site.objects.get_current().domain, 'STATIC_URL': settings.STATIC_URL, } # plan = MemberRentalPlan.get_current_plan(request.user) plan = MemberRentalPlan.objects.all()[0] from project.utils.mailer import mail mail('*****@*****.**', 'emails/rent_emails/plan_subscription_successfull.html', { 'user': plan.user, 'plan': plan, 'new_releases': Item.list_new_releases(6), 'coming_soon': Item.list_all()[:6], }, subject="TEST EMAIL!") return render_to_response('emails/rent_emails/plan_subscription_successfull.html', { 'user': plan.user, 'plan': plan, 'new_releases': Item.list_new_releases(6), 'coming_soon': Item.list_all()[:6], }, Context(ctx))
def mail(mailto, template, ctx={}, mailfrom=None, subject=None): mailfrom = mailfrom or settings.DEFAULT_FROM_EMAIL if isinstance(template, basestring): ctx.update({ 'CATALOG_CATEGORIES': Category.list_names(), 'SITE_URL': 'http://%s' % Site.objects.get_current().domain, 'STATIC_URL': settings.EMAIL_STATIC_URL, 'terms_url': 'http://www.gamemine.com/Terms/', 'help_url': 'http://www.gamemine.com/Help-FAQs/', 'WIMGW_url': 'http://www.gamemine.com/What-is-My-Game-Worth/', }) try: body = get_template(template).render(Context(ctx)) subject = subject or '' except TemplateDoesNotExist: template = Template.objects.get(name=template) subject = subject or get_template_from_string(u'{%% autoescape off %%}%s{%% endautoescape %%}' % template.subject).render(Context(ctx)) body = get_template_from_string(u'{%% autoescape off %%}%s{%% endautoescape %%}' % template.body).render(Context(ctx)) msg = EmailMessage(subject, body, mailfrom, [mailto]) msg.content_subtype = "html" msg.send()
def get_owned_systems(self): if self.owned_systems.all().count() == 0: from project.catalog.models.categories import Category return Category.list() return self.owned_systems.all()