Skip to content

Commit

Permalink
update for try make crud for user in profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed00Abdelmonem committed Feb 1, 2024
1 parent 24e88bf commit 960f615
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
8 changes: 7 additions & 1 deletion accounts/forms.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -22,4 +23,9 @@ class Meta:

class ActivationForm(forms.Form):
code = forms.CharField(max_length=8)



class UpdateUserForm(forms.ModelForm):
class Meta:
model = Profile
fields = '__all__'
10 changes: 5 additions & 5 deletions accounts/templates/registration/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h4>Your Profile</h4>
</div>
<div class="col-lg-2">
<div class="profile-btn">
<a href="change-password.html">change pass.</a>
<a href="password_change" style="background-color: var(--primary, #00ff00); color: #ffffff; padding: 10px 15px; border-radius: 5px; text-decoration: none; display: inline-block;">change pass.</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -122,7 +122,7 @@ <h4>payment option</h4>
<div class="row">
<div class="col-md-6 col-lg-4 alert fade show">
<div class="payment-card payment active">
<img src="{% static 'en/images/payment/png/01.png' %}" alt="payment">
<img src="{% static 'en/images/payment/png/icon-pay-01.png' %}" alt="payment">
<h4>card number</h4>
<p>
<span>****</span>
Expand All @@ -136,7 +136,7 @@ <h5>miron mahmud</h5>
</div>
<div class="col-md-6 col-lg-4 alert fade show">
<div class="payment-card payment">
<img src="images/payment/png/02.png" alt="payment">
<img src="{% static 'en/images/payment/png/icon-pay-02.png' %}" alt="payment">
<h4>card number</h4>
<p>
<span>****</span>
Expand All @@ -150,7 +150,7 @@ <h5>miron mahmud</h5>
</div>
<div class="col-md-6 col-lg-4 alert fade show">
<div class="payment-card payment">
<img src="images/payment/png/03.png" alt="payment">
<img src="{% static 'en/images/payment/png/icon-pay-03.png' %}" alt="payment">
<h4>card number</h4>
<p>
<span>****</span>
Expand Down Expand Up @@ -275,7 +275,7 @@ <h3>edit profile info</h3>
</div>
<div class="form-group">
<label class="form-label">name</label>
<input class="form-control" type="text" value="Miron Mahmud">
<input class="form-control" type="text" value="{{user.username}}">
</div>
<div class="form-group">
<label class="form-label">email</label>
Expand Down
4 changes: 3 additions & 1 deletion accounts/urls.py
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -8,6 +8,8 @@
path('<str:username>/activate', activate),
path('profile', profile, name='profile_user'),
path('dashboard', dashboard),
path('edit-profile/', EditProfile.as_view(), name='edit_profile'),

]


20 changes: 17 additions & 3 deletions accounts/views.py
Original file line number Diff line number Diff line change
@@ -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



Expand Down Expand Up @@ -90,4 +92,16 @@ def dashboard(request):
'new_products':new_products,
'sale_products':sale_products,
'feature_products':feature_products,
})
})




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
2 changes: 1 addition & 1 deletion product/templates/product/product_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ <h6 class="product-name">
</h6>
<h6 class="product-price">
{% comment %} <del>$34</del> {% endcomment %}
<span>${{object.id}}<small>/piece</small></span>
<span>${{object.price}}<small>/piece</small></span>
</h6>
<button class="product-add" title="Add to Cart">
<i class="fas fa-shopping-basket"></i>
Expand Down
Binary file added static/en/images/payment/png/icon-pay-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/en/images/payment/png/icon-pay-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/en/images/payment/png/icon-pay-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 960f615

Please sign in to comment.