feat: update order payment methods and refine profile edit functionality
All checks were successful
Build and Push Docker Image / build (push) Successful in 43s
All checks were successful
Build and Push Docker Image / build (push) Successful in 43s
- Replaced `Order.PaymentMethod` options with "cash" and "card" while adjusting related code and templates - Set "cash" as the default payment method for orders and checkout forms - Added profile editing functionality with `ProfileForm`, allowing users to update names - Improved feedback messages across profile and order management templates - Updated catalog to handle empty filter results with a "reset filters" option
This commit is contained in:
@@ -77,6 +77,15 @@ class RegisterForm(UserCreationForm):
|
||||
return user
|
||||
|
||||
|
||||
class ProfileForm(forms.ModelForm):
|
||||
first_name = forms.CharField(label="Имя", max_length=150)
|
||||
last_name = forms.CharField(label="Фамилия", max_length=150)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ("first_name", "last_name")
|
||||
|
||||
|
||||
class SantehRayPasswordResetForm(PasswordResetForm):
|
||||
email = forms.EmailField(label="Электронная почта")
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import get_user_model, login as auth_login, logout as auth_logout
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.tokens import default_token_generator
|
||||
@@ -13,7 +14,7 @@ from django.utils.encoding import force_str
|
||||
from django.utils.http import urlsafe_base64_decode
|
||||
from django.views.decorators.http import require_http_methods
|
||||
|
||||
from users.forms import LoginForm, RegisterForm, SantehRayPasswordResetForm, SantehRaySetPasswordForm
|
||||
from users.forms import LoginForm, ProfileForm, RegisterForm, SantehRayPasswordResetForm, SantehRaySetPasswordForm
|
||||
from users.services import send_activation_email
|
||||
|
||||
|
||||
@@ -71,8 +72,15 @@ def activate(request, uidb64, token):
|
||||
|
||||
|
||||
@login_required
|
||||
@require_http_methods(["GET", "POST"])
|
||||
def profile(request):
|
||||
return render(request, "users/profile.html", context={})
|
||||
form = ProfileForm(request.POST or None, instance=request.user)
|
||||
if request.method == "POST" and form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, "Данные профиля обновлены.")
|
||||
return redirect("users:profile")
|
||||
|
||||
return render(request, "users/profile.html", context={"form": form})
|
||||
|
||||
|
||||
class SantehRayPasswordResetView(PasswordResetView):
|
||||
|
||||
Reference in New Issue
Block a user