From a24451d140b041904b71f79a594344d3e4fb3991 Mon Sep 17 00:00:00 2001 From: AdrienLSH Date: Thu, 8 Feb 2024 10:09:36 +0100 Subject: [PATCH] ux: Me becomes Settings; backend: fix special usernames (me, block...) --- frontend/static/css/{me.css => settings.css} | 0 frontend/static/js/api/MyProfile.js | 6 +++--- frontend/static/js/api/client.js | 2 +- frontend/static/js/api/profile.js | 2 +- frontend/static/js/index.js | 4 ++-- frontend/static/js/lang/en.json | 2 +- frontend/static/js/lang/fr.json | 2 +- frontend/static/js/views/HomeView.js | 2 +- frontend/static/js/views/{MeView.js => SettingsView.js} | 4 ++-- frontend/templates/index.html | 2 +- profiles/urls.py | 9 ++++----- 11 files changed, 17 insertions(+), 18 deletions(-) rename frontend/static/css/{me.css => settings.css} (100%) rename frontend/static/js/views/{MeView.js => SettingsView.js} (97%) diff --git a/frontend/static/css/me.css b/frontend/static/css/settings.css similarity index 100% rename from frontend/static/css/me.css rename to frontend/static/css/settings.css diff --git a/frontend/static/js/api/MyProfile.js b/frontend/static/js/api/MyProfile.js index de3f46e..fb4a9fd 100644 --- a/frontend/static/js/api/MyProfile.js +++ b/frontend/static/js/api/MyProfile.js @@ -9,7 +9,7 @@ class MyProfile extends Profile */ constructor (client) { - super(client, "me") + super(client, "../me") } /** @@ -19,7 +19,7 @@ class MyProfile extends Profile */ async change_avatar(form_data) { - let response = await this.client._patch_file(`/api/profiles/me`, form_data); + let response = await this.client._patch_file(`/api/profiles/settings`, form_data); let response_data = await response.json() return response_data; @@ -27,4 +27,4 @@ class MyProfile extends Profile } -export {MyProfile} \ No newline at end of file +export {MyProfile} diff --git a/frontend/static/js/api/client.js b/frontend/static/js/api/client.js index 7e7a183..5df70bf 100644 --- a/frontend/static/js/api/client.js +++ b/frontend/static/js/api/client.js @@ -150,7 +150,7 @@ class Client async _patch_json(uri, data) { let response = await fetch(this._url + uri, { - ethod: "PATCH", + method: "PATCH", headers: { "X-CSRFToken": getCookie("csrftoken"), "Content-Type": "application/json", diff --git a/frontend/static/js/api/profile.js b/frontend/static/js/api/profile.js index 2b57a04..8fcc6bf 100644 --- a/frontend/static/js/api/profile.js +++ b/frontend/static/js/api/profile.js @@ -42,7 +42,7 @@ class Profile { let response; if (this.username !== undefined) - response = await this.client._get(`/api/profiles/${this.username}`); + response = await this.client._get(`/api/profiles/user/${this.username}`); else response = await this.client._get(`/api/profiles/id/${this.id}`); diff --git a/frontend/static/js/index.js b/frontend/static/js/index.js index a3111d2..911920a 100644 --- a/frontend/static/js/index.js +++ b/frontend/static/js/index.js @@ -12,7 +12,7 @@ import GameView from "./views/GameView.js"; import PageNotFoundView from './views/PageNotFoundView.js' import AbstractRedirectView from "./views/abstracts/AbstractRedirectView.js"; -import MeView from "./views/MeView.js"; +import SettingsView from "./views/SettingsView.js"; import ProfilePageView from "./views/ProfilePageView.js"; import MatchMakingView from "./views/MatchMakingView.js"; import TournamentPageView from "./views/tournament/TournamentPageView.js"; @@ -82,7 +82,7 @@ const router = async(uri) => { { path: "/register", view: RegisterView }, { path: "/search", view: Search }, { path: "/home", view: HomeView }, - { path: "/me", view: MeView }, + { path: "/settings", view: SettingsView }, { path: "/matchmaking", view: MatchMakingView }, { path: "/games/offline", view: GameOfflineView }, { path: "/games/:id", view: GameView }, diff --git a/frontend/static/js/lang/en.json b/frontend/static/js/lang/en.json index b6ad271..8bd8b4b 100644 --- a/frontend/static/js/lang/en.json +++ b/frontend/static/js/lang/en.json @@ -10,7 +10,7 @@ "homeTitle": "Home", "homeOnline": "Play online", "homeOffline": "Play offline", - "homeMe": "Me", + "homeSettings": "Settings", "homeLogout": "Logout", "loginWindowTitle": "Login", "loginFormTitle": "Login", diff --git a/frontend/static/js/lang/fr.json b/frontend/static/js/lang/fr.json index be38190..06d2434 100644 --- a/frontend/static/js/lang/fr.json +++ b/frontend/static/js/lang/fr.json @@ -10,7 +10,7 @@ "homeTitle": "Maison", "homeOnline": "Jouer en ligne", "homeOffline": "Jouer hors ligne", - "homeMe": "Moi", + "homeSettings": "Paramètres", "homeLogout": "Déconnexion", "loginWindowTitle": "Connexion", "loginFormTitle": "Connexion", diff --git a/frontend/static/js/views/HomeView.js b/frontend/static/js/views/HomeView.js index 458af60..8ac3ea2 100644 --- a/frontend/static/js/views/HomeView.js +++ b/frontend/static/js/views/HomeView.js @@ -12,7 +12,7 @@ export default class extends AbstractAuthentificateView {

${lang.get('homeTitle', 'Home')}

${lang.get('homeOnline', 'Play online')} ${lang.get('homeOffline', 'Play offline')} - ${lang.get('homeMe', 'Me')} + ${lang.get('homeSettings', 'Settings')} ${lang.get('homeLogout', 'Logout')} `; } diff --git a/frontend/static/js/views/MeView.js b/frontend/static/js/views/SettingsView.js similarity index 97% rename from frontend/static/js/views/MeView.js rename to frontend/static/js/views/SettingsView.js index 4362d3e..d22024c 100644 --- a/frontend/static/js/views/MeView.js +++ b/frontend/static/js/views/SettingsView.js @@ -6,7 +6,7 @@ export default class extends AbstractAuthentificateView { constructor(params) { - super(params, "Me"); + super(params, "Settings"); } async postInit() @@ -95,7 +95,7 @@ export default class extends AbstractAuthentificateView async getHtml() { return /* HTML */ ` - +

ME

diff --git a/frontend/templates/index.html b/frontend/templates/index.html index 585f672..2d62ab7 100644 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -36,7 +36,7 @@ diff --git a/profiles/urls.py b/profiles/urls.py index d0904f6..d2f5bb4 100644 --- a/profiles/urls.py +++ b/profiles/urls.py @@ -1,17 +1,16 @@ from django.urls import path -from django.conf import settings -from django.conf.urls.static import static from . import viewsets from . import views urlpatterns = [ - path("me", viewsets.MyProfileViewSet.as_view({'patch': 'partial_update', 'get': 'retrieve'}), name="my_profile_page"), + path("settings", viewsets.MyProfileViewSet.as_view({'patch': 'partial_update'}), name="my_profile_page"), + path("me", viewsets.MyProfileViewSet.as_view({'get': 'retrieve'}), name="my_profile_page"), path("", viewsets.ProfileViewSet.as_view({'get': 'list'}), name="profiles_list"), path("block", views.BlocksView.as_view(), name="block_page"), path("block/", views.BlockView.as_view(), name="block_page"), path("friend", views.FriendsView.as_view(), name="friend_page"), - path("", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"), + path("user/", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"), path("id/", viewsets.ProfileViewSet.as_view({'get': 'retrieve_id'}), name="profile_page"), -] + static("/staqic/avatars/", document_root="./avatars") +]