Beispiel #1
0
def welcome_email_task(using="default"):
    """
	Sends the welcome email for this site. The 'using' kwarg is only here
	as part of the settings hack.

	"""
    send_welcome_email()
def welcome_email_task(using='default'):
	"""
	Sends the welcome email for this site. The 'using' kwarg is only here
	as part of the settings hack.

	"""
	send_welcome_email()
Beispiel #3
0
 def save(self):
     self.tier_info.tier = self.cleaned_data['tier']
     self.tier_info.tier_changed = datetime.datetime.now()
     self.tier_info.save()
     # Run send_welcome_email to get it out of the way if they're
     # arriving after paying on paypal. It won't do anything if it was
     # already sent, and the overhead is minimal.
     send_welcome_email()
Beispiel #4
0
 def save(self):
     self.tier_info.tier = self.cleaned_data['tier']
     self.tier_info.tier_changed = datetime.datetime.now()
     self.tier_info.save()
     # Run send_welcome_email to get it out of the way if they're
     # arriving after paying on paypal. It won't do anything if it was
     # already sent, and the overhead is minimal.
     send_welcome_email()
Beispiel #5
0
    def test_welcome_email(self):
        now = datetime.datetime.now()
        tier = self.create_tier()
        tier_info = self.create_tier_info(tier, welcome_email_sent=now)

        # Shouldn't send if it's already been sent.
        self.assertEqual(len(mail.outbox), 0)
        send_welcome_email()
        self.assertEqual(len(mail.outbox), 0)

        tier_info.welcome_email_sent = None
        tier_info.save()
        send_welcome_email()
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue(tier_info.welcome_email_sent)
        self.assertEqual(mail.outbox[0].to, [self.owner.email])
    def handle(self, site_name, domain, **options):
        available_tiers = Tier.objects.filter(slug__in=('basic', 'plus',
                                                        'premium', 'max'))
        tier = available_tiers.get(slug=options['tier'])
        site = Site.objects.get_current()
        # Make sure this site hasn't already been set up.
        try:
            SiteTierInfo.objects.get(site=site)
        except SiteTierInfo.DoesNotExist:
            tier_info = SiteTierInfo.objects.create(
                site=site,
                tier=tier,
                tier_changed=datetime.datetime.now(),
                enforce_payments=True,
                site_name=site_name)
            tier_info.available_tiers = available_tiers
        else:
            self.stderr.write('Site already initialized.\n')
            return
        site.name = site_name
        site.domain = domain
        site.save()

        SiteSettings.objects.get_or_create(site=site)

        if options['username']:
            user = User.objects.create_user(options['username'],
                                            options['email'],
                                            options['password'])
            user.is_superuser = True
            user.save()

        if tier.slug == 'basic':
            send_welcome_email()
            self.stdout.write('http://{0}/'.format(site.domain))
        else:
            # Send the welcome email in ~30 minutes if they haven't gotten
            # back from paypal by then.
            welcome_email_task.apply_async(countdown=30 * 60,
                                           kwargs={'using': CELERY_USING})
            form = PayPalSubscriptionForm(tier)
            data = form.initial

            # Here we make use of the fact that paypal subscriptions can use
            # GET as well as POST. A bit hackish.
            self.stdout.write("{0}?{1}".format(form.action,
                                               urllib.urlencode(data)))
    def handle(self, site_name, domain, **options):
        available_tiers = Tier.objects.filter(slug__in=("basic", "plus", "premium", "max"))
        tier = available_tiers.get(slug=options["tier"])
        site = Site.objects.get_current()
        # Make sure this site hasn't already been set up.
        try:
            SiteTierInfo.objects.get(site=site)
        except SiteTierInfo.DoesNotExist:
            tier_info = SiteTierInfo.objects.create(
                site=site, tier=tier, tier_changed=datetime.datetime.now(), enforce_payments=True, site_name=site_name
            )
            tier_info.available_tiers = available_tiers
        else:
            self.stderr.write("Site already initialized.\n")
            return
        site.name = site_name
        site.domain = domain
        site.save()

        SiteSettings.objects.get_or_create(site=site)

        if options["username"]:
            user = User.objects.create_user(options["username"], options["email"], options["password"])
            user.is_superuser = True
            user.save()

        if tier.slug == "basic":
            send_welcome_email()
            self.stdout.write("http://{0}/".format(site.domain))
        else:
            # Send the welcome email in ~30 minutes if they haven't gotten
            # back from paypal by then.
            welcome_email_task.apply_async(countdown=30 * 60, kwargs={"using": CELERY_USING})
            form = PayPalSubscriptionForm(tier)
            data = form.initial

            # Here we make use of the fact that paypal subscriptions can use
            # GET as well as POST. A bit hackish.
            self.stdout.write("{0}?{1}".format(form.action, urllib.urlencode(data)))
Beispiel #8
0
 def handle_noargs(self, **options):
     send_welcome_email()