Première version en Python-Django.
[auf_paf.git] / paf / admin.py
old mode 100644 (file)
new mode 100755 (executable)
index 5d4cab3..347db0f
@@ -50,19 +50,19 @@ class EmploymentInline(admin.StackedInline):
             return ('entreprise', 'activity_sector', 'country', 'website', 'position', 'detail_position', 'observation')
         return ()
 
-class StudentForm(forms.ModelForm):
-    class Meta:
-        model = Student
-        widgets = {
-            'identifier': forms.TextInput(attrs={'readonly':'readonly'}),
-        }
+#class StudentForm(forms.ModelForm):
+#    class Meta:
+#        model = Student
+#        widgets = {
+#            'identifier': forms.TextInput(attrs={'readonly':'readonly'}),
+#        }
 
 
 class StudentAdmin(admin.ModelAdmin):
-    form = StudentForm
+#    form = StudentForm
     list_display = ('firstname', 'lastname', 'tel', 'email')
     search_fields = ('firstname', 'lastname')
-    list_filter = ('sex', 'linguisticlevel__delf_dalf', 'currentacademic__university__name',)
+    list_filter = ('sex', 'linguisticlevel__delf_dalf', 'currentacademic__university',)
     date_hierarchy = 'dob'
     ordering = ('-lastname',)
     inlines = [CurrentAcademicInline, LinguisticLevelInline, DiplomaObtainedInline, EmploymentInline]
@@ -73,7 +73,7 @@ class StudentAdmin(admin.ModelAdmin):
     def get_readonly_fields(self, request, obj=None):
         if request.user.username == 'enseignant':
             return ('identifier', 'firstname', 'lastname', 'nationality', 'sex', 'dob', 'email', 'tel', 'parent_tel', 'parent_address')
-        return ()
+        return ('identifier',)
     
     def queryset(self, request):
         qs = super(StudentAdmin, self).queryset(request)
@@ -86,11 +86,6 @@ class StudentAdmin(admin.ModelAdmin):
         if request.user.first_name == 'student':
             self.change_form_template = 'edit_info.html'
         elif request.user.username == 'enseignant':
-            #self.readonly_fields = list(self.fields)
-            #for inline in self.get_inline_instances(request):
-            #    inline.readonly_fields = list(inline.fields)
-            #self.readonly_fields = ('identifier', 'firstname', 'lastname', 'nationality', 'sex', 'dob', 'email', 'tel', 'parent_tel', 'parent_address')
-
             self.change_form_template = 'student_info.html'
         else:
             self.change_form_template = None
@@ -143,4 +138,4 @@ admin.site.register(University, UniversityAdmin)
 admin.site.register(Faculty, FacultyAdmin)
 admin.site.register(Level, LevelAdmin)
 admin.site.register(DiplomaObtained, DiplomaObtainedAdmin)
-admin.site.register(CurrentAcademic, CurrentAcademicAdmin)
\ No newline at end of file
+admin.site.register(CurrentAcademic, CurrentAcademicAdmin)