Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion plans/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
logger = logging.getLogger(__name__)

from .build_layer import build_layer
from .models import ODKSyncLog, Plan
from .models import ODKSyncLog, PlanApp
from .serializers import PlanAppSerializer
from .utils import fetch_bearer_token, fetch_db_data
from geoadmin.models import GramPanchayat
from django.db.models import Q

_COMMON_REQUIRED_FIELDS: Tuple[str, ...] = (
"layer_name",
Expand Down Expand Up @@ -756,3 +758,32 @@ def map_plan_to_gp(request):
},
}
)


@api_view(["GET"])
@schema(None)
def plan_count(request):
"""
gives plan count on the basis of org_id or project_id and filter
"""
org_id = request.query_params.get("org_id")
project_id = request.query_params.get("project_id")
is_completed = request.query_params.get("is_completed")

queryset = PlanApp.objects.filter(enabled=True).exclude(
Q(plan__icontains="test") | Q(plan__icontains="demo")
)

if is_completed:
queryset = queryset.filter(is_completed=True).exclude(
Q(plan__icontains="test") | Q(plan__icontains="demo")
)

if org_id:
plan_count = queryset.filter(organization=org_id).count()
elif project_id:
plan_count = queryset.filter(project=project_id).count()
else:
plan_count = 0

return Response({"plan_count": plan_count})
1 change: 1 addition & 0 deletions plans/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@
path("", include(org_watershed_router.urls)),
path("", include(global_router.urls)),
path("map_plan_to_gp/", api.map_plan_to_gp, name="map_plan_to_gp"),
path("plan_count/", api.plan_count, name="plan_count"),
]
4 changes: 2 additions & 2 deletions users/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def send_email_to_org_admin(sender, instance, created, **kwargs):
<p style="font-size: 16px; margin-bottom: 15px;">Please take the following action:</p>
<ol style="padding-left: 20px; font-size: 15px;">
<li>
<a href="{user_approval_url}"
<a href="{user_approval_url}"
style="color: #1a73e8; text-decoration: none; font-weight: bold;">
Assign user to a project
</a>
Expand All @@ -57,7 +57,7 @@ def send_email_to_org_admin(sender, instance, created, **kwargs):
</tr>
<tr>
<td style="background-color: #f9f9f9; padding: 15px; text-align: center; font-size: 12px; color: #888; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
© 2025 CoRE Stack. All rights reserved.
© 2025 CoRE Stack. All rights reserved.
</td>
</tr>
</table>
Expand Down