diff --git a/accounts/views/delete.py b/accounts/views/delete.py index a039dc7..0a3265c 100644 --- a/accounts/views/delete.py +++ b/accounts/views/delete.py @@ -7,6 +7,6 @@ from rest_framework.authentication import SessionAuthentication class DeleteView(APIView): permission_classes = (permissions.IsAuthenticated,) authentication_classes = (SessionAuthentication,) - def post(self, request: HttpRequest): + def delete(self, request: HttpRequest): request.user.delete() return Response("user deleted", status=status.HTTP_200_OK) \ No newline at end of file diff --git a/frontend/static/js/index.js b/frontend/static/js/index.js index 3011676..47255df 100644 --- a/frontend/static/js/index.js +++ b/frontend/static/js/index.js @@ -75,6 +75,7 @@ const router = async (uri = "") => { if (content == null) return 1; + view.setTitle(); document.querySelector("#app").innerHTML = content await view.postInit(); diff --git a/frontend/static/js/views/AbstractAuthentifiedView.js b/frontend/static/js/views/AbstractAuthentifiedView.js index 705630f..191dcb5 100644 --- a/frontend/static/js/views/AbstractAuthentifiedView.js +++ b/frontend/static/js/views/AbstractAuthentifiedView.js @@ -2,8 +2,8 @@ import { client, navigateTo } from "../index.js"; import AbstractRedirectView from "./AbstractRedirectView.js"; export default class extends AbstractRedirectView{ - constructor(params) { - super(params, "/login"); + constructor(params, title) { + super(params, title, "/login"); } async redirect() diff --git a/frontend/static/js/views/AbstractNonAuthentified.js b/frontend/static/js/views/AbstractNonAuthentified.js index c8b4eb2..8c6190c 100644 --- a/frontend/static/js/views/AbstractNonAuthentified.js +++ b/frontend/static/js/views/AbstractNonAuthentified.js @@ -2,8 +2,8 @@ import { client, navigateTo } from "../index.js"; import AbstractRedirectView from "./AbstractRedirectView.js"; export default class extends AbstractRedirectView{ - constructor(params, url) { - super(params, url); + constructor(params, title, url) { + super(params, title, url); } async redirect() diff --git a/frontend/static/js/views/AbstractRedirectView.js b/frontend/static/js/views/AbstractRedirectView.js index 7f139cd..6144270 100644 --- a/frontend/static/js/views/AbstractRedirectView.js +++ b/frontend/static/js/views/AbstractRedirectView.js @@ -2,9 +2,9 @@ import { navigateTo } from "../index.js"; import AbstractView from "./AbstractView.js"; export default class extends AbstractView{ - constructor(params, url) + constructor(params, title, url) { - super(params); + super(params, title); this.redirect_url = url; } diff --git a/frontend/static/js/views/AbstractView.js b/frontend/static/js/views/AbstractView.js index f1a14f2..a488d80 100644 --- a/frontend/static/js/views/AbstractView.js +++ b/frontend/static/js/views/AbstractView.js @@ -1,6 +1,7 @@ export default class { - constructor(params) { + constructor(params, title) { this.params = params; + this.title = title; } async postInit() { @@ -9,8 +10,8 @@ export default class { async leavePage() { } - setTitle(title) { - document.title = title; + setTitle() { + document.title = this.title; } async getHtml() { diff --git a/frontend/static/js/views/Chat.js b/frontend/static/js/views/Chat.js index 9352c17..de4b02b 100644 --- a/frontend/static/js/views/Chat.js +++ b/frontend/static/js/views/Chat.js @@ -1,9 +1,8 @@ -import AbstractView from "./AbstractView.js"; +import AbstractAuthentifiedView from "./AbstractAuthentifiedView.js"; -export default class extends AbstractView { +export default class extends AbstractAuthentifiedView { constructor(params) { - super(params); - this.setTitle("Chat"); + super(params, "Chat"); let url = `wss://${window.location.host}/ws/socket-server/` diff --git a/frontend/static/js/views/Dashboard.js b/frontend/static/js/views/Dashboard.js index e2f4409..698f945 100644 --- a/frontend/static/js/views/Dashboard.js +++ b/frontend/static/js/views/Dashboard.js @@ -2,8 +2,7 @@ import AbstractView from "./AbstractView.js"; export default class extends AbstractView { constructor(params) { - super(params); - this.setTitle("Dashboard"); + super(params, "Dashboard"); } async getHtml() { diff --git a/frontend/static/js/views/HomeView.js b/frontend/static/js/views/HomeView.js index 4d44ecb..5f9f3fb 100644 --- a/frontend/static/js/views/HomeView.js +++ b/frontend/static/js/views/HomeView.js @@ -2,8 +2,7 @@ import AbstractAuthentificateView from "./AbstractAuthentifiedView.js"; export default class extends AbstractAuthentificateView { constructor(params) { - super(params); - this.setTitle("Home"); + super(params, "Home"); this.redirect_url = "/login" } diff --git a/frontend/static/js/views/PostView.js b/frontend/static/js/views/PostView.js index 24e2785..d5f01bf 100644 --- a/frontend/static/js/views/PostView.js +++ b/frontend/static/js/views/PostView.js @@ -2,9 +2,8 @@ import AbstractView from "./AbstractView.js"; export default class extends AbstractView { constructor(params) { - super(params); + super(params, "Viewing Post"); this.postId = params.id; - this.setTitle("Viewing Post"); } async getHtml() { diff --git a/frontend/static/js/views/Posts.js b/frontend/static/js/views/Posts.js index 06ff6c9..f000557 100644 --- a/frontend/static/js/views/Posts.js +++ b/frontend/static/js/views/Posts.js @@ -2,8 +2,7 @@ import AbstractView from "./AbstractView.js"; export default class extends AbstractView { constructor(params) { - super(params); - this.setTitle("Posts"); + super(params, "Posts"); } async getHtml() { diff --git a/frontend/static/js/views/Settings.js b/frontend/static/js/views/Settings.js index a54cf89..1c9f85f 100644 --- a/frontend/static/js/views/Settings.js +++ b/frontend/static/js/views/Settings.js @@ -2,8 +2,7 @@ import AbstractView from "./AbstractView.js"; export default class extends AbstractView { constructor(params) { - super(params); - this.setTitle("Settings"); + super(params, "Settings"); } async getHtml() { diff --git a/frontend/static/js/views/accounts/LoginView.js b/frontend/static/js/views/accounts/LoginView.js index f8c64dd..907035d 100644 --- a/frontend/static/js/views/accounts/LoginView.js +++ b/frontend/static/js/views/accounts/LoginView.js @@ -29,12 +29,11 @@ async function login() export default class extends AbstractNonAuthentifiedView { constructor(params) { - super(params, "/home"); + super(params, "Login", "/home"); } async postInit() { - this.setTitle("Login"); document.getElementById("button").onclick = login; } diff --git a/frontend/static/js/views/accounts/LogoutView.js b/frontend/static/js/views/accounts/LogoutView.js index 3e0b7d6..3713d18 100644 --- a/frontend/static/js/views/accounts/LogoutView.js +++ b/frontend/static/js/views/accounts/LogoutView.js @@ -4,8 +4,7 @@ import AbstractAuthentifiedView from "../AbstractAuthentifiedView.js"; export default class extends AbstractAuthentifiedView { constructor(params) { - super(params); - this.setTitle("Logout"); + super(params, "Logout"); client.logout(); navigateTo("/login") } diff --git a/frontend/static/js/views/accounts/RegisterView.js b/frontend/static/js/views/accounts/RegisterView.js index e8c220d..5873b4c 100644 --- a/frontend/static/js/views/accounts/RegisterView.js +++ b/frontend/static/js/views/accounts/RegisterView.js @@ -24,12 +24,11 @@ async function register() export default class extends AbstractAuthentifiedView { constructor(params) { - super(params, "/home"); + super(params, "Register", "/home"); } async postInit() { - this.setTitle("register"); document.getElementById("button").onclick = register; }