MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / ProjectListSerializer

Class ProjectListSerializer

api/projects/serializers.py:21–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20
21class ProjectListSerializer(serializers.ModelSerializer): # type: ignore[type-arg]
22 migration_status = serializers.SerializerMethodField(
23 help_text="Edge migration status of the project; can be one of: "
24 + ", ".join([k.value for k in ProjectIdentityMigrationStatus])
25 )
26 use_edge_identities = serializers.SerializerMethodField()
27
28 class Meta:
29 model = Project
30 fields = (
31 "id",
32 "uuid",
33 "name",
34 "organisation",
35 "hide_disabled_flags",
36 "enable_dynamo_db",
37 "migration_status",
38 "use_edge_identities",
39 "prevent_flag_defaults",
40 "enable_realtime_updates",
41 "only_allow_lower_case_feature_names",
42 "feature_name_regex",
43 "show_edge_identity_overrides_for_feature",
44 "stale_flags_limit_days",
45 "edge_v2_migration_status",
46 "minimum_change_request_approvals",
47 "enforce_feature_owners",
48 )
49 read_only_fields = (
50 "enable_dynamo_db",
51 "edge_v2_migration_status",
52 )
53
54 def get_migration_status(self, obj: Project) -> str:
55 if not settings.PROJECT_METADATA_TABLE_NAME_DYNAMO:
56 migration_status = ProjectIdentityMigrationStatus.NOT_APPLICABLE.value
57 elif obj.is_edge_project_by_default:
58 migration_status = ProjectIdentityMigrationStatus.MIGRATION_COMPLETED.value
59 else:
60 migration_status = IdentityMigrator(obj.id).migration_status.value # type: ignore[no-untyped-call]
61
62 # Add migration status to the context - to be used by `get_use_edge_identities`
63 self.context["migration_status"] = migration_status
64
65 return migration_status
66
67 def get_use_edge_identities(self, obj: Project) -> bool:
68 return ( # type: ignore[no-any-return]
69 self.context["migration_status"]
70 == ProjectIdentityMigrationStatus.MIGRATION_COMPLETED.value
71 )
72
73
74class ProjectCreateSerializer(ReadOnlyIfNotValidPlanMixin, ProjectListSerializer):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…