Commit 876f4b6f by Őry Máté

school: Group fancier admin

parent 8192a6ae
...@@ -17,6 +17,7 @@ class CourseAdmin(contrib.admin.ModelAdmin): ...@@ -17,6 +17,7 @@ class CourseAdmin(contrib.admin.ModelAdmin):
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')
class SemesterAdmin(contrib.admin.ModelAdmin): class SemesterAdmin(contrib.admin.ModelAdmin):
model=models.Semester model=models.Semester
......
...@@ -82,8 +82,17 @@ class Group(models.Model): ...@@ -82,8 +82,17 @@ class Group(models.Model):
class Meta: class Meta:
unique_together = (('name', 'course', 'semester', ), ) unique_together = (('name', 'course', 'semester', ), )
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")
def member_count(self):
return self.members.count()
def __unicode__(self): def __unicode__(self):
if self.course: if self.course:
return "%s (%s)" % (self.name, self.course.short()) return "%s (%s)" % (self.name, self.course.short())
else: else:
return "%s (%s)" % (self.name, ", ".join([u.last_name for u in self.owners.all()])) return "%s (%s)" % (self.name, self.owner_list())
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