Code Monkey home page Code Monkey logo

Comments (3)

benjaoming avatar benjaoming commented on June 17, 2024

That's a good idea... as well as RSS feeds would be great for updates and to monitor when new pages arrive.

Both cases have to account for permissions, though.

from django-wiki.

puterleat avatar puterleat commented on June 17, 2024

That's a good idea... as well as RSS feeds would be great for updates and to monitor when new pages arrive.

Both cases have to account for permissions, though.

Will django's sitemap framework be useful? I'm not sure in this case... but a sitemap config would be nice to have too.

from django-wiki.

jdcaballerov avatar jdcaballerov commented on June 17, 2024

Hello, I have one dirty solution I've been using during debug to get the index for a user and (almost) respecting permissions . Thanks to Ben for the excellent architecture !
I am not sure about all drawbacks of my implementation.

I create a view as follows:

from wiki import models


def wiki_index(request,template='wiki_index.html'):
    #hope this line circumvents any site issues
    nodes = models.URLPath.root().get_descendants(include_self=True).can_read(request.user) 
    if not request.user.has_perm('wiki.moderate'):
        nodes = nodes.exclude(article__current_revision__deleted=True)  

return render_to_response(template,{'nodes':nodes},context_instance=RequestContext(request))

and then using mptt tags is straightforward (wiki_index.html)

{% load mptt_tags %}
{% load url from future %}

<ul>
    {% recursetree nodes %}
        <li>
        <a href="{% url 'wiki:get' path=node.path %}"> {{node.article.current_revision.title|default_if_none:"No Title"}}</a>
            {% if not node.is_leaf_node %}
                <ul class="children">
                    {{ children }}
                </ul>
            {% endif %}
        </li>
    {% endrecursetree %}
</ul> 

urls.py add

 url('^index/$', 'your_app.views.wiki_index', name='wiki_index'),

This code "almost" respects permissions, since taking into account the current implementation (not architecture) of can_moderate it is wiki wide and not per article.

Any advise on how to fully implement it correctly ? I dont want to test each article for can_moderate, and since the manager doesn't implement it I dont see any better.

from django-wiki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.