-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from molgen/order-publications-v2
Order publications v2
- Loading branch information
Showing
11 changed files
with
946 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
mpicms/publications/migrations/0004_publication_sort_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import migrations, models | ||
|
||
def init_sort_order(apps, schema_editor): | ||
Publication = apps.get_model('publications', 'Publication') | ||
for publication in Publication.objects.all(): | ||
publication.sort_order = -publication.pk | ||
publication.save(update_fields=['sort_order']) | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('publications', '0003_auto_20190905_1120'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='publication', | ||
name='sort_order', | ||
field=models.IntegerField(blank=True, editable=False, null=True), | ||
), | ||
migrations.RunPython(init_sort_order, reverse_code=migrations.RunPython.noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register | ||
from wagtailorderable.modeladmin.mixins import OrderableMixin | ||
|
||
from .models import Publication | ||
|
||
|
||
class PublicationAdmin(ModelAdmin): | ||
class PublicationAdmin(OrderableMixin, ModelAdmin): | ||
model = Publication | ||
menu_label = _('Publications') | ||
menu_icon = 'doc-full' | ||
search_fields = ['title', 'authors', 'source', 'doi', 'groups'] | ||
ordering = ['sort_order'] | ||
|
||
|
||
modeladmin_register(PublicationAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ psycopg2-binary | |
# Wagtail | ||
wagtail | ||
wagtail-modeltranslation | ||
wagtail-orderable | ||
|
||
markdown | ||
pygments | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.