Giter Site home page Giter Site logo

Comments (2)

linuxsoftware avatar linuxsoftware commented on May 20, 2024

Hi,

I've only just pushed the change that added _getContext to the CalendarPage model. But sorry I think I have confused you with the name. It does not give all the context you need. It only returns the common fields: self, page, version, themeCSS and today, that all the serve functions use. I should probably rename it _getCommonContext or something like that.

Possibly _getExtraContext would work for you? e.g.

    def _getExtraContext(self, route):
        if route == "month":     # if you only want this for the month view
            return {'test': "test"}
        else:
            return {}

Or, modifying the TemplateResponse is possible. [NB: If you want this code to be called via an URL like /calendar/2019/05/ then your EventCalendarPage class must be concrete not a proxy and the derived serveMonth method must be registered as a RoutablePageMixin. I guess you have already worked this out, but I hadn't tried it before.]

@route(r"^month/$")
@route(r"^{YYYY}/{MM}/$".format(**DatePictures))
def serveMonth(self, request, year=None, month=None):
        response = super().serveMonth(request, year, month)
        response.context_data.update({'test': "test"})
        return response

Yes, this is a good way of raising questions. It's good to get the feedback, thanks. And I'd rather keep on using GitHub issues for this. I will see questions here quicker than on Stack Overflow. Are you able to share the full code for your Wagtail project? No worries if you can't, but if you can it might make it clearer to me what you are trying to do.

Best wishes, David.

from ls.joyous.

Jean-Zombie avatar Jean-Zombie commented on May 20, 2024

Hey David,

thanks again for your suggestions. I needed the weekend to read up on the concept of the super()-class; but the solution with RouteablePageMixin totally does it.

What I am actually trying to do (now) is to make a route for categories; i.e. query all events of category "Party" or "Concert". I am pretty confident your code snippet will lead me there. I can share code, so I might be back if I get stuck ;-)

Cheers
Ronald

from ls.joyous.

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.