Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
5360100a
Unverified
Commit
5360100a
authored
Jan 19, 2017
by
Joost Rijneveld
Browse files
Make sure models are ordered in admin dropdowns
parent
d18859db
Changes
11
Hide whitespace changes
Inline
Side-by-side
website/activemembers/migrations/0016_auto_20170120_0837.py
0 → 100644
View file @
5360100a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-20 07:37
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'activemembers'
,
'0015_datamigration_lifelong'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'committee'
,
options
=
{
'ordering'
:
(
'name_nl'
,),
'verbose_name'
:
'committee'
,
'verbose_name_plural'
:
'committees'
},
),
]
website/activemembers/migrations/0017_auto_20170121_1105.py
0 → 100644
View file @
5360100a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-21 10:05
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'activemembers'
,
'0016_auto_20170120_0837'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'committee'
,
options
=
{
'verbose_name'
:
'committee'
,
'verbose_name_plural'
:
'committees'
},
),
]
website/activemembers/models.py
View file @
5360100a
...
...
@@ -10,16 +10,25 @@ from django.utils import timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
members.models
import
Member
from
utils.translation
import
ModelTranslateMeta
,
MultilingualField
from
utils.translation
import
(
ModelTranslateMeta
,
MultilingualField
,
localize_attr_name
)
logger
=
logging
.
getLogger
(
__name__
)
class
UnfilteredSortedManager
(
models
.
Manager
):
"""Returns committees and boards, sorted by name"""
def
get_queryset
(
self
):
return
(
super
().
get_queryset
()
.
order_by
(
localize_attr_name
(
'name'
)))
class
CommitteeManager
(
models
.
Manager
):
"""Returns committees only"""
def
get_queryset
(
self
):
return
(
super
().
get_queryset
()
.
exclude
(
board__is_board
=
True
))
.
exclude
(
board__is_board
=
True
)
.
order_by
(
localize_attr_name
(
'name'
)))
class
ActiveCommitteeManager
(
models
.
Manager
):
...
...
@@ -27,13 +36,14 @@ class ActiveCommitteeManager(models.Manager):
def
get_queryset
(
self
):
return
(
super
().
get_queryset
()
.
exclude
(
board__is_board
=
True
)
.
exclude
(
active
=
False
))
.
exclude
(
active
=
False
)
.
order_by
(
localize_attr_name
(
'name'
)))
class
Committee
(
models
.
Model
,
metaclass
=
ModelTranslateMeta
):
"""A committee"""
unfiltered_objects
=
models
.
Manager
()
unfiltered_objects
=
UnfilteredSorted
Manager
()
objects
=
CommitteeManager
()
active_committees
=
ActiveCommitteeManager
()
...
...
@@ -98,6 +108,7 @@ class Committee(models.Model, metaclass=ModelTranslateMeta):
class
Meta
:
verbose_name
=
_
(
'committee'
)
verbose_name_plural
=
_
(
'committees'
)
# ordering is done in the manager, to sort on a translated field
class
BoardManager
(
models
.
Manager
):
...
...
website/members/migrations/0015_auto_20170120_0837.py
0 → 100644
View file @
5360100a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-20 07:37
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'members'
,
'0014_auto_20161109_2128'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'member'
,
options
=
{
'ordering'
:
(
'user__first_name'
,
'user__last_name'
)},
),
]
website/members/models.py
View file @
5360100a
...
...
@@ -311,6 +311,9 @@ class Member(models.Model):
blank
=
True
,
)
class
Meta
:
ordering
=
(
'user__first_name'
,
'user__last_name'
)
def
display_name
(
self
):
pref
=
self
.
display_name_preference
if
pref
==
'nickname'
and
self
.
nickname
is
not
None
:
...
...
website/partners/migrations/0008_auto_20170120_0837.py
0 → 100644
View file @
5360100a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-20 07:37
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'partners'
,
'0007_vacancy_remarks'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'partner'
,
options
=
{
'ordering'
:
(
'name'
,)},
),
]
website/partners/models.py
View file @
5360100a
...
...
@@ -61,6 +61,9 @@ class Partner(models.Model):
def
get_absolute_url
(
self
):
return
reverse
(
'partners:partner'
,
args
=
(
self
.
slug
,))
class
Meta
:
ordering
=
(
'name'
,
)
class
PartnerImage
(
models
.
Model
):
partner
=
models
.
ForeignKey
(
...
...
website/photos/migrations/0006_auto_20170120_0837.py
0 → 100644
View file @
5360100a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-20 07:37
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'photos'
,
'0005_merge_20160812_1706'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'album'
,
options
=
{
'ordering'
:
(
'-date'
,
'title'
)},
),
migrations
.
AlterModelOptions
(
name
=
'photo'
,
options
=
{
'ordering'
:
(
'file'
,)},
),
]
website/photos/models.py
View file @
5360100a
...
...
@@ -46,6 +46,9 @@ class Photo(models.Model):
image
.
save
(
image_path
,
"JPEG"
)
self
.
_orig_file
=
self
.
file
.
path
class
Meta
:
ordering
=
(
'file'
,
)
class
Album
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
200
)
...
...
@@ -85,3 +88,6 @@ class Album(models.Model):
def
access_token
(
self
):
return
hashlib
.
sha256
(
'{}album{}'
.
format
(
settings
.
SECRET_KEY
,
self
.
pk
)
.
encode
(
'utf-8'
)).
hexdigest
()
class
Meta
:
ordering
=
(
'-date'
,
'title'
)
website/pizzas/migrations/0002_auto_20170120_0837.py
0 → 100644
View file @
5360100a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-20 07:37
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'pizzas'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'product'
,
options
=
{
'ordering'
:
(
'name'
,)},
),
]
website/pizzas/models.py
View file @
5360100a
...
...
@@ -60,6 +60,9 @@ class Product(models.Model, metaclass=ModelTranslateMeta):
def
__str__
(
self
):
return
self
.
name
class
Meta
:
ordering
=
(
'name'
,
)
class
Order
(
models
.
Model
):
member
=
models
.
ForeignKey
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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