Add stage confirmation view
This commit is contained in:
parent
75e1597d6f
commit
68bba26c75
|
|
@ -5,7 +5,7 @@ from graphene_django.views import GraphQLView
|
||||||
|
|
||||||
from api.schema_public import schema
|
from api.schema_public import schema
|
||||||
|
|
||||||
from core.views import PrivateGraphQLView
|
from core.views import PrivateGraphQLView, ConfirmationKeyView
|
||||||
|
|
||||||
app_name = 'api'
|
app_name = 'api'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
@ -17,5 +17,6 @@ if settings.DEBUG:
|
||||||
urlpatterns += [url(r'^graphiql-public', csrf_exempt(GraphQLView.as_view(schema=schema, graphiql=True,
|
urlpatterns += [url(r'^graphiql-public', csrf_exempt(GraphQLView.as_view(schema=schema, graphiql=True,
|
||||||
pretty=True)))]
|
pretty=True)))]
|
||||||
urlpatterns += [url(r'^graphiql', csrf_exempt(PrivateGraphQLView.as_view(graphiql=True, pretty=True)))]
|
urlpatterns += [url(r'^graphiql', csrf_exempt(PrivateGraphQLView.as_view(graphiql=True, pretty=True)))]
|
||||||
|
urlpatterns += [url(r'^confirmation', ConfirmationKeyDisplayView.as_view(), name='confirmation_key_display')]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ class HepClientUnauthorizedException(Exception):
|
||||||
|
|
||||||
|
|
||||||
class HepClient:
|
class HepClient:
|
||||||
URL = 'https://stage.hep-verlag.ch'
|
URL = settings.HEP_URL
|
||||||
# URL = 'https://www.hep-verlag.ch'
|
|
||||||
WEBSITE_ID = 1
|
WEBSITE_ID = 1
|
||||||
HEADERS = {
|
HEADERS = {
|
||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
|
|
@ -118,13 +117,14 @@ class HepClient:
|
||||||
})
|
})
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def customers_search(self, 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))
|
"=email&searchCriteria[filterGroups][0][filters][0][value]={}".format(email), method='get',
|
||||||
|
additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
|
||||||
|
|
||||||
json_data = response.json()
|
json_data = response.json()
|
||||||
if len(json_data) > 0:
|
if len(json_data['items']) > 0:
|
||||||
return json_data[0]
|
return json_data['items'][0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _customer_orders(self, admin_token, customer_id):
|
def _customer_orders(self, admin_token, customer_id):
|
||||||
|
|
|
||||||
|
|
@ -374,5 +374,6 @@ USE_LOCAL_REGISTRATION = False
|
||||||
# HEP
|
# HEP
|
||||||
HEP_ADMIN_USER = "adminuser"
|
HEP_ADMIN_USER = "adminuser"
|
||||||
HEP_ADMIN_PASSWORD = "password"
|
HEP_ADMIN_PASSWORD = "password"
|
||||||
|
HEP_URL = 'https://stage.hep-verlag.ch'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Confirmation</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="/{{ confirmation_key }}">Email bestätitgen</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -7,9 +7,13 @@ from django.http.response import HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||||
|
from django.views.generic import TemplateView
|
||||||
from graphene_django.views import GraphQLView
|
from graphene_django.views import GraphQLView
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from core.hep_client import HepClient
|
||||||
|
from core.models import AdminData
|
||||||
|
|
||||||
|
|
||||||
class PrivateGraphQLView(LoginRequiredMixin, GraphQLView):
|
class PrivateGraphQLView(LoginRequiredMixin, GraphQLView):
|
||||||
pass
|
pass
|
||||||
|
|
@ -73,3 +77,20 @@ class LegacySetPasswordConfirmView(PasswordResetConfirmView):
|
||||||
class LegacySetPasswordCompleteView(PasswordResetCompleteView):
|
class LegacySetPasswordCompleteView(PasswordResetCompleteView):
|
||||||
template_name = 'registration/set_password_complete.html'
|
template_name = 'registration/set_password_complete.html'
|
||||||
title = _('Passwort setzen erfolgreich')
|
title = _('Passwort setzen erfolgreich')
|
||||||
|
|
||||||
|
|
||||||
|
class ConfirmationKeyDisplayView(TemplateView):
|
||||||
|
|
||||||
|
template_name = 'confirmation_key.html'
|
||||||
|
|
||||||
|
def get_context_data(self, request, *args, **kwargs):
|
||||||
|
|
||||||
|
email = request.GET.get('email', '')
|
||||||
|
|
||||||
|
hep_client = HepClient()
|
||||||
|
admin_token = AdminData.objects.get_admin_token()
|
||||||
|
hep_user = hep_client.customers_search(admin_token, email)
|
||||||
|
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['confirmation_key'] = hep_user['confirmation']
|
||||||
|
return context
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue