feat: add profile and defalt hospital
This commit is contained in:
@@ -25,7 +25,16 @@ class CmsInstitutionSerializer(serializers.ModelSerializer):
|
||||
'id', 'code', 'name', 'type', 'level',
|
||||
'province', 'city', 'banner_url', 'created_at', 'updated_at',
|
||||
]
|
||||
read_only_fields = ['id', 'created_at', 'updated_at']
|
||||
# type 不可编辑:新增/编辑均不接收,存库恒为 hospital(见 create/update)
|
||||
read_only_fields = ['id', 'type', 'created_at', 'updated_at']
|
||||
|
||||
def create(self, validated_data):
|
||||
validated_data['type'] = 'hospital'
|
||||
return super().create(validated_data)
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
validated_data['type'] = 'hospital' # 每次保存都归一为 hospital
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
def to_representation(self, instance):
|
||||
data = super().to_representation(instance)
|
||||
|
||||
Reference in New Issue
Block a user