@ -103,14 +103,14 @@ class CreateSchool(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
return response
return response
class EditSchool ( LoginRequiredMixin , PermissionRequiredMixin , UpdateView ) :
class EditSchoolName ( LoginRequiredMixin , PermissionRequiredMixin , UpdateView ) :
model = Group
model = Group
fields = [ ' name ' ]
fields = [ ' name ' ]
template_name = ' edit.html '
template_name = ' edit.html '
queryset = Group . objects . filter ( school__isnull = False )
queryset = Group . objects . filter ( school__isnull = False )
def get_success_url ( self ) :
def get_success_url ( self ) :
return reverse ( ' users:school ' , kwargs = { ' pk ' : self . object . pk } )
return reverse ( ' users:edit- school-phone ' , kwargs = { ' pk ' : self . object . school . pk } )
def get_context_data ( self , * * kwargs ) :
def get_context_data ( self , * * kwargs ) :
context = super ( ) . get_context_data ( * * kwargs )
context = super ( ) . get_context_data ( * * kwargs )
@ -127,14 +127,34 @@ class EditSchool(LoginRequiredMixin, PermissionRequiredMixin, UpdateView):
return r
return r
class EditSchoolPhone ( LoginRequiredMixin , PermissionRequiredMixin , UpdateView ) :
model = SchoolProfile
fields = [ ' phone ' ]
template_name = ' edit.html '
def get_success_url ( self ) :
return reverse ( ' users:school ' , kwargs = { ' pk ' : self . object . group . pk } )
def get_context_data ( self , * * kwargs ) :
context = super ( ) . get_context_data ( * * kwargs )
context [ ' title ' ] = " Édition de l ' école "
context [ ' validate ' ] = " Modifier "
return context
def has_permission ( self ) :
return self . request . user . has_perm ( ' users.manage_ ' + str ( self . kwargs [ ' pk ' ] ) )
class DeleteSchool ( LoginRequiredMixin , PermissionRequiredMixin , DeleteView ) :
class DeleteSchool ( LoginRequiredMixin , PermissionRequiredMixin , DeleteView ) :
model = Group
model = Group
permission_required = ' users.delete_schoolprofile '
permission_required = ' users.delete_schoolprofile '
queryset = Group . objects . filter ( school__isnull = False )
class School ( LoginRequiredMixin , PermissionRequiredMixin , DetailView ) :
class School ( LoginRequiredMixin , PermissionRequiredMixin , DetailView ) :
model = Group
model = Group
template_name = " users/school.html "
template_name = " users/school.html "
queryset = Group . objects . filter ( school__isnull = False )
def get_context_data ( self , * * kwargs ) :
def get_context_data ( self , * * kwargs ) :
context = super ( ) . get_context_data ( )
context = super ( ) . get_context_data ( )