Пример #1
0
    def test_deleted_domain_exists(self):
        x = Domain(name='x')
        x.save()
        y = Domain(name='y')
        y.save()
        y.delete(leave_tombstone=True)
        self.addCleanup(x.delete)
        self.addCleanup(y.delete)
        self.assertTrue(domain_exists('x'))
        self.assertFalse(deleted_domain_exists('x'))
        self.assertTrue(domain_or_deleted_domain_exists('x'))

        self.assertFalse(domain_exists('y'))
        self.assertTrue(deleted_domain_exists('y'))
        self.assertTrue(domain_or_deleted_domain_exists('y'))

        self.assertTrue(len(list(iter_all_domains_and_deleted_domains_with_name('x'))), 1)
        self.assertTrue(len(list(iter_all_domains_and_deleted_domains_with_name('y'))), 1)
Пример #2
0
 def quantity(self):
     # Iterate through all months in the invoice date range to aggregate total users into one line item
     dates = self.all_month_ends_in_invoice()
     excess_users = 0
     for date in dates:
         total_users = 0
         for domain in self.subscribed_domains:
             try:
                 history = DomainUserHistory.objects.get(domain=domain,
                                                         record_date=date)
                 total_users += history.num_users
             except DomainUserHistory.DoesNotExist:
                 if not deleted_domain_exists(domain):
                     # this checks to see if the domain still exists
                     # before raising an error. If it was deleted the
                     # loop will continue
                     raise
         excess_users += max(total_users - self.rate.monthly_limit, 0)
     return excess_users
Пример #3
0
def should_create_invoice(subscription, domain, invoice_start, invoice_end):
    if not domain_exists(domain) and deleted_domain_exists(domain):
        # domain has been deleted, ignore
        return False
    if subscription.is_trial:
        log_accounting_info(
            "Skipping invoicing for Subscription %s because it's a trial." %
            subscription.pk)
        return False
    if subscription.skip_invoicing_if_no_feature_charges and not \
            subscription.plan_version.feature_charges_exist_for_domain(domain):
        log_accounting_info(
            "Skipping invoicing for Subscription %s because there are no feature charges."
            % subscription.pk)
        return False
    if subscription.date_start > invoice_end:
        # No invoice gets created if the subscription didn't start in the previous month.
        return False
    if subscription.date_end and subscription.date_end <= invoice_start:
        # No invoice gets created if the subscription ended before the invoicing period.
        return False
    return True