diff options
-rw-r--r-- | blocks/.dockerignore | 5 | ||||
-rw-r--r-- | blocks/Dockerfile | 3 | ||||
-rw-r--r-- | blocks/Dockerfile.patch | 10 | ||||
-rw-r--r-- | blocks/authAPI/views.py | 4 | ||||
-rw-r--r-- | blocks/blocks/settings.py | 3 | ||||
-rw-r--r-- | blocks/eda-frontend/.babelrc.json | 3 | ||||
-rw-r--r-- | blocks/eda-frontend/src/redux/authSlice.js | 10 | ||||
-rwxr-xr-x | blocks/init.sh | 6 | ||||
-rw-r--r-- | blocks/simulationAPI/helpers/scilab_manager.py | 3 |
9 files changed, 20 insertions, 27 deletions
diff --git a/blocks/.dockerignore b/blocks/.dockerignore index 5e6b38b0..6de483dd 100644 --- a/blocks/.dockerignore +++ b/blocks/.dockerignore @@ -9,8 +9,11 @@ env* *.sqlite3 *.swp .DS_Store -**/.env +.env **/.env.* +**/.git* +**/.nvmrc +**/.vscode **/build **/node_modules tags diff --git a/blocks/Dockerfile b/blocks/Dockerfile index f8bfc6ae..d5d630ca 100644 --- a/blocks/Dockerfile +++ b/blocks/Dockerfile @@ -121,9 +121,6 @@ COPY . . # Configure venv and sqlite3 RUN ./install.sh -# For localhost only -RUN echo 'WDS_SOCKET_PORT=80' > eda-frontend/.env.local - # Cleanup RUN apt-get autoremove -qq --purge gawk python3-pip python3-venv wget xz-utils RUN apt-get clean -qq diff --git a/blocks/Dockerfile.patch b/blocks/Dockerfile.patch index 0a94dd1c..069a62cc 100644 --- a/blocks/Dockerfile.patch +++ b/blocks/Dockerfile.patch @@ -1,5 +1,5 @@ ---- Dockerfile 2025-07-04 16:16:28.040919228 +0530 -+++ Dockerfile.1 2025-07-04 16:19:16.930142599 +0530 +--- Dockerfile 2025-07-08 18:20:34.818712259 +0530 ++++ Dockerfile.1 2025-07-08 18:21:40.192702872 +0530 @@ -119,7 +119,7 @@ COPY . . @@ -7,9 +7,9 @@ -RUN ./install.sh +RUN ./install.sh prod - # For localhost only - RUN echo 'WDS_SOCKET_PORT=80' > eda-frontend/.env.local -@@ -173,4 +173,4 @@ + # Cleanup + RUN apt-get autoremove -qq --purge gawk python3-pip python3-venv wget xz-utils +@@ -170,4 +170,4 @@ WORKDIR ${XCOS_DIR} diff --git a/blocks/authAPI/views.py b/blocks/authAPI/views.py index e1cc173b..49dbdac2 100644 --- a/blocks/authAPI/views.py +++ b/blocks/authAPI/views.py @@ -10,7 +10,6 @@ from django.http import HttpResponseNotFound from djoser import utils from djoser.serializers import TokenSerializer from authAPI.serializers import TokenCreateSerializer -from blocks.settings import DOMAIN Token = djoser_settings.TOKEN_MODEL @@ -50,8 +49,7 @@ def get_social_user(email, request, callback, service): user.save() token, created = Token.objects.get_or_create(user=user) - protocol = 'https://' if request.is_secure() else 'http://' - web_url = protocol + DOMAIN + '/#/dashboard' + web_url = settings.POST_ACTIVATE_REDIRECT_URL + '#/dashboard' return render(request, callback, {'token': token, diff --git a/blocks/blocks/settings.py b/blocks/blocks/settings.py index 8f9d6a87..aba1009f 100644 --- a/blocks/blocks/settings.py +++ b/blocks/blocks/settings.py @@ -141,6 +141,7 @@ EMAIL_PORT = int(os.environ.get('EMAIL_PORT', '587')) EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', '') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', '') EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', 'true').lower() == 'true' +DEFAULT_FROM_EMAIL = os.environ.get('FROM_EMAIL', 'webmaster@localhost') if EMAIL_HOST: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' @@ -154,8 +155,6 @@ GITHUB_OAUTH_REDIRECT_URI = os.environ.get('GITHUB_OAUTH_REDIRECT_URI', 'http://localhost/api/auth/github-callback') POST_ACTIVATE_REDIRECT_URL = os.environ.get('POST_ACTIVATE_REDIRECT_URL', 'http://localhost/') -DOMAIN = os.environ.get('EMAIL_DOMAIN', 'localhost') -SITE_NAME = os.environ.get('EMAIL_SITE_NAME', 'Xcos') DJOSER = { 'LOGIN_FIELD': 'email', diff --git a/blocks/eda-frontend/.babelrc.json b/blocks/eda-frontend/.babelrc.json deleted file mode 100644 index 7dd5e9df..00000000 --- a/blocks/eda-frontend/.babelrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@babel/preset-react"] -} diff --git a/blocks/eda-frontend/src/redux/authSlice.js b/blocks/eda-frontend/src/redux/authSlice.js index ee5705c1..bb8e9644 100644 --- a/blocks/eda-frontend/src/redux/authSlice.js +++ b/blocks/eda-frontend/src/redux/authSlice.js @@ -32,7 +32,7 @@ export const loadUser = createAsyncThunk( try { const res = await api.get('auth/users/me/', config) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { return res.data } return rejectWithValue(res.data || 'Failed to load user') @@ -69,7 +69,7 @@ export const login = createAsyncThunk( email, password }) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { localStorage.setItem(tokenKey, res.data.auth_token) if (toUrl === '') { dispatch(loadUser()) @@ -117,7 +117,7 @@ export const signUp = createAsyncThunk( password, re_password: reenterPassword }) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { return 'Successfully Signed Up! A verification link has been sent to your email account.' } @@ -165,7 +165,7 @@ export const googleLogin = createAsyncThunk( async (host, { rejectWithValue }) => { try { const res = await api.get(`auth/o/google-oauth2/?redirect_uri=${host}/api/auth/google-callback`) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { // Open google login page window.open(res.data.authorization_url, '_self') return res.data.authorization_url @@ -185,7 +185,7 @@ export const githubLogin = createAsyncThunk( async (host, { rejectWithValue }) => { try { const res = await api.get(`auth/o/github/?redirect_uri=${host}/api/auth/github-callback`) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { // Open GitHub login page window.open(res.data.authorization_url, '_self') return res.data.authorization_url diff --git a/blocks/init.sh b/blocks/init.sh index ef98711c..16215a00 100755 --- a/blocks/init.sh +++ b/blocks/init.sh @@ -7,8 +7,8 @@ PASSWORD='' rm -f xcosblocks.sqlite3 -./manage.py migrate -v0 -./manage.py loaddata xcosblocks +python manage.py migrate -v0 +python manage.py loaddata -v0 saveAPI xcosblocks echo "from authAPI.models import User; User.objects.create_superuser('$EMAIL', '$EMAIL', '$PASSWORD')" | - ./manage.py shell + python manage.py shell diff --git a/blocks/simulationAPI/helpers/scilab_manager.py b/blocks/simulationAPI/helpers/scilab_manager.py index ce420eee..528cda5d 100644 --- a/blocks/simulationAPI/helpers/scilab_manager.py +++ b/blocks/simulationAPI/helpers/scilab_manager.py @@ -86,8 +86,7 @@ def secure_filename(filename: str) -> str: def makedirs(dirname, dirtype=None): - if not exists(dirname): - os.makedirs(dirname) + os.makedirs(dirname, exist_ok=True) def rmdir(dirname, dirtype=None): |