Commit 16814bd6 by Őry Máté

school: admin++

parent 876f4b6f
...@@ -7,20 +7,25 @@ import string ...@@ -7,20 +7,25 @@ import string
class GroupInline(contrib.admin.TabularInline): class GroupInline(contrib.admin.TabularInline):
model = models.Group model = models.Group
extra = 2 extra = 3
class CourseAdmin(contrib.admin.ModelAdmin): class CourseAdmin(contrib.admin.ModelAdmin):
model=models.Course model = models.Course
inlines = (GroupInline, ) inlines = (GroupInline, )
filter_horizontal = ('owners', ) filter_horizontal = ('owners', )
list_display = ('code', 'name', 'short_name', 'owner_list')
list_editable = ('name', 'short_name')
class GroupAdmin(contrib.admin.ModelAdmin): class GroupAdmin(contrib.admin.ModelAdmin):
model = models.Group model = models.Group
filter_horizontal = ('owners', 'members', ) filter_horizontal = ('owners', 'members', )
list_display = ('name', 'course', 'semester', 'owner_list', 'member_count') list_display = ('name', 'course', 'semester', 'owner_list', 'member_count')
list_filter = ('semester', 'course')
class SemesterAdmin(contrib.admin.ModelAdmin): class SemesterAdmin(contrib.admin.ModelAdmin):
model=models.Semester model = models.Semester
list_display = ('id', 'name', 'start', 'end')
list_editable = ('name', 'start', 'end')
contrib.admin.site.register(models.Course, CourseAdmin) contrib.admin.site.register(models.Course, CourseAdmin)
contrib.admin.site.register(models.Semester, SemesterAdmin) contrib.admin.site.register(models.Semester, SemesterAdmin)
......
...@@ -48,6 +48,11 @@ class Course(models.Model): ...@@ -48,6 +48,11 @@ class Course(models.Model):
return self.short_name return self.short_name
else: else:
return self.code return self.code
def owner_list(self):
if self.owners:
return ", ".join([u.last_name if u.last_name else u.username for u in self.owners.all()])
else:
return _("n/a")
class Semester(models.Model): class Semester(models.Model):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment