From 960f61569606cbea2179afde5985579426943a9b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Feb 2024 00:25:14 +0200 Subject: [PATCH] update for try make crud for user in profile page --- accounts/forms.py | 8 +++++++- accounts/templates/registration/profile.html | 10 +++++----- accounts/urls.py | 4 +++- accounts/views.py | 20 ++++++++++++++++--- product/templates/product/product_list.html | 2 +- static/en/images/payment/png/icon-pay-01.png | Bin 0 -> 2290 bytes static/en/images/payment/png/icon-pay-02.png | Bin 0 -> 2513 bytes static/en/images/payment/png/icon-pay-03.png | Bin 0 -> 2812 bytes 8 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 static/en/images/payment/png/icon-pay-01.png create mode 100644 static/en/images/payment/png/icon-pay-02.png create mode 100644 static/en/images/payment/png/icon-pay-03.png diff --git a/accounts/forms.py b/accounts/forms.py index 2a9b329..91a4e84 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -1,5 +1,6 @@ from django import forms from django.contrib.auth.models import User +from .models import Profile from django.contrib.auth.forms import UserCreationForm @@ -22,4 +23,9 @@ class Meta: class ActivationForm(forms.Form): code = forms.CharField(max_length=8) - \ No newline at end of file + + +class UpdateUserForm(forms.ModelForm): + class Meta: + model = Profile + fields = '__all__' \ No newline at end of file diff --git a/accounts/templates/registration/profile.html b/accounts/templates/registration/profile.html index 3b61891..38b92f1 100644 --- a/accounts/templates/registration/profile.html +++ b/accounts/templates/registration/profile.html @@ -56,7 +56,7 @@

Your Profile

@@ -122,7 +122,7 @@

payment option

- payment + payment

card number

**** @@ -136,7 +136,7 @@

miron mahmud
- payment + payment

card number

**** @@ -150,7 +150,7 @@

miron mahmud
- payment + payment

card number

**** @@ -275,7 +275,7 @@

edit profile info

- +
diff --git a/accounts/urls.py b/accounts/urls.py index 9fde60b..7e68ae4 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from .views import signup, activate, dashboard, profile +from .views import signup, activate, dashboard, profile, EditProfile app_name = 'accounts' @@ -8,6 +8,8 @@ path('/activate', activate), path('profile', profile, name='profile_user'), path('dashboard', dashboard), + path('edit-profile/', EditProfile.as_view(), name='edit_profile'), + ] diff --git a/accounts/views.py b/accounts/views.py index b87757a..baa79c0 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,13 +1,15 @@ from django.shortcuts import render, redirect from django.core.mail import send_mail from django.contrib.auth.decorators import login_required -from .forms import SignupForm, ActivationForm +from .forms import SignupForm, ActivationForm, UpdateUserForm from django.contrib.auth.models import User from .models import Profile from product.models import Product, Brand, Review from orders.models import Order from django.conf import settings - +from django.views.generic import UpdateView +from django.urls import reverse_lazy +from django.contrib.auth.mixins import LoginRequiredMixin @@ -90,4 +92,16 @@ def dashboard(request): 'new_products':new_products, 'sale_products':sale_products, 'feature_products':feature_products, - }) \ No newline at end of file + }) + + + + +class EditProfile(LoginRequiredMixin, UpdateView): + model = User + form_class = UpdateUserForm + template_name = 'registration/profile.html' # Replace with your actual template name + success_url = reverse_lazy('profile') # Replace 'profile' with the name of your profile URL + + def get_object(self, queryset=None): + return self.request.user \ No newline at end of file diff --git a/product/templates/product/product_list.html b/product/templates/product/product_list.html index 807935b..b96b9ee 100644 --- a/product/templates/product/product_list.html +++ b/product/templates/product/product_list.html @@ -396,7 +396,7 @@
{% comment %} $34 {% endcomment %} - ${{object.id}}/piece + ${{object.price}}/piece