-
Notifications
You must be signed in to change notification settings - Fork 3
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
New Feature: Publish start/end date #9
Conversation
Thanks for the new feature, @jedie! This is missing migrations though. Can you add the migration file and rebase this on master please? |
@jedie I'm also thinking that, is this actually a bit problematic. After this we would have objects in "draft" state, but actually public because of the dates. Edit: Didn't read the PR carefully enough. Indeed looks like you made sure that |
The few merge commits in the PR seem a bit unnecessary, otherwise looks pretty good to me. |
I have rebase on master and add tests to this feature... |
There's a silly thing about it. If an instance has already been published and you then set an end date, you should not forget to publish these changes. On the other hand, this is only consistent. |
I'm also working on a more verbose, but compact admin column. Something like this:
maybe it can be similar to django cms icons in page list?!? |
Nice work, @jedie! Thanks! Btw. forget my comment about missing migrations. Forgot that the changed models are abstract, so no migrations are needed. |
Q(publication_start_date__isnull=True) | Q(publication_start_date__lte=timezone.now()), | ||
Q(publication_end_date__isnull=True) | Q(publication_end_date__gt=timezone.now()), | ||
publisher_is_draft=PublisherModelBase.STATE_PUBLISHED, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. Should the functionality of this manager method match with the is_published method in PublisherModelBase? I think it should... so maybe add a visible
method rather than changing this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no... Don't know ;)
The idea was not to change the current API. Existing software that uses published() also considers start/end date.
But yes, it's a little messy. What should I do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see. Maybe the is_published
property should follow the same logic then? If there is a need for another property which doesn't consider the date, it should have a different name. How about is_publishable
? (Yep, naming is hard...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, naming... Hm...
Maybe we should just risk to ignore start/end date and "refactor" the names a little bit:
instance bool properties:
- instance.is_draft
- instance.is_published
- instance.hidden_by_end_date
- instance.hidden_by_start_date
- instance.is_visible
- instance.is_dirty
Model Manager methods:
- PublisherManager.drafts()
- PublisherManager.published()
- PublisherManager.visible()
QuerySet methods:
- PublisherQuerySet.filter_drafts()
- PublisherQuerySet.filter_published()
- PublisherQuerySet.filter_visible()
It should be documented that user should switch from PublisherManager.published()
to PublisherManager.visible()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is a good call.
Just a one thing: The QuerySet methods should have same names as the Model Manager methods. See https://docs.djangoproject.com/en/1.8/topics/db/managers/#from-queryset for instructions on how to define the drafts
, published
and visible
in the query set so that they are also defined in the manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done this in #14 ... It is time-consuming to maintain all changes in separate pull requests. So I created a new pull request with all changes.
See also: #7