python-gsoc / python-blogs

Python Software Foundation GSoC Blog Platform. This system was used until 2024 but is no longer maintained.
http://python-gsoc.org/
GNU Affero General Public License v3.0
41 stars 60 forks source link

GSoC 2019 - Add notice when page is unpublished. #53

Closed botanicvelious closed 5 years ago

botanicvelious commented 5 years ago

This task is to add a notice to a logged in user when a page is unpublished. Some sort of large red box at the top would do nicely.

Saurabh-Singh-00 commented 5 years ago
from django.shortcuts import render
from aldryn_newsblog import models

def unpublished_article(request):
    unpublished = None
    if request.user.is_authenticated:
        unpublished = models.Article.objects.filter(author__user=request.user, is_published=False)
    return render(request, 'unpublished_notice.html', {'unpublished': unpublished})

I have created a demo view like this and this one does the required job but how should I integrate this with the djangocms?

imageedit_4_5013573572

botanicvelious commented 5 years ago

You can override the default template files.

Saurabh-Singh-00 commented 5 years ago

So, should I have to override all the templates or only base.html would be enough?

botanicvelious commented 5 years ago

Whatever template you need to override to make it work. Dont just override everything for no reason, just the ones you need.

Saurabh-Singh-00 commented 5 years ago

imageedit_2_8563309557

I created a page named "unpublished-page" and kept it as unpublished. Now it shows a large red box at the top to admin if a page is unpublished. Is this what, exactly was required? It shows the red box only on unpublished page.

botanicvelious commented 5 years ago

Looks correct, make sure that only displays when someone is logged in!

Saurabh-Singh-00 commented 5 years ago

@botanicvelious Is there something more required in this issue?