springload / madewithwagtail

A showcase of sites and apps made with Wagtail CMS, the easy to use, open source Django content management system
http://madewithwagtail.org
MIT License
84 stars 21 forks source link

Ability to re-arrange sites within a Developer profile #80

Closed jennyadamsnz closed 6 years ago

jennyadamsnz commented 6 years ago

Andy from Rock Kitchen Harris has enquired re having the option to be able to re-arrange their website submissions on their Developer profile page either alphabetically or in a custom order so they can feature their best work first (current pushed on to the second page as the order is currently chronological and their major projects were submitted first). This is currently possible with the featured tick box but this would also impact the home page featured items. Ideally it would be great to have a home page featured option and a seperate featured option within the individual developer profiles.

thibaudcolas commented 6 years ago

Makes perfect sense to me. I'm not sure how best to implement this, suggestions welcome!

loicteixeira commented 6 years ago

Sorry I wasn't watching this repo for some reason..

Children need to be ordered by path (or -path I can never remember) instead of -first_published_at.

But maybe it would make sense to have an option on the page to allow either alphabetical or manual ordering, e.g. WagtailCompanyPage could have:

# At the top of the file
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _

# In the class
automatic_ordering_of_sites = models.BooleanField(
    default=True,
    help_text=mark(
        _(
            'Whether the sites are automatically listed in alphabetical order '
            'or <a href="{}" target="_blank">manually ordered</a> through the admin.'
        ).format('http://docs.wagtail.io/en/v1.8/editor_manual/finding_your_way_around/the_explorer_page.html#reordering-pages')
    )

    def children(self):
        qs = WagtailSitePage.objects.live().descendant_of(self)
        if self.automatic_ordering_of_sites:
            qs = qs.order_by('title')
        else:
            qs = qs.order_by('path')  # or `-path`?
        return

    # TODO: Update the panels

I'll try to make a PR if you agree with the process.

Note:

jennyadamsnz commented 6 years ago

Sounds good! Let's do it!