Ejemplo n.º 1
0
    def getPageItem(self, request):
        # POST id
        id = sintjan.business.util.parseint(request.get("id"), 0)

        # GET id
        if id < 1:
            id = sintjan.business.util.parseint(request.get("pageid"), 0)

        if id > 0:
            page = Page.get_by_id(id)
        else:
            user = users.get_current_user()

            page = Page()
            page.createdOn = datetime.now()
            page.createdBy = user.user_id()
            page.url = request.get("path")
            page.title = ""
            page.content = ""
            page.breadcrumb = ""
            page.visible = True

        if not page.breadcrumb:
            page.breadcrumb = ""

        return page
Ejemplo n.º 2
0
    def get(self):
        
        values = {'context':RequestContext()}
        
        try:
            path = self.request.path
             
            if path.endswith('/'):
                str = "templates" + path + "index.html"
            else:
                str = "templates" + path + ".html"

            #values['debug1'] = self.request.path;
            #values['debug2'] = str;
            #values['debug1'] = arr[1]
            
            arr = path.split('/')
            values['menuItem'] = arr[1]
            self.response.out.write(template.render(str,values))
            
        except TemplateDoesNotExist:

            path = self.request.path
            values['path'] = path

            try:
                # Some hardcoding!!!
                if path == '/overons/':
                    path = '/overons/schoolmet5ks'
                elif path == '/overons/jaarthema/':
                    path = '/overons/jaarthema/2013-2014'
                elif path == '/info/':
                    path = '/info/contact'

                if path == '/sneeuwklassen' or path == '/sneeuwklassen/':
                    import datetime
                    now = datetime.datetime.now()
                    #2013-03-04
                    """
                    MAPPING = {
                        '2013-03-10': '/sneeuwklassen/maandag-10-maart-2014',
                        '2013-03-11': '/sneeuwklassen/disndag-11-maart-2014',
                        '2013-03-12': '/sneeuwklassen/woensdag-12-maart-2014',
                        '2013-03-13': '/sneeuwklassen/donderdag-13-maart-2014',
                        '2013-03-14': '/sneeuwklassen/vrijdag-14-maart-2014',
                        '2013-03-15': '/sneeuwklassen/zaterdag-15-maart-2014',
                        '2013-03-16': '/sneeuwklassen/zondag-16-maart-2014',
                        '2013-03-17': '/sneeuwklassen/maandag-17-maart-2014',
                        '2013-03-18': '/sneeuwklassen/dinsdag-18-maart-2014',
                        }
                    """
                    MAPPING = {
                        "2015-03-26": "/sneeuwklassen/donderdag-26-maart-2015",
                        "2015-03-27": "/sneeuwklassen/vrijdag-27-maart-2015",
                        "2015-03-28": "/sneeuwklassen/zaterdag-28-maart-2015",
                        "2015-03-29": "/sneeuwklassen/zondag-29-maart-2015",
                        "2015-03-30": "/sneeuwklassen/maandag-30-maart-2015",
                        "2015-03-31": "/sneeuwklassen/dinsdag-31-maart-2015",
                        "2015-04-01": "/sneeuwklassen/woensdag-1-april-2015",
                        "2015-04-02": "/sneeuwklassen/donderdag-2-april-2015",
                        "2015-04-03": "/sneeuwklassen/vrijdag-3-april-2015"
                    }
                    path = MAPPING.get(now.strftime('%Y-%m-%d'), '/sneeuwklassen/donderdag-26-maart-2015')

                # Fetching the page
                page = Page.gql("WHERE url = :url", url = path)[0]

                values['page'] = page
                values['blockLeft'] = self.getBlockLinkByRegion('left', page)
                values['blockFooter'] = self.getBlockLinkByRegion('footer', page)
                values['path'] = path

                if not page.breadcrumb:
                    values['breadcrumbLength'] = 0
                else:
                    values['breadcrumbLength'] = len(page.breadcrumb)

                if path.startswith('/sneeuwklassen'):
                    self.response.out.write(template.render('templates/pagesnow.html', values))
                else:
                    self.response.out.write(template.render('templates/page.html', values))
            except:
                # upsie, een vier nul vier
                # self.response.headers['Content-Type'] = 'text/html'
                #self.response.out.write(template.render('templates/info/contact.html',values))
                self.response.set_status(404)
                self.response.out.write(template.render('templates/404.html',values))