def addUpdatePageModule(pageStringKey, pageModuleName, language, publish):
    pageKey = db.Key(pageStringKey)

    if publish == "on":
        publish = True
    else:
        publish = False

    page = dbPages.Pages.get(pageKey)
    pageModule = dbPageModules.PageModules.gql('WHERE pageKey = :pageKey AND lang = :language', pageKey = pageKey, language = language).get()

    if pageModule is None:
        pageModule = dbPageModules.PageModules()
        pageModule.pageKey = pageKey
        pageModule.lang = language

    pageModule.name = pageModuleName
    stringPath = Utils.slugify(unicode(pageModuleName)) + '/'
    path = getPath(page, language, stringPath)

    ## If path is False, parent page in GetPath method has not been saved.
    if not path:
        return { 'status' : -1, 'message' : 'Parent page is not published', 'pageId' : str(page.key().id()) }

    pageModule.path = path
    pageModule.published = publish

    ## We need the key so we put this in the datastore right away
    pageModuleKey = db.put(pageModule)

    return { 'status' : 1, 'message' : 'Content added/updated', 'redirect' : '/edit/Pages/?item_id=' + str(page.key().id()), 'pageModuleKey' : pageModuleKey }
示例#2
0
def addNewPage(pageName, pageTemplateType, pageParentKey):
    if pageName == '':
        return { 'status': '-1', 'message': 'No Page name entered' }

    if pageTemplateType == '-1':
        return { 'status': '-1', 'message': 'No Page template selected' }

    if pageParentKey == '-1':
        return { 'status': '-1', 'message': 'No Page parent selected' }

    if pageTemplateType.split('.')[-1] == 'PageContainer':
        keyName = Utils.slugify(unicode(pageName))
        page = dbPages.Pages(key_name=keyName)
        page.sortIndex = 1000
    else:
        page = dbPages.Pages()
        page.sortIndex = 10

    page.name = pageName
    page.templateType = pageTemplateType

    parentStringKey = None
    
    if pageParentKey != '0' and pageTemplateType != 'PageService.PageTemplates.PageContainer':
        parentStringKey = pageParentKey

    page.parentStringKey = parentStringKey

    pageKey = db.put(page)

    return { 'status' : 1, 'message' : 'Page added/updated', 'pageKey' : pageKey, 'redirect' : '/edit/Pages/?item_id=' + str(pageKey.id()) }
    def __init__(self, path, **kwargs):
        GetHandler.__init__(self, path, **kwargs)

        self.pathList = Utils.parsePath(path[1])

        _view = getattr(Edit, self.pathList[-1])
        self.view = _view(path = '/'.join(self.pathList), query = kwargs['query'])

        self.check_permission(**kwargs)
        self.view.toTemplate.userContext = self.userContext
示例#4
0
    def __init__(self, **kwargs):
        query = kwargs['query']

        self.templateFile = ''
        self.permissionLevel = 0
        self.isEdit = False
        self.toTemplate = Utils.dictObj()
        self.toTemplate.markets = Settings.markets

        if 'path' in kwargs:
            self.toTemplate.path = kwargs['path']

        self.toTemplate.currentView = self

        if query.getvalue('status'):
            self.toTemplate.statusCode = query.getvalue('status')
            self.toTemplate.statusMessage = query.getvalue('message')
    def __init__(self, **kwargs):
        query = kwargs['query']

        self.templateFile = ''
        self.permissionLevel = 0
        self.isEdit = False
        self.toTemplate = Utils.dictObj()
        self.toTemplate.markets = Settings.markets

        if 'path' in kwargs:
            self.toTemplate.path = kwargs['path']

        self.toTemplate.currentView = self

        if query.getvalue('status'):
            self.toTemplate.statusCode = query.getvalue('status')
            self.toTemplate.statusMessage = query.getvalue('message')
def addUpdatePageModule(pageStringKey, pageModuleName, language, publish):
    pageKey = db.Key(pageStringKey)

    if publish == "on":
        publish = True
    else:
        publish = False

    page = dbPages.Pages.get(pageKey)
    pageModule = dbPageModules.PageModules.gql(
        'WHERE pageKey = :pageKey AND lang = :language',
        pageKey=pageKey,
        language=language).get()

    if pageModule is None:
        pageModule = dbPageModules.PageModules()
        pageModule.pageKey = pageKey
        pageModule.lang = language

    pageModule.name = pageModuleName
    stringPath = Utils.slugify(unicode(pageModuleName)) + '/'
    path = getPath(page, language, stringPath)

    ## If path is False, parent page in GetPath method has not been saved.
    if not path:
        return {
            'status': -1,
            'message': 'Parent page is not published',
            'pageId': str(page.key().id())
        }

    pageModule.path = path
    pageModule.published = publish

    ## We need the key so we put this in the datastore right away
    pageModuleKey = db.put(pageModule)

    return {
        'status': 1,
        'message': 'Content added/updated',
        'redirect': '/edit/Pages/?item_id=' + str(page.key().id()),
        'pageModuleKey': pageModuleKey
    }
 def __init__(self, path, **kwargs):
     self.pathList = Utils.parsePath(path[0])
     PostHandler.__init__(self, path, **kwargs)
    def __init__(self, path, **kwargs):
        GetHandler.__init__(self, path, **kwargs)

        self.pathList = Utils.parsePath(path[0])

        self.view = MainView(path = '/'.join(self.pathList), query = kwargs['query'])