available number of accounts
@@ -61,6 +61,26 @@ class PartnersDetailView(DetailView):
context['total_apps_approved_or_sent'] = context['total_apps_approved'] + context['total_apps_sent']
+ partner_streams = Stream.objects.filter(partner=partner)
+ if partner_streams.count() > 0:
+ context['total_accounts_available_current'] = {}
+ for stream in partner_streams:
+ context['total_apps_approved_or_sent_stream'] = User.objects.filter(
+ editor__applications__partner=partner,
+ editor__applications__status__in=(Application.APPROVED, Application.SENT),
+ editor__applications__specific_stream=stream).count()
+
+ total_accounts_available = stream.accounts_available
+ context['total_accounts_available'] = total_accounts_available
+
+ context['total_accounts_available_current'][stream.name] = context['total_accounts_available'] - context['total_apps_approved_or_sent_stream']
+ else:
+ context['total_apps_approved_or_sent_stream'] = None
+
+ context['total_accounts_available'] = Partner.objects.filter(id=partner).values_list('accounts_available', flat=True)
+
+ context['total_accounts_available_current'] = context['total_accounts_available'] - context['total_apps_approved_or_sent']
+
context['unique_users'] = User.objects.filter(
editor__applications__partner=partner).distinct().count()
