import requests from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.views import PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, \ PasswordResetCompleteView from django.http.response import HttpResponse from django.shortcuts import render from django.urls import reverse_lazy from django.views.decorators.csrf import ensure_csrf_cookie from graphene_django.views import GraphQLView from django.utils.translation import gettext_lazy as _ class PrivateGraphQLView(LoginRequiredMixin, GraphQLView): pass @login_required @ensure_csrf_cookie def home(request): if settings.DEBUG: try: return HttpResponse(requests.get('http://localhost:8080/{}'.format(request.get_full_path())).text) except Exception as e: print('Can not connect to dev server at http://localhost:8080:', e) return render(request, 'index.html', {}) class SetPasswordView(PasswordResetView): email_template_name = 'registration/set_password_email.html' subject_template_name = 'registration/set_password_subject.txt' success_url = reverse_lazy('set_password_done') template_name = 'registration/set_password_form.html' title = _('Password setzen') class SetPasswordDoneView(PasswordResetDoneView): template_name = 'registration/set_password_done.html' title = _('Password setzen versandt') class SetPasswordConfirmView(PasswordResetConfirmView): success_url = reverse_lazy('set_password_complete') template_name = 'registration/set_password_confirm.html' title = _('Gib ein Passwort ein') class SetPasswordCompleteView(PasswordResetCompleteView): template_name = 'registration/set_password_complete.html' title = _('Passwort setzen erfolgreich')