Browse Source

Prepare for the removal of Member.team_id

pull/214/head
Pēteris Caune 6 years ago
parent
commit
3c1964b493
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 8 additions and 5 deletions
  1. +3
    -3
      hc/accounts/admin.py
  2. +4
    -1
      hc/accounts/models.py
  3. +1
    -1
      hc/payments/views.py

+ 3
- 3
hc/accounts/admin.py View File

@ -51,13 +51,13 @@ class ProfileAdmin(admin.ModelAdmin):
def get_queryset(self, request):
qs = super(ProfileAdmin, self).get_queryset(request)
qs = qs.annotate(Count("member", distinct=True))
qs = qs.annotate(num_members=Count("user__project__member", distinct=True))
qs = qs.annotate(num_checks=Count("user__project__check", distinct=True))
return qs
@mark_safe
def users(self, obj):
if obj.member__count == 0:
if obj.num_members == 0:
return obj.user.email
else:
return render_to_string("admin/profile_list_team.html", {
@ -75,7 +75,7 @@ class ProfileAdmin(admin.ModelAdmin):
""" % (pct, obj.num_checks, obj.check_limit)
def invited(self, obj):
return "%d of %d" % (obj.member__count, obj.team_limit)
return "%d of %d" % (obj.num_members, obj.team_limit)
def sms(self, obj):
return "%d of %d" % (obj.sms_sent, obj.sms_limit)


+ 4
- 1
hc/accounts/models.py View File

@ -167,7 +167,7 @@ class Profile(models.Model):
return True
def can_invite(self):
return self.member_set.count() < self.team_limit
return self.member_count() < self.team_limit
def invite(self, user):
project = self.get_own_project()
@ -210,6 +210,9 @@ class Profile(models.Model):
return project
def member_count(self):
return Member.objects.filter(project__owner__profile=self).count()
class Project(models.Model):
code = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)


+ 1
- 1
hc/payments/views.py View File

@ -60,7 +60,7 @@ def billing(request):
"profile": request.profile,
"sub": sub,
"num_checks": Check.objects.filter(project__owner=request.user).count(),
"team_size": request.profile.member_set.count() + 1,
"team_size": request.profile.member_count() + 1,
"team_max": request.profile.team_limit + 1,
"send_invoices_status": send_invoices_status,
"set_plan_status": "default",


Loading…
Cancel
Save