Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Apply changes after review

Maciej Korycinskic36ed4e2decf
diff --git a/saleor/account/migrations/0033_serviceaccount.py b/saleor/account/migrations/0033_serviceaccount.py
index 1a46edbabe..aeb3a28b8a 100644
--- a/saleor/account/migrations/0033_serviceaccount.py
+++ b/saleor/account/migrations/0033_serviceaccount.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.2.4 on 2019-08-30 10:10
+# Generated by Django 2.2.4 on 2019-09-03 11:28
import django.contrib.postgres.fields.jsonb
import oauthlib.common
@@ -69,7 +69,7 @@ class Migration(migrations.Migration):
),
],
options={
- "permissions": (("manage_service_account", "Manage service account"),)
+ "permissions": (("manage_service_accounts", "Manage service account"),)
},
)
]
diff --git a/saleor/account/models.py b/saleor/account/models.py
index 6d1b8617b9..884c85548c 100644
--- a/saleor/account/models.py
+++ b/saleor/account/models.py
@@ -203,7 +203,7 @@ class ServiceAccount(ModelWithMetadata):
class Meta:
permissions = (
(
- "manage_service_account",
+ "manage_service_accounts",
pgettext_lazy("Permission description", "Manage service account"),
),
)
diff --git a/saleor/core/permissions.py b/saleor/core/permissions.py
index c429f9ab01..034930139b 100644
--- a/saleor/core/permissions.py
+++ b/saleor/core/permissions.py
@@ -3,7 +3,7 @@ from django.contrib.auth.models import Permission
MODELS_PERMISSIONS = [
"account.manage_users",
"account.manage_staff",
- "account.manage_service_account",
+ "account.manage_service_accounts",
"account.impersonate_users",
"discount.manage_discounts",
"giftcard.manage_gift_card",
diff --git a/saleor/graphql/account/mutations/service_account.py b/saleor/graphql/account/mutations/service_account.py
index 90bbcd1631..09541a9a5e 100644
--- a/saleor/graphql/account/mutations/service_account.py
+++ b/saleor/graphql/account/mutations/service_account.py
@@ -37,7 +37,7 @@ class ServiceAccountCreate(ModelMutation):
class Meta:
description = "Creates a new service account"
model = models.ServiceAccount
- permissions = ("account.manage_service_account",)
+ permissions = ("account.manage_service_accounts",)
@classmethod
def clean_input(cls, info, instance, data):
@@ -61,6 +61,12 @@ class ServiceAccountCreate(ModelMutation):
response.auth_token = instance.auth_token
return response
+ @classmethod
+ def success_response(cls, instance):
+ response = super().success_response(instance)
+ response.auth_token = instance.auth_token
+ return response
+
class ServiceAccountUpdate(ModelMutation):
class Arguments:
@@ -75,7 +81,7 @@ class ServiceAccountUpdate(ModelMutation):
class Meta:
description = "Updates an existing service account"
model = models.ServiceAccount
- permissions = ("account.manage_service_account",)
+ permissions = ("account.manage_service_accounts",)
@classmethod
def clean_input(cls, info, instance, data):
@@ -95,13 +101,13 @@ class ServiceAccountDelete(ModelDeleteMutation):
class Meta:
description = "Deletes a service account"
model = models.ServiceAccount
- permissions = ("account.manage_service_account",)
+ permissions = ("account.manage_service_accounts",)
class ServiceAccountUpdatePrivateMeta(UpdateMetaBaseMutation):
class Meta:
description = "Updates private metadata for a service account."
- permissions = ("account.manage_service_account",)
+ permissions = ("account.manage_service_accounts",)
model = models.ServiceAccount
public = False
@@ -110,5 +116,5 @@ class ServiceAccountClearStoredPrivateMeta(ClearMetaBaseMutation):
class Meta:
description = "Clear stored metadata value."
model = models.ServiceAccount
- permissions = ("account.manage_service_account",)
+ permissions = ("account.manage_service_accounts",)
public = False
diff --git a/saleor/graphql/account/schema.py b/saleor/graphql/account/schema.py
index a6d0798e2e..df3bbbf4cb 100644
--- a/saleor/graphql/account/schema.py
+++ b/saleor/graphql/account/schema.py
@@ -132,11 +132,11 @@ class AccountQueries(graphene.ObjectType):
city_area=city_area,
)
- @permission_required("account.manage_service_account")
+ @permission_required("account.manage_service_accounts")
def resolve_service_accounts(self, info, **_kwargs):
return resolve_service_accounts(info)
- @permission_required("account.manage_service_account")
+ @permission_required("account.manage_service_accounts")
def resolve_service_account(self, info, id):
return graphene.Node.get_node_from_global_id(info, id, ServiceAccount)
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.py
index 00491e87cb..6eab9e9cea 100644
--- a/saleor/graphql/account/types.py
+++ b/saleor/graphql/account/types.py
@@ -158,16 +158,20 @@ class ServiceAccount(MetadataObjectType, CountableDjangoObjectType):
permissions = graphene.List(
PermissionDisplay, description="List of the service's permissions."
)
- created = graphene.DateTime(description="Created date")
- is_active = graphene.Boolean()
- name = graphene.String()
+ created = graphene.DateTime(
+ description="The date and time when the service account was created."
+ )
+ is_active = graphene.Boolean(
+ description="Determine if service account will be set active or not."
+ )
+ name = graphene.String(description="Name of the service account.")
auth_token = graphene.String(description="Last 4 characters of the token")
class Meta:
description = "Represents service account data."
interfaces = [relay.Node]
model = models.ServiceAccount
- permissions = ("account.manage_service_account",)
+ permissions = ("account.manage_service_accounts",)
only_fields = ["name" "permissions", "created", "is_active", "auth_token", "id"]
@staticmethod
diff --git a/tests/api/test_account_bot.py b/tests/api/test_account_service_account.py
similarity index 100%
rename from tests/api/test_account_bot.py
rename to tests/api/test_account_service_account.py
diff --git a/tests/conftest.py b/tests/conftest.py
index c91cab8b91..8059ef88f2 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -426,7 +426,7 @@ def permission_manage_plugins():
@pytest.fixture
def permission_manage_service_accounts():
- return Permission.objects.get(codename="manage_service_account")
+ return Permission.objects.get(codename="manage_service_accounts")
@pytest.fixture