[SILO-600] Add slug to application categories and query param (#4433)

* add slug field in applications category and applications filter

* add automation categories
This commit is contained in:
Saurabh Kumar
2025-10-11 16:26:30 +05:30
committed by GitHub
parent f3f93c6aa3
commit 1bb803f480
5 changed files with 71 additions and 4 deletions
@@ -6,6 +6,7 @@
"created_at": "2025-05-15T10:22:30.575Z",
"updated_at": "2025-05-15T10:22:30.575Z",
"name": "Engineering",
"slug": "engineering",
"description": "Engineering Productivity",
"logo_props": {
"logo": {
@@ -22,6 +23,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Agents",
"slug": "agents",
"description": "AI Agents and Automation",
"logo_props": {
"logo": {
@@ -38,6 +40,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Customer Experience",
"slug": "customer-experience",
"description": "Customer Support and Experience",
"logo_props": {
"logo": {
@@ -54,6 +57,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Communication & Collaboration",
"slug": "communication-and-collaboration",
"description": "Team Communication, Collaboration, and Documentation Tools",
"logo_props": {
"logo": {
@@ -70,6 +74,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Development & DevOps",
"slug": "development-and-devops",
"description": "Development Tools, DevOps Platforms, and Testing & QA Tools",
"logo_props": {
"logo": {
@@ -86,6 +91,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Design & Creative",
"slug": "design-and-creative",
"description": "Design and Creative Tools",
"logo_props": {
"logo": {
@@ -102,6 +108,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Analytics & Reporting",
"slug": "analytics-and-reporting",
"description": "Data Analytics, Reporting, and Time Tracking Tools",
"logo_props": {
"logo": {
@@ -118,6 +125,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Security & Compliance",
"slug": "security-and-compliance",
"description": "Security and Compliance Tools",
"logo_props": {
"logo": {
@@ -134,6 +142,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Marketing & Sales",
"slug": "marketing-and-sales",
"description": "Marketing and Sales Tools",
"logo_props": {
"logo": {
@@ -150,6 +159,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Integrations",
"slug": "integrations",
"description": "Integration Tools",
"logo_props": {
"logo": {
@@ -166,6 +176,7 @@
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Importers",
"slug": "importers",
"description": "Importer Tools",
"logo_props": {
"logo": {
@@ -174,5 +185,22 @@
"in_use": "logo"
}
}
},
{
"model": "authentication.applicationcategory",
"pk": "562d381b-7323-4307-a67a-a6776016567c",
"fields": {
"created_at": "2024-01-09T10:22:30.575Z",
"updated_at": "2024-01-09T10:22:30.575Z",
"name": "Automations",
"slug": "automations",
"description": "Automation Tools",
"logo_props": {
"logo": {
"url": "https://media.docs.plane.so/logo/favicon-512x512.png"
},
"in_use": "logo"
}
}
}
]
@@ -0,0 +1,31 @@
# Generated by Django 4.2.22 on 2025-10-10 09:49
from django.db import migrations, models
from django.utils.text import slugify
def update_existing_slugs(apps, schema_editor):
ApplicationCategory = apps.get_model('authentication', 'ApplicationCategory')
for category in ApplicationCategory.objects.all():
category.slug = slugify(category.name)
category.save()
class Migration(migrations.Migration):
dependencies = [
('authentication', '0010_application_links_application_priority_and_more'),
]
operations = [
migrations.AddField(
model_name='applicationcategory',
name='slug',
field=models.SlugField(blank=True, max_length=48, null=True, unique=True),
),
migrations.RunPython(update_existing_slugs, reverse_code=migrations.RunPython.noop),
migrations.AlterField(
model_name='applicationcategory',
name='slug',
field=models.SlugField(max_length=48, unique=True)
),
]
@@ -456,6 +456,7 @@ class ApplicationAttachment(BaseModel):
class ApplicationCategory(BaseModel):
name = models.CharField(max_length=255, unique=True)
slug = models.SlugField(max_length=48, db_index=True, unique=True)
description = models.TextField(null=True, blank=True)
logo_props = models.JSONField(default=dict)
is_active = models.BooleanField(default=True)
@@ -52,7 +52,7 @@ class ApplicationCategorySerializer(serializers.ModelSerializer):
applications_count = serializers.SerializerMethodField()
class Meta:
model = ApplicationCategory
fields = ["id", "name", "description", "logo_props", "is_active", "applications_count"]
fields = ["id", "name", "slug", "description", "logo_props", "is_active", "applications_count"]
def get_applications_count(self, obj):
# send only count of applications that are published
@@ -37,9 +37,16 @@ class PublishedApplicationEndpoint(BaseAPIView):
return Response(serialised_application.data, status=status.HTTP_200_OK)
applications: QuerySet[Application] = self.get_queryset()
serialised_applications = PublishedApplicationSerializer(
applications, many=True
)
serialised_applications = PublishedApplicationSerializer(applications, many=True)
# base query set
application_query_set: QuerySet[Application] = self.get_queryset()
# getting all applications by category from query params
category = request.query_params.get("category", None)
if category:
application_query_set = application_query_set.filter(categories__slug=category)
serialised_applications = PublishedApplicationSerializer(application_query_set, many=True)
return Response(serialised_applications.data, status=status.HTTP_200_OK)