Fix minor issues
This commit is contained in:
parent
e5b0fe539f
commit
5d614dd7e5
|
|
@ -7,17 +7,3 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
@import "@/styles/_mixins.scss";
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,6 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {},
|
|
||||||
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "@/styles/_variables.scss";
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ import REDEEM_COUPON from '@/graphql/gql/mutations/redeemCoupon.gql';
|
||||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
validateBeforeSubmit() {
|
validateBeforeSubmit() {
|
||||||
|
|
|
||||||
|
|
@ -93,18 +93,17 @@ class HepClient:
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def customer_me(self, token):
|
def customer_me(self, token):
|
||||||
response = self._call('/rest/V1/customers/me', additional_headers={'authorization': 'Bearer {}'.format(token)})
|
response = self._call('/rest/V1/customers/me', additional_headers={'authorization': f'Bearer {token}'})
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def customer_activate(self, confirmation_key, user_id):
|
def customer_activate(self, confirmation_key, user_id):
|
||||||
response = self._call("/customer/account/confirm/?back_url=&id={}&key={}"
|
response = self._call(f'/customer/account/confirm/?back_url=&id={user_id}&key={confirmation_key}', method='get')
|
||||||
.format(user_id, confirmation_key), method='get')
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def customers_search(self, admin_token, email):
|
def customers_search(self, admin_token, email):
|
||||||
response = self._call("/rest/V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]="
|
response = self._call('/rest/V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]='
|
||||||
"email&searchCriteria[filterGroups][0][filters][0][value]={}".format(email),
|
f'email&searchCriteria[filterGroups][0][filters][0][value]={email}',
|
||||||
additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
|
additional_headers={'authorization': f'Bearer {admin_token}'})
|
||||||
|
|
||||||
json_data = response.json()
|
json_data = response.json()
|
||||||
if len(json_data['items']) > 0:
|
if len(json_data['items']) > 0:
|
||||||
|
|
@ -113,19 +112,19 @@ class HepClient:
|
||||||
|
|
||||||
def customers_by_id(self, admin_token, user_id):
|
def customers_by_id(self, admin_token, user_id):
|
||||||
response = self._call('/rest/V1/customers/{}'.format(user_id),
|
response = self._call('/rest/V1/customers/{}'.format(user_id),
|
||||||
additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
|
additional_headers={'authorization': f'Bearer {admin_token}'})
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def _customer_orders(self, admin_token, customer_id):
|
def _customer_orders(self, admin_token, customer_id):
|
||||||
url = ("/rest/V1/orders/?searchCriteria[filterGroups][0][filters][0]["
|
url = ('/rest/V1/orders/?searchCriteria[filterGroups][0][filters][0]['
|
||||||
"field]=customer_id&searchCriteria[filterGroups][0][filters][0][value]={}".format(customer_id))
|
f'field]=customer_id&searchCriteria[filterGroups][0][filters][0][value]={customer_id}')
|
||||||
|
|
||||||
response = self._call(url, additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
|
response = self._call(url, additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def coupon_redeem(self, coupon, customer_id):
|
def coupon_redeem(self, coupon, customer_id):
|
||||||
try:
|
try:
|
||||||
response = self._call('/rest/deutsch/V1/coupon/{}/customer/{}'.format(coupon, customer_id), method='put')
|
response = self._call(f'/rest/deutsch/V1/coupon/{coupon}/customer/{customer_id}', method='put')
|
||||||
except HepClientException as e:
|
except HepClientException as e:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class UserLoggedInCookieMiddleWare(MiddlewareMixin):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
class UserHasLicenseeMiddleWare(MiddlewareMixin):
|
class UserHasLicenseMiddleWare(MiddlewareMixin):
|
||||||
|
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
if request.path == '/api/graphql/':
|
if request.path == '/api/graphql/':
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ MIDDLEWARE += [
|
||||||
'core.middleware.ThreadLocalMiddleware',
|
'core.middleware.ThreadLocalMiddleware',
|
||||||
'core.middleware.CommonRedirectMiddleware',
|
'core.middleware.CommonRedirectMiddleware',
|
||||||
'core.middleware.UserLoggedInCookieMiddleWare',
|
'core.middleware.UserLoggedInCookieMiddleWare',
|
||||||
'core.middleware.UserHasLicenseeMiddleWare',
|
'core.middleware.UserHasLicenseMiddleWare',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'core.urls'
|
ROOT_URLCONF = 'core.urls'
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ def is_private_api_call_allowed(user, body):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# logged in users should only be able to access all resources if the have a valid license
|
||||||
|
# logged in users without valid license have only access to logout, me & coupon mutations
|
||||||
if re.search(r"mutation\s*.*\s*logout\s*{", body_unicode) or re.search(r"query\s*.*\s*me\s*{", body_unicode)\
|
if re.search(r"mutation\s*.*\s*logout\s*{", body_unicode) or re.search(r"query\s*.*\s*me\s*{", body_unicode)\
|
||||||
or re.search(r"mutation\s*Coupon", body_unicode):
|
or re.search(r"mutation\s*Coupon", body_unicode):
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -16,22 +16,18 @@ from core.models import AdminData
|
||||||
from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR
|
from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR
|
||||||
|
|
||||||
|
|
||||||
class RegistrationError(graphene.ObjectType):
|
|
||||||
field = graphene.String()
|
|
||||||
|
|
||||||
|
|
||||||
class Registration(relay.ClientIDMutation):
|
class Registration(relay.ClientIDMutation):
|
||||||
class Input:
|
class Input:
|
||||||
confirmation_key_input = graphene.String()
|
confirmation_key = graphene.String()
|
||||||
user_id_input = graphene.Int()
|
user_id_input = graphene.Int()
|
||||||
|
|
||||||
success = graphene.Boolean()
|
success = graphene.Boolean()
|
||||||
message = graphene.String()
|
message = graphene.String()
|
||||||
errors = graphene.List(RegistrationError) # todo: change for consistency
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||||
confirmation_key = kwargs.get('confirmation_key_input')
|
confirmation_key = kwargs.get('confirmation_key')
|
||||||
user_id = kwargs.get('user_id_input')
|
user_id = kwargs.get('user_id_input')
|
||||||
|
|
||||||
hep_client = HepClient()
|
hep_client = HepClient()
|
||||||
|
|
@ -53,7 +49,7 @@ class Registration(relay.ClientIDMutation):
|
||||||
if status_msg:
|
if status_msg:
|
||||||
return cls.return_registration_msg(status_msg)
|
return cls.return_registration_msg(status_msg)
|
||||||
|
|
||||||
return cls(success=True, errors=[], message='success')
|
return cls(success=True, message='success')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def return_registration_msg(cls, message):
|
def return_registration_msg(cls, message):
|
||||||
|
|
@ -61,7 +57,7 @@ class Registration(relay.ClientIDMutation):
|
||||||
if message == UNKNOWN_ERROR:
|
if message == UNKNOWN_ERROR:
|
||||||
raise Exception(message)
|
raise Exception(message)
|
||||||
|
|
||||||
return cls(success=True, errors=[], message=message)
|
return cls(success=True, message=message)
|
||||||
|
|
||||||
|
|
||||||
class RegistrationMutations:
|
class RegistrationMutations:
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,13 @@ class RegistrationTests(TestCase):
|
||||||
registration(input: $input) {
|
registration(input: $input) {
|
||||||
success
|
success
|
||||||
message
|
message
|
||||||
errors {
|
|
||||||
field
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
return self.client.execute(mutation, variables={
|
return self.client.execute(mutation, variables={
|
||||||
'input': {
|
'input': {
|
||||||
'confirmationKeyInput': confirmation_key,
|
'confirmationKey': confirmation_key,
|
||||||
'userIdInput': user_id
|
'userIdInput': user_id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue