Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
adding pytest to the requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Sep 24, 2024
1 parent c1a0b13 commit b3d3c64
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 35 deletions.
4 changes: 3 additions & 1 deletion backoffice/.envs/local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
USE_DOCKER=yes
IPYTHONDIR=/app/.ipython


# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
Expand All @@ -25,3 +24,6 @@ AIRFLOW_BASE_URL=http://airflow-webserver:8080
AIRFLOW_TOKEN=YWlyZmxvdzphaXJmbG93

SERVICENOW_URL=https://cerntraining.service-now.com

# Frontend
FRONTEND_LOGIN_SUCCESS=http://127.0.0.1:5000/success
2 changes: 0 additions & 2 deletions backoffice/backoffice/users/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def is_open_for_signup(
) -> bool:
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)



def populate_user(
self,
request: HttpRequest,
Expand Down
8 changes: 1 addition & 7 deletions backoffice/backoffice/users/api/views.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import requests
from urllib.parse import urljoin
from django.urls import reverse

from allauth.socialaccount.providers.oauth2.client import OAuth2Client
from allauth.socialaccount.providers.orcid.views import OrcidOAuth2Adapter
from django.contrib.auth import get_user_model
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, UpdateModelMixin
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
from rest_framework.views import APIView

from backoffice.users.api.serializers import UserSerializer

User = get_user_model()
Expand Down
5 changes: 0 additions & 5 deletions backoffice/backoffice/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,5 @@ class UserRedirectView(LoginRequiredMixin, RedirectView):
def get_redirect_url(self):
return reverse("users:detail", kwargs={"pk": self.request.user.pk})

def success(request):
import ipdb;ipdb.set_trace()
return JsonResponse(data={"wow":request.user.email})

user_redirect_view = UserRedirectView.as_view()


19 changes: 4 additions & 15 deletions backoffice/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,19 @@
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.headless",
"allauth.socialaccount.providers.orcid",
"django_celery_beat",
"rest_framework",
"rest_framework.authtoken",
"corsheaders",
"drf_spectacular",
"allauth.socialaccount.providers.orcid",
"django_prometheus",
"django_opensearch_dsl",
"django_elasticsearch_dsl_drf",
"rest_framework_simplejwt",
"django_json_widget",
]

REST_AUTH = {
"SESSION_LOGIN": True,
"USE_JWT": True,
"JWT_AUTH_COOKIE": "auth",
'JWT_AUTH_REFRESH_COOKIE': 'my-refresh-token',
"JWT_AUTH_HTTPONLY": False,
}

LOCAL_APPS = ["backoffice.users", "backoffice.workflows", "backoffice.management"]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand All @@ -136,7 +127,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
AUTH_USER_MODEL = "users.User"
# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
LOGIN_REDIRECT_URL = "http://127.0.0.1:5000/success"
LOGIN_REDIRECT_URL = env("FRONTEND_LOGIN_SUCCESS")
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
LOGIN_URL = "account_login"

Expand Down Expand Up @@ -170,7 +161,7 @@
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.middleware.common.CommonMiddleware",
#"django.middleware.csrf.CsrfViewMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
Expand Down Expand Up @@ -340,7 +331,7 @@
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_VERIFICATION = False
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_ADAPTER = "backoffice.users.adapters.AccountAdapter"
# https://django-allauth.readthedocs.io/en/latest/forms.html
Expand Down Expand Up @@ -391,8 +382,6 @@
"BASE_DOMAIN": "sandbox.orcid.org"
}
}
SOCIALACCOUNT_EMAIL_VERIFICATION = False
ACCOUNT_EMAIL_VERIFICATION = False


# Opensearch
Expand Down
7 changes: 3 additions & 4 deletions backoffice/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from allauth.socialaccount.providers.orcid.views import oauth2_callback
from allauth.socialaccount.providers.orcid.views import oauth2_callback, oauth2_login
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
Expand All @@ -9,8 +9,8 @@
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from django.views.decorators.csrf import csrf_exempt

from backoffice.users.views import success

urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
Expand All @@ -21,6 +21,7 @@
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("backoffice.users.urls", namespace="users")),
path("accounts/orcid/login/", csrf_exempt(oauth2_login), name="orcid_login"),
path("accounts/", include("allauth.urls")),
path("", include("django_prometheus.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Expand All @@ -32,7 +33,6 @@
# API URLS
urlpatterns += [
# API base url
path("accounts/login/success/",success),
path("api/oauth/authorized/orcid/", oauth2_callback, name="orcid_callback"),
path("api/", include("config.search_router")),
path("api/", include("config.api_router")),
Expand All @@ -46,7 +46,6 @@
),
path("api/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
path("_allauth/", include("allauth.headless.urls")),
]


Expand Down
1 change: 0 additions & 1 deletion logs/scheduler/latest

This file was deleted.

0 comments on commit b3d3c64

Please sign in to comment.