Skip to content

Commit

Permalink
Merge branch 'master' into riese/style-anchored-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinRiese committed Apr 24, 2024
2 parents 354f8a8 + 2fac97b commit 8365aab
Show file tree
Hide file tree
Showing 313 changed files with 7,605 additions and 1,881 deletions.
17 changes: 17 additions & 0 deletions corehq/apps/accounting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from corehq.apps.accounting.utils.stripe import charge_through_stripe

from corehq.apps.domain.shortcuts import publish_domain_saved
from corehq.apps.users.dbaccessors import get_active_web_usernames_by_domain, get_web_user_count
from dimagi.ext.couchdbkit import (
BooleanProperty,
DateTimeProperty,
Expand Down Expand Up @@ -603,6 +604,22 @@ def _send_autopay_card_added_email(self, domain):
use_domain_gateway=True,
)

def get_web_user_usernames(self):
domains = self.get_domains()
web_users = set()

for domain in domains:
web_users.update(get_active_web_usernames_by_domain(domain))

return web_users

def get_web_user_count(self):
domains = self.get_domains()
count = 0
for domain in domains:
count += get_web_user_count(domain, include_inactive=False)
return count

@staticmethod
def should_show_sms_billable_report(domain):
account = BillingAccount.get_account_by_domain(domain)
Expand Down
21 changes: 8 additions & 13 deletions corehq/apps/accounting/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
from corehq.apps.accounting.utils.subscription import (
assign_explicit_unpaid_subscription,
)
from corehq.apps.users.models import WebUser
from corehq.apps.app_manager.dbaccessors import get_all_apps
from corehq.apps.celery import periodic_task, task
from corehq.apps.domain.models import Domain
Expand Down Expand Up @@ -554,13 +553,13 @@ def weekly_digest():
in_forty_days = today + datetime.timedelta(days=40)

ending_in_forty_days = [sub for sub in Subscription.visible_objects.filter(
date_end__lte=in_forty_days,
date_end__gte=today,
is_active=True,
is_trial=False,
).exclude(
account__dimagi_contact='',
) if not sub.is_renewed]
date_end__lte=in_forty_days,
date_end__gte=today,
is_active=True,
is_trial=False,
).exclude(
account__dimagi_contact='',
) if not sub.is_renewed]

if not ending_in_forty_days:
log_accounting_info(
Expand Down Expand Up @@ -833,11 +832,7 @@ def calculate_web_users_in_all_billing_accounts(today=None):
today = today or datetime.date.today()
for account in BillingAccount.objects.all():
record_date = today - relativedelta(days=1)
domains = account.get_domains()
web_user_in_account = set()
for domain in domains:
[web_user_in_account.add(id) for id in WebUser.ids_by_domain(domain)]
num_users = len(web_user_in_account)
num_users = account.get_web_user_count()
try:
BillingAccountWebUserHistory.objects.create(
billing_account=account,
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions corehq/apps/app_execution/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin

from .models import AppWorkflowConfig


@admin.register(AppWorkflowConfig)
class AppWorkflowAdmin(admin.ModelAdmin):
list_display = ('domain', 'app_id', 'user_id', 'django_user')
Loading

0 comments on commit 8365aab

Please sign in to comment.