ux: Me becomes Settings; backend: fix special usernames (me, block...)

This commit is contained in:
AdrienLSH 2024-02-08 10:09:36 +01:00
parent 1dea678a04
commit 55d3ea40f6
11 changed files with 17 additions and 18 deletions

View File

@ -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}
export {MyProfile}

View File

@ -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",

View File

@ -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}`);

View File

@ -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 },

View File

@ -10,7 +10,7 @@
"homeTitle": "Home",
"homeOnline": "Play online",
"homeOffline": "Play offline",
"homeMe": "Me",
"homeSettings": "Settings",
"homeLogout": "Logout",
"loginWindowTitle": "Login",
"loginFormTitle": "Login",

View File

@ -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",

View File

@ -12,7 +12,7 @@ export default class extends AbstractAuthentificateView {
<h1>${lang.get('homeTitle', 'Home')}</h1>
<a href="/matchmaking" data-link>${lang.get('homeOnline', 'Play online')}</a>
<a href="/games/offline" data-link>${lang.get('homeOffline', 'Play offline')}</a>
<a href="/me" data-link>${lang.get('homeMe', 'Me')}</a>
<a href="/settings" data-link>${lang.get('homeSettings', 'Settings')}</a>
<a href="/logout" data-link>${lang.get('homeLogout', 'Logout')}</a>
`;
}

View File

@ -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 */ `
<link rel="stylesheet" href="/static/css/me.css">
<link rel="stylesheet" href="/static/css/settings.css">
<h1>ME</h1>
<div id="main">
<div class="avatar">

View File

@ -36,7 +36,7 @@
</a>
<div class='dropdown-menu dropdown-menu-end position-absolute text-end px-2' style='min-width: 100px'>
<a data-i18n='navbarProfile' id='myProfileLink' href='' class="dropdow-item nav-link pt-1" data-link>My Profile</a>
<a data-i18n='navbarSettings' href="/me" class="dropdow-item nav-link pt-0" data-link>Settings</a>
<a data-i18n='navbarSettings' href="/settings" class="dropdow-item nav-link pt-0" data-link>Settings</a>
<hr class='dropdown-separator my-auto mx-1'></hr>
<a data-i18n='navbarLogout' href="/logout" class="dropdow-item nav-link pb-1" data-link>Logout</a>
</div>

View File

@ -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/<int:pk>", views.BlockView.as_view(), name="block_page"),
path("friend", views.FriendsView.as_view(), name="friend_page"),
path("<str:username>", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"),
path("user/<str:username>", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"),
path("id/<int:pk>", viewsets.ProfileViewSet.as_view({'get': 'retrieve_id'}), name="profile_page"),
] + static("/staqic/avatars/", document_root="./avatars")
]