def accept_project_confirm( request, uidb64, pidb64, token, template_name='project/project_join_request_confirm.html', ): accept = request.GET.get('accept', 'True').lower() == 'true' role = request.GET.get('role', 'normal') try: uid = force_text(urlsafe_base64_decode(uidb64)) pid = force_text(urlsafe_base64_decode(pidb64)) user = User.objects.get(pk=uid) join_request = ProjectJoinRequest.objects.get(pk=pid) except ( TypeError, ValueError, OverflowError, ProjectJoinRequest.DoesNotExist, User.DoesNotExist, ): user = None join_request = None request_data = { 'join_request': join_request, 'will_responded_by': user, } context = { 'title': 'Project Join Request', 'success': True, 'accept': accept, 'role': role, 'notification_url': get_frontend_url('notifications/'), 'join_request': join_request, 'project_url': get_frontend_url('projects/{}/#/general'.format( join_request.project.id)) if join_request else None, } if (join_request and user) is not None and\ project_request_token_generator.check_token(request_data, token): if accept: ProjectViewSet._accept_request(user, join_request, role) else: ProjectViewSet._reject_request(user, join_request) else: context['success'] = False return TemplateResponse(request, template_name, context)
def user_activate_confirm( request, uidb64, token, template_name='registration/user_activation_confirm.html', token_generator=default_token_generator, ): try: uid = force_text(urlsafe_base64_decode(uidb64)) user = User.objects.get(pk=uid) except (TypeError, ValueError, OverflowError, User.DoesNotExist): user = None context = { 'success': True, 'login_url': get_frontend_url('login/'), 'title': 'Account Activation', } if user is not None and token_generator.check_token(user, token): user.is_active = True user.profile.login_attempts = 0 user.save() else: context['success'] = False return TemplateResponse(request, template_name, context)
), # Combined API View re_path(get_api_path(r'combined/$'), CombinedView.as_view()), # Viewsets re_path(get_api_path(''), include(router.urls)), # DRF auth, TODO: logout re_path(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), re_path(r'^project-viz/(?P<project_stat_id>\d+)/(?P<token>[0-9a-f-]+)/$', ProjectPublicVizView.as_view(), name='project-stat-viz-public'), re_path(r'^favicon.ico$', RedirectView.as_view(url=get_frontend_url('favicon.ico')), name="favicon"), ] + [ # graphql patterns re_path('^graphql/?$', csrf_exempt(CustomGraphQLView.as_view())), re_path(r'^favicon.ico$', RedirectView.as_view(url=get_frontend_url('favicon.ico'), ), name="favicon"), ] + static.static(settings.MEDIA_URL, view=xframe_options_exempt(serve), document_root=settings.MEDIA_ROOT) if settings.DEBUG: import debug_toolbar if 'debug_toolbar' in settings.INSTALLED_APPS: urlpatterns += [
# Docs url(get_api_path(r'docs/'), DocsView.as_view()), # DRF auth, TODO: logout url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), # NOTE: For debuging email templates url(r'^pr-email/$', PasswordReset.as_view()), url(r'^aa-email/$', AccountActivate.as_view()), url(r'^pj-email/$', ProjectJoinRequest.as_view()), url(r'^favicon.ico$', RedirectView.as_view( url=get_frontend_url('favicon.ico'), ), name="favicon"), ] + static.static( settings.MEDIA_URL, view=xframe_options_exempt(serve), document_root=settings.MEDIA_ROOT) urlpatterns += [ url(r'^$', FrontendView.as_view()), ] handler404 = Api_404View.as_view() # TODO Uncomment after fixing custom autofixtures # autofixture.autodiscover()