Add profile page

This commit is contained in:
2025-12-12 10:54:04 +05:30
parent 495dfe7b8e
commit 07dcb72deb
5 changed files with 47 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ header > .home {
font-size: 3em; font-size: 3em;
text-decoration: none; text-decoration: none;
color: #000; color: #000;
margin-left: 20px;
} }
header img { header img {
@@ -31,6 +32,24 @@ main {
padding: 0 30px; 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 { .notes {
width: 100%; width: 100%;
columns: auto 300px; columns: auto 300px;
@@ -58,15 +77,15 @@ main {
margin-bottom: 40px; 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; 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; 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; 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; border-radius: 25px 155px 15px 25px / 115px 25px 225px 150px;
background-color: #fac9dc; background-color: #fac9dc;
} }

View File

@@ -13,7 +13,7 @@
<a href="{% url "post-a-note" %}"> <a href="{% url "post-a-note" %}">
<img src="{% static "notes/images/icons/post-a-note.png" %}" alt="Post a note" title="Post a note" /> <img src="{% static "notes/images/icons/post-a-note.png" %}" alt="Post a note" title="Post a note" />
</a> </a>
<a href="#"> <a href="{% url "profile" %}">
<img src="{% static "notes/images/icons/profile.png" %}" alt="Profile" title="Profile" /> <img src="{% static "notes/images/icons/profile.png" %}" alt="Profile" title="Profile" />
</a> </a>
</header> </header>

View File

@@ -0,0 +1,12 @@
{% extends "notes/base.html" %}
{% block title %}Profile{% endblock %}
{% block body %}
<h1>Profile</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Post!</button>
</form>
{% endblock %}

View File

@@ -7,6 +7,7 @@ from notes import views, api_views
urlpatterns = [ urlpatterns = [
path("", views.HomePage.as_view(), name="home"), path("", views.HomePage.as_view(), name="home"),
path("post-a-note/", views.PostNoteView.as_view(), name="post-a-note"), 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("login/", LoginView.as_view(), name='login'),
path("api/notes/", api_views.NoteListView.as_view(), name="api-notes-list"), path("api/notes/", api_views.NoteListView.as_view(), name="api-notes-list"),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")), path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),

View File

@@ -3,9 +3,9 @@ from typing import Any
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils import timezone 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 django.views.generic.edit import FormMixin
from notes.models import Note from notes.models import Note, User
# Create your views here. # Create your views here.
class HomePage(LoginRequiredMixin, TemplateView): class HomePage(LoginRequiredMixin, TemplateView):
@@ -33,3 +33,12 @@ class PostNoteView(LoginRequiredMixin, CreateView):
note.from_user = self.request.user note.from_user = self.request.user
note.save() note.save()
return FormMixin.form_valid(self, form) 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