Fix create trade offer flow and other related bugs
This commit is contained in:
parent
f3a1366269
commit
65ca344582
40 changed files with 867 additions and 278 deletions
|
|
@ -3,8 +3,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
|||
from django.urls import reverse_lazy
|
||||
from django.shortcuts import redirect, get_object_or_404
|
||||
from django.views.generic import ListView, CreateView, DeleteView, View, TemplateView, UpdateView
|
||||
from accounts.models import FriendCode
|
||||
from accounts.forms import FriendCodeForm
|
||||
from accounts.models import FriendCode, CustomUser
|
||||
from accounts.forms import FriendCodeForm, UserSettingsForm
|
||||
from django.db.models import Case, When, Value, BooleanField
|
||||
|
||||
class ListFriendCodesView(LoginRequiredMixin, ListView):
|
||||
|
|
@ -123,11 +123,23 @@ class ChangeDefaultFriendCodeView(LoginRequiredMixin, View):
|
|||
messages.success(request, "Default friend code updated successfully.")
|
||||
return redirect("list_friend_codes")
|
||||
|
||||
class SettingsView(LoginRequiredMixin, TemplateView):
|
||||
# Updated SettingsView to update the new user setting.
|
||||
class SettingsView(LoginRequiredMixin, UpdateView):
|
||||
"""
|
||||
Display the user's settings.
|
||||
Display account navigation links and allow the user to update their friend code
|
||||
visibility setting.
|
||||
"""
|
||||
model = CustomUser
|
||||
form_class = UserSettingsForm
|
||||
template_name = "account/settings.html"
|
||||
success_url = reverse_lazy("settings")
|
||||
|
||||
def get_object(self):
|
||||
return self.request.user
|
||||
|
||||
def form_valid(self, form):
|
||||
messages.success(self.request, "Settings updated successfully.")
|
||||
return super().form_valid(form)
|
||||
|
||||
class ProfileView(LoginRequiredMixin, TemplateView):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue