My account form
This commit is contained in:
parent
3889256fb1
commit
4534a278d7
|
@ -42,4 +42,19 @@ class SignUpForm(UserCreationForm):
|
|||
class TFJMUserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TFJMUser
|
||||
fields = '__all__'
|
||||
fields = ('last_name', 'first_name', 'email', 'phone_number', 'gender', 'birth_date', 'address', 'postal_code',
|
||||
'city', 'country', 'school', 'student_class', 'responsible_name', 'responsible_phone',
|
||||
'responsible_email',)
|
||||
|
||||
|
||||
class CoachUserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TFJMUser
|
||||
fields = ('last_name', 'first_name', 'email', 'phone_number', 'gender', 'birth_date', 'address', 'postal_code',
|
||||
'city', 'country', 'description',)
|
||||
|
||||
|
||||
class AdminUserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TFJMUser
|
||||
fields = ('last_name', 'first_name', 'email', 'phone_number', 'description',)
|
||||
|
|
|
@ -15,7 +15,7 @@ from django_tables2 import SingleTableView
|
|||
from tournament.forms import TeamForm, JoinTeam
|
||||
from tournament.models import Team
|
||||
from tournament.views import AdminMixin, TeamMixin
|
||||
from .forms import SignUpForm, TFJMUserForm
|
||||
from .forms import SignUpForm, TFJMUserForm, AdminUserForm, CoachUserForm
|
||||
from .models import TFJMUser, Document, Solution, MotivationLetter, Synthesis
|
||||
from .tables import UserTable
|
||||
|
||||
|
@ -28,9 +28,12 @@ class CreateUserView(CreateView):
|
|||
|
||||
class MyAccountView(LoginRequiredMixin, UpdateView):
|
||||
model = TFJMUser
|
||||
form_class = TFJMUserForm
|
||||
template_name = "member/my_account.html"
|
||||
|
||||
def get_form_class(self):
|
||||
return AdminUserForm if self.request.user.organizes else TFJMUserForm \
|
||||
if self.request.user.role == "3participant" else CoachUserForm
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
return self.request.user
|
||||
|
||||
|
|
Loading…
Reference in New Issue