-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
DEEP SupportDEEP's support and maintenance issuesDEEP's support and maintenance issues
Description
Problem Statement
Creating new organization features uses a Rest API.
Acceptance Criteria
Creating new organization works with a graphql mutation.
Additional Information
serializer
server/apps/organization/serializers.py
Lines 34 to 55 in 0c1dc33
| class OrganizationSerializer( | |
| DynamicFieldsMixin, RemoveNullFieldsMixin, UserResourceSerializer, | |
| ): | |
| organization_type_display = OrganizationTypeSerializer( | |
| source='organization_type', read_only=True, | |
| ) | |
| regions_display = SimpleRegionSerializer( | |
| source='regions', read_only=True, many=True, | |
| ) | |
| logo_url = URLCachedFileField(source='logo.file', allow_null=True, required=False) | |
| merged_as = MergedAsOrganizationSerializer(source='parent', read_only=True) | |
| client_id = None | |
| class Meta: | |
| model = Organization | |
| exclude = ('parent',) | |
| read_only_fields = ('verified', 'logo_url',) | |
| def create(self, validated_data): | |
| organization = super().create(validated_data) | |
| organization.created_by = organization.modified_by = self.context['request'].user | |
| return organization |
views
server/apps/organization/views.py
Lines 27 to 46 in 0c1dc33
| class OrganizationViewSet( | |
| mixins.CreateModelMixin, | |
| mixins.RetrieveModelMixin, | |
| mixins.ListModelMixin, | |
| viewsets.GenericViewSet, | |
| ): | |
| serializer_class = OrganizationSerializer | |
| permission_classes = [permissions.IsAuthenticated] | |
| pagination_class = AutocompleteSetPagination | |
| authentication_classes = [CSRFExemptSessionAuthentication] | |
| filter_backends = (django_filters.rest_framework.DjangoFilterBackend, | |
| filters.SearchFilter, filters.OrderingFilter) | |
| search_fields = ('title', 'short_name', 'long_name', 'url',) | |
| filterset_fields = ('verified',) | |
| ordering = ('title',) | |
| def get_queryset(self): | |
| if self.kwargs.get('pk'): | |
| return Organization.objects.prefetch_related('parent') | |
| return Organization.objects.filter(parent=None) |
testcase
Not updated
Rest Framework URLs
method: POST
url: /api/v1/organizations
request payload: {
"title": str
"shortName":str,
"url": str
"organizationType": ID,
"logo": ID
}
response: {
"id":ID,
"modifiedAt": datetime
"modifiedBy": ID,
"createdByName": str,
"modifiedByName": str,
"organizationTypeDisplay": Object / Organization type,
"regionsDisplay": RegionList,
"createdAt": datetime,
"title": str,
"shortName": str,
"longName": str,
"url": str,
"verified": bool,
"popularity": int,
"createdBy": ID,
"organizationType": ID,
"regions": regionobject
}
Metadata
Metadata
Assignees
Labels
DEEP SupportDEEP's support and maintenance issuesDEEP's support and maintenance issues