dev: enable workspace member calculation

This commit is contained in:
pablohashescobar 2023-10-27 13:25:36 +05:30
parent 939fe4af03
commit 7f521da889
2 changed files with 23 additions and 3 deletions

View File

@ -11,7 +11,6 @@ from django.conf import settings
from django.utils import timezone
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.contrib.sites.shortcuts import get_current_site
from django.db.models import (
Prefetch,
OuterRef,
@ -34,7 +33,6 @@ from django.contrib.auth.hashers import make_password
from rest_framework import status
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
from sentry_sdk import capture_exception
# Module imports
from plane.api.serializers import (

View File

@ -1,6 +1,8 @@
# Django imports
from django.db import models
from django.conf import settings
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
# Module imports
from . import BaseModel
@ -50,7 +52,7 @@ def get_default_props():
"state": True,
"sub_issue_count": True,
"updated_on": True,
}
},
}
@ -199,3 +201,23 @@ class WorkspaceTheme(BaseModel):
verbose_name_plural = "Workspace Themes"
db_table = "workspace_themes"
ordering = ("-created_at",)
@receiver(post_save, sender=WorkspaceMember)
def workspace_member_add(sender, instance, created, **kwargs):
if created:
total_members_count = WorkspaceMember.objects.filter(
workspace=instance.workspace_id, member__is_bot=False
)
action = "add"
# Update the license engine
@receiver(post_delete, sender=WorkspaceMember)
def workspace_member_delete(sender, instance, **kwargs):
total_members_count = WorkspaceMember.objects.filter(
workspace=instance.workspace_id, member__is_bot=False
)
action = "delete"
# Update the license engine