* dev: remove auto script for registration * dev: make all of the instance admins as owners when adding a instance admin * dev: remove sign out endpoint * dev: update takeoff script to register the instance * dev: reapply instance model * dev: check none for instance configuration encryptions * dev: encrypting secrets configuration * dev: user workflow for registration in instances * dev: add email automation configuration * dev: remove unused imports * dev: reallign migrations * dev: reconfigure license engine registrations * dev: move email check to background worker * dev: add sign up * chore: signup error message * dev: updated onboarding workflows and instance setting * dev: updated template for magic login * chore: page migration changed * dev: updated migrations and authentication for license and update template for workspace invite --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
49 lines
No EOL
1.5 KiB
Python
49 lines
No EOL
1.5 KiB
Python
# Module imports
|
|
from plane.license.models import Instance, InstanceAdmin, InstanceConfiguration
|
|
from plane.app.serializers import BaseSerializer
|
|
from plane.app.serializers import UserAdminLiteSerializer
|
|
from plane.license.utils.encryption import decrypt_data
|
|
|
|
class InstanceSerializer(BaseSerializer):
|
|
primary_owner_details = UserAdminLiteSerializer(source="primary_owner", read_only=True)
|
|
|
|
class Meta:
|
|
model = Instance
|
|
fields = "__all__"
|
|
read_only_fields = [
|
|
"id",
|
|
"instance_id",
|
|
"license_key",
|
|
"api_key",
|
|
"version",
|
|
"email",
|
|
"last_checked_at",
|
|
"is_setup_done",
|
|
]
|
|
|
|
|
|
class InstanceAdminSerializer(BaseSerializer):
|
|
user_detail = UserAdminLiteSerializer(source="user", read_only=True)
|
|
|
|
class Meta:
|
|
model = InstanceAdmin
|
|
fields = "__all__"
|
|
read_only_fields = [
|
|
"id",
|
|
"instance",
|
|
"user",
|
|
]
|
|
|
|
class InstanceConfigurationSerializer(BaseSerializer):
|
|
|
|
class Meta:
|
|
model = InstanceConfiguration
|
|
fields = "__all__"
|
|
|
|
def to_representation(self, instance):
|
|
data = super().to_representation(instance)
|
|
# Decrypt secrets value
|
|
if instance.key in ["OPENAI_API_KEY", "GITHUB_CLIENT_SECRET", "EMAIL_HOST_PASSWORD", "UNSPLASH_ACESS_KEY"] and instance.value is not None:
|
|
data["value"] = decrypt_data(instance.value)
|
|
|
|
return data |