From 07dcb72debbd2ef9c88503503bf3e748ea339049 Mon Sep 17 00:00:00 2001 From: Irene Sheen Date: Fri, 12 Dec 2025 10:54:04 +0530 Subject: [PATCH] Add profile page --- notes/static/notes/stylesheets/style.css | 26 ++++++++++++++++++++---- notes/templates/notes/base.html | 2 +- notes/templates/notes/user_form.html | 12 +++++++++++ notes/urls.py | 1 + notes/views.py | 13 ++++++++++-- 5 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 notes/templates/notes/user_form.html diff --git a/notes/static/notes/stylesheets/style.css b/notes/static/notes/stylesheets/style.css index 6d18786..cd2a9f7 100644 --- a/notes/static/notes/stylesheets/style.css +++ b/notes/static/notes/stylesheets/style.css @@ -20,6 +20,7 @@ header > .home { font-size: 3em; text-decoration: none; color: #000; + margin-left: 20px; } header img { @@ -31,6 +32,24 @@ main { padding: 0 30px; } +input, select, textarea { + padding: 5px; + min-width: 200px; + display: block; + box-shadow: 15px 28px 25px -18px rgba(0, 0, 0, 0.1); + margin: 10px 0; +} + +textarea { + resize: vertical; + padding: 20px; +} + +button { + padding: 10px; + min-width: 100px; +} + .notes { width: 100%; columns: auto 300px; @@ -58,15 +77,15 @@ main { margin-bottom: 40px; } -.note:nth-child(3n) { +select:nth-child(3n), textarea:nth-child(3n), input:nth-child(3n), .note:nth-child(3n) { border-radius: 155px 25px 15px 25px / 15px 225px 230px 150px; } -.note:nth-child(3n + 1) { +select:nth-child(3n + 1), textarea:nth-child(3n + 1), input:nth-child(3n + 1), .note:nth-child(3n + 1) { border-radius: 25px 155px 15px 25px / 115px 25px 225px 150px; } -.note:nth-child(3n + 2) { +select:nth-child(3n + 2), textarea:nth-child(3n + 2), input:nth-child(3n + 2), .note:nth-child(3n + 2) { border-radius: 25px 150px 25px 155px / 115px 25px 225px 50px; } @@ -104,4 +123,3 @@ main { border-radius: 25px 155px 15px 25px / 115px 25px 225px 150px; background-color: #fac9dc; } - diff --git a/notes/templates/notes/base.html b/notes/templates/notes/base.html index 405ff0d..c657d83 100644 --- a/notes/templates/notes/base.html +++ b/notes/templates/notes/base.html @@ -13,7 +13,7 @@ Post a note - + Profile diff --git a/notes/templates/notes/user_form.html b/notes/templates/notes/user_form.html new file mode 100644 index 0000000..5c84dc9 --- /dev/null +++ b/notes/templates/notes/user_form.html @@ -0,0 +1,12 @@ +{% extends "notes/base.html" %} + +{% block title %}Profile{% endblock %} + +{% block body %} +

Profile

+
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/notes/urls.py b/notes/urls.py index eeafaf8..b0995cb 100644 --- a/notes/urls.py +++ b/notes/urls.py @@ -7,6 +7,7 @@ from notes import views, api_views urlpatterns = [ path("", views.HomePage.as_view(), name="home"), path("post-a-note/", views.PostNoteView.as_view(), name="post-a-note"), + path("profile/", views.ProfileView.as_view(), name="profile"), path("login/", LoginView.as_view(), name='login'), path("api/notes/", api_views.NoteListView.as_view(), name="api-notes-list"), path("api-auth/", include("rest_framework.urls", namespace="rest_framework")), diff --git a/notes/views.py b/notes/views.py index 5b6620f..e74fe68 100644 --- a/notes/views.py +++ b/notes/views.py @@ -3,9 +3,9 @@ from typing import Any from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse_lazy from django.utils import timezone -from django.views.generic import CreateView, TemplateView +from django.views.generic import CreateView, TemplateView, UpdateView from django.views.generic.edit import FormMixin -from notes.models import Note +from notes.models import Note, User # Create your views here. class HomePage(LoginRequiredMixin, TemplateView): @@ -33,3 +33,12 @@ class PostNoteView(LoginRequiredMixin, CreateView): note.from_user = self.request.user note.save() return FormMixin.form_valid(self, form) + + +class ProfileView(LoginRequiredMixin, UpdateView): + model = User + fields = ["first_name", "last_name", "allow_notes_from", "expiry_seconds"] + success_url = reverse_lazy("profile") + + def get_object(self): + return self.request.user