Browse Source

fix(orgs): 改正单词拼写

pull/4939/head
xinwen 4 years ago committed by 老广
parent
commit
44d9aff573
  1. 6
      apps/orgs/serializers.py
  2. 2
      apps/orgs/urls/api_urls.py
  3. 10
      apps/tickets/tests.py

6
apps/orgs/serializers.py

@ -26,12 +26,12 @@ class OrgSerializer(ModelSerializer):
read_only_fields = ['created_by', 'date_created']
def create(self, validated_data):
members = self._pop_memebers(validated_data)
members = self._pop_members(validated_data)
instance = Organization.objects.create(**validated_data)
OrganizationMember.objects.add_users_by_role(instance, *members)
return instance
def _pop_memebers(self, validated_data):
def _pop_members(self, validated_data):
return (
validated_data.pop('users', None),
validated_data.pop('admins', None),
@ -39,7 +39,7 @@ class OrgSerializer(ModelSerializer):
)
def update(self, instance, validated_data):
members = self._pop_memebers(validated_data)
members = self._pop_members(validated_data)
for attr, value in validated_data.items():
setattr(instance, attr, value)
instance.save()

2
apps/orgs/urls/api_urls.py

@ -14,7 +14,7 @@ router = DefaultRouter()
bulk_router = BulkRouter()
router.register(r'orgs', api.OrgViewSet, 'org')
bulk_router.register(r'org-member-relation', api.OrgMemberRelationBulkViewSet, 'org-memeber-relation')
bulk_router.register(r'org-member-relation', api.OrgMemberRelationBulkViewSet, 'org-member-relation')
old_version_urlpatterns = [
re_path('(?P<resource>org)/.*', capi.redirect_plural_name_api)

10
apps/tickets/tests.py

@ -43,19 +43,19 @@ class TicketTest(APITestCase):
])
new_user = User.objects.create
new_org_memeber = OrganizationMember.objects.create
new_org_member = OrganizationMember.objects.create
u = new_user(name='user-01', username='user-01', email='user-01@jms.com')
new_org_memeber(org=org_01, user=u, role=ORG_ROLE.USER)
new_org_memeber(org=org_02, user=u, role=ORG_ROLE.USER)
new_org_member(org=org_01, user=u, role=ORG_ROLE.USER)
new_org_member(org=org_02, user=u, role=ORG_ROLE.USER)
self.user_01 = u
u = new_user(name='org-admin-01', username='org-admin-01', email='org-admin-01@jms.com')
new_org_memeber(org=org_01, user=u, role=ORG_ROLE.ADMIN)
new_org_member(org=org_01, user=u, role=ORG_ROLE.ADMIN)
self.org_admin_01 = u
u = new_user(name='org-admin-02', username='org-admin-02', email='org-admin-02@jms.com')
new_org_memeber(org=org_02, user=u, role=ORG_ROLE.ADMIN)
new_org_member(org=org_02, user=u, role=ORG_ROLE.ADMIN)
self.org_admin_02 = u
def test_create_request_asset_perm(self):

Loading…
Cancel
Save