remove trailing whitespace and add docstrings

This commit is contained in:
Pierre-antoine Comby 2019-09-23 12:54:08 +02:00
parent 075995ce73
commit e2d32b11e2
1 changed files with 12 additions and 8 deletions

View File

@ -27,8 +27,8 @@ from note.tables import HistoryTable
class UserCreateView(CreateView): class UserCreateView(CreateView):
""" """
Une vue pour inscrire un utilisateur et lui créer un profile Une vue pour inscrire un utilisateur et lui créer un profile
""" """
form_class = ProfileForm form_class = ProfileForm
success_url = reverse_lazy('login') success_url = reverse_lazy('login')
template_name ='member/signup.html' template_name ='member/signup.html'
@ -49,14 +49,15 @@ class UserCreateView(CreateView):
user_profile.save() user_profile.save()
return super().form_valid(form) return super().form_valid(form)
class UserDetailView(LoginRequiredMixin,DetailView): class UserDetailView(LoginRequiredMixin,DetailView):
"""
Affiche les informations sur un utilisateur, sa note, ses clubs ...
"""
model = Profile model = Profile
context_object_name = "profile" context_object_name = "profile"
def get_context_data(slef,**kwargs): def get_context_data(slef,**kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
user = context['profile'].user user = context['profile'].user
history_list = \ history_list = \
Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note)) Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note))
context['history_list'] = HistoryTable(history_list) context['history_list'] = HistoryTable(history_list)
@ -66,12 +67,15 @@ class UserDetailView(LoginRequiredMixin,DetailView):
return context return context
class UserListView(LoginRequiredMixin,SingleTableView): class UserListView(LoginRequiredMixin,SingleTableView):
"""
Affiche la liste des utilisateurs, avec une fonction de recherche statique
"""
model = User model = User
table_class = UserTable table_class = UserTable
template_name = 'member/user_list.html' template_name = 'member/user_list.html'
filter_class = UserFilter filter_class = UserFilter
formhelper_class = UserFilterFormHelper formhelper_class = UserFilterFormHelper
def get_queryset(self,**kwargs): def get_queryset(self,**kwargs):
qs = super().get_queryset() qs = super().get_queryset()
self.filter = self.filter_class(self.request.GET,queryset=qs) self.filter = self.filter_class(self.request.GET,queryset=qs)
@ -97,10 +101,10 @@ class ClubCreateView(LoginRequiredMixin,CreateView):
def form_valid(self,form): def form_valid(self,form):
return super().form_valid(form) return super().form_valid(form)
class ClubListView(LoginRequiredMixin,SingleTableView): class ClubListView(LoginRequiredMixin,SingleTableView):
""" """
List existing tables List existing Clubs
""" """
model = Club model = Club
table_class = ClubTable table_class = ClubTable
@ -120,7 +124,7 @@ class ClubDetailView(LoginRequiredMixin,DetailView):
# TODO: consider only valid Membership # TODO: consider only valid Membership
context['member_list'] = club_member context['member_list'] = club_member
return context return context
class ClubAddMemberView(LoginRequiredMixin,CreateView): class ClubAddMemberView(LoginRequiredMixin,CreateView):
model = Membership model = Membership
form_class = MembershipForm form_class = MembershipForm
@ -130,7 +134,7 @@ class ClubAddMemberView(LoginRequiredMixin,CreateView):
context['formset'] = MemberFormSet() context['formset'] = MemberFormSet()
context['helper'] = FormSetHelper() context['helper'] = FormSetHelper()
return context return context
def post(self,request,*args,**kwargs): def post(self,request,*args,**kwargs):
formset = MembershipFormset(request.POST) formset = MembershipFormset(request.POST)
if formset.is_valid(): if formset.is_valid():