1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 07:42:22 +00:00

My account form

This commit is contained in:
Yohann D'ANELLO 2020-05-05 01:04:07 +02:00
parent 3889256fb1
commit 4534a278d7
2 changed files with 21 additions and 3 deletions

View File

@ -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',)

View File

@ -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