Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
876f4b6f
authored
Feb 02, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: Group fancier admin
parent
8192a6ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
school/admin.py
+1
-0
school/models.py
+10
-1
No files found.
school/admin.py
View file @
876f4b6f
...
@@ -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
...
...
school/models.py
View file @
876f4b6f
...
@@ -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
(
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment