[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create abstract base class for common fields #47

Merged
merged 7 commits into from
Feb 20, 2017
Merged

Conversation

daaray
Copy link
Contributor
@daaray daaray commented Feb 18, 2017

Fixes #41

Introduces base.models.BasePageFieldsMixin which includes image and introductionfields.

Currently utilized in:

  • base.models.GalleryPage
  • blog.models.BlogIndexPage
  • breads.models.BreadsIndexPage
  • locations.models.LocationsIndexPage

Review other pages for use of the mixin:

  • BlogPage
  • BreadPage
  • LocationPage

@daaray daaray requested a review from shacker February 18, 2017 11:38
@shacker
Copy link
Contributor
shacker commented Feb 18, 2017

Hey wow, I had actually done half of this work last night, was going to finish today, but you beat me to it. Thanks! Code looks great, and I pulled it down and it migrated and works fine. My only question is: Shouldn't every page of the site have a large hero image and intro? (both index and detail pages)? If so, then this should also be applied to BlogPage, BreadPage, and LocationPage, not just the index pages. If you agree, can you do a 2nd commit on this PR to add those? Or do you disagree?

@shacker shacker mentioned this pull request Feb 18, 2017
14 tasks
@daaray
Copy link
Contributor Author
daaray commented Feb 19, 2017 via email

@shacker
Copy link
Contributor
shacker commented Feb 19, 2017

Of course you're right that unassigned tickets are up for grabs - I should have thought to assign it to myself. All yours now :)

@daaray
Copy link
Contributor Author
daaray commented Feb 19, 2017

@shacker I would like some feedback as to how to best approach BlogPage and BreadPage:

BlogPage

This model is currently differentiated by the addition of a subtitle field and how the content panels are configured:

        MultiFieldPanel([
            FieldPanel('subtitle'),
            FieldPanel('introduction'),
        ]),
        ...

BreadPage

BreadPage currently has no introduction field. It does have a description StreamField:

    description = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
    ])

How would you suggest that we reconcile the above with the BasePageFieldsMixin?

@shacker
Copy link
Contributor
shacker commented Feb 19, 2017

For the BlogPage, I don't think we need both subtitle and introduction. Intro is important for smart truncation of blog posts on index pages so keep that, but subtitle isn't actually something I've seen on blogs before. I'd ditch that. For the content panels of BlogPage, I'd show the inherited ones first, then the specific ones (so introduction after the two inherited ones).

On the BreadPage, I don't see the point of a heading CharBlock since we already have the bread's title. With that gone, we could just use body from elsewhere, rather than introduction (to maximize consistency).

Agree/disagree?

@daaray
Copy link
Contributor Author
daaray commented Feb 20, 2017

@shacker when you have a change, if you could take another look at this PR; I implemented your suggestions.

@hminnovation
Copy link
Contributor

@shacker and @daaray the subtitle came from the design, and is the text that's appearing visually under the main title on the BlogPage. If it's going to make lives difficult then I'd say ditch it, but it does help with the design by giving an extra element to play with. (Not perhaps relevant but On UK news websites it's also a pattern that's used regularly to have title, standfirst then introduction)

The rest looks great!

@daaray
Copy link
Contributor Author
daaray commented Feb 20, 2017

@heymonkeyriot @shacker I restored subtitle as it is a design requirement. It also allows us to illustrate the malleability of the content_panels (they are 'just' lists and can be interacted with as such):

    content_panels = BasePageFieldsMixin.content_panels + [
        StreamFieldPanel('body'),
        FieldPanel('date_published'),
        InlinePanel(
            'blog_person_relationship', label="Author(s)",
            panels=None, min_num=1),
        FieldPanel('tags'),
    ]
    # Inject subtitle panel after title field
    title_index = next((i for i, panel in enumerate(content_panels) if panel.field_name == 'title'), -1)  # noqa
    content_panels.insert(title_index + 1, FieldPanel('subtitle'))

This should be ready for final review.

@shacker
Copy link
Contributor
shacker commented Feb 20, 2017

That's a very interesting technique, using a list comprehension to manipulate the content_panels dynamically.

@shacker shacker merged commit dc93606 into master Feb 20, 2017
@shacker shacker deleted the 41-abstract-base-page branch February 20, 2017 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants