def action_edit(self): if self.section.handler.request.get('submit'): self.SITE_HEADER = self.section.handler.request.get('SITE_HEADER') self.SITE_SUB_HEADER = self.section.handler.request.get('SITE_SUB_HEADER') self.DEFAULT_THEME = self.section.handler.request.get('DEFAULT_THEME') self.GOOGLE_ANALYTICS_UA = self.section.handler.request.get('GOOGLE_ANALYTICS_UA') self.ROBOTS_TXT = self.section.handler.request.get('ROBOTS_TXT') if self.section.handler.request.get('FAVICON_ICO'): data = db.Blob(self.section.handler.request.get('FAVICON_ICO')) if self.FAVICON_ICO: self.FAVICON_ICO.data = data else: self.FAVICON_ICO = File(filename='favicon.ico', content_type='image/x-icon', data=data) self.FAVICON_ICO.put() self.ENABLE_THEME_PREVIEW = self.section.handler.request.get('ENABLE_THEME_PREVIEW') != '' self.DEBUG_MODE = self.section.handler.request.get('DEBUG_MODE') != '' cache.delete(CACHE_KEY) self.update() raise Exception('Redirect', self.section.action_redirect_path) f = form(self.section, self.section.full_path) f.add_control(control(self.section, 'text', 'SITE_HEADER', self.SITE_HEADER, 'Site header', 50)) f.add_control(control(self.section, 'text', 'SITE_SUB_HEADER', self.SITE_SUB_HEADER, 'Site sub-header', 50)) combined_themes = get_local_theme_namespaces() + get_custom_theme_namespaces() f.add_control(selectcontrol(self.section, 'DEFAULT_THEME', combined_themes, self.DEFAULT_THEME if self.DEFAULT_THEME else DEFAULT_LOCAL_THEME_TEMPLATE, 'Default theme')) f.add_control(control(self.section, 'text', 'GOOGLE_ANALYTICS_UA', self.GOOGLE_ANALYTICS_UA, 'Google analytics UA')) f.add_control(control(self.section, 'file', 'FAVICON_ICO', label='favicon.ico')) f.add_control(textareacontrol(self.section, 'ROBOTS_TXT', self.ROBOTS_TXT, 'robots.txt', 90, 5)) f.add_control(checkboxcontrol(self.section, 'ENABLE_THEME_PREVIEW', self.ENABLE_THEME_PREVIEW, 'Enable theme preview')) f.add_control(checkboxcontrol(self.section, 'DEBUG_MODE', self.DEBUG_MODE, 'Debug mode')) f.add_control(control(self.section, 'submit', 'submit', 'Submit')) return '<h2>Edit configuration</h2>%s' % unicode(f)
def action_edit(self): if self.section.handler.request.get('submit'): self.SITE_HEADER = self.section.handler.request.get('SITE_HEADER') self.SITE_SUB_HEADER = self.section.handler.request.get( 'SITE_SUB_HEADER') self.DEFAULT_THEME = self.section.handler.request.get( 'DEFAULT_THEME') self.GOOGLE_ANALYTICS_UA = self.section.handler.request.get( 'GOOGLE_ANALYTICS_UA') self.ROBOTS_TXT = self.section.handler.request.get('ROBOTS_TXT') if self.section.handler.request.get('FAVICON_ICO'): if self.FAVICON_ICO: BlobInfo.get(self.FAVICON_ICO).delete() data = self.section.handler.request.get('FAVICON_ICO') handle = files.blobstore.create( mime_type='image/x-icon', _blobinfo_uploaded_filename='favicon.ico') with files.open(handle, 'a') as f: f.write(data) files.finalize(handle) self.FAVICON_ICO = files.blobstore.get_blob_key(handle) self.ENABLE_THEME_PREVIEW = self.section.handler.request.get( 'ENABLE_THEME_PREVIEW') != '' self.DEBUG_MODE = self.section.handler.request.get( 'DEBUG_MODE') != '' cache.delete(CACHE_KEY) self.update() raise Exception('Redirect', self.section.action_redirect_path) f = form(self.section, self.section.full_path) f.add_control( control(self.section, 'text', 'SITE_HEADER', self.SITE_HEADER, 'Site header', 50)) f.add_control( control(self.section, 'text', 'SITE_SUB_HEADER', self.SITE_SUB_HEADER, 'Site sub-header', 50)) combined_themes = get_local_theme_namespaces( ) + get_custom_theme_namespaces() f.add_control( selectcontrol( self.section, 'DEFAULT_THEME', combined_themes, self.DEFAULT_THEME if self.DEFAULT_THEME else DEFAULT_LOCAL_THEME_TEMPLATE, 'Default theme')) f.add_control( control(self.section, 'text', 'GOOGLE_ANALYTICS_UA', self.GOOGLE_ANALYTICS_UA, 'Google analytics UA')) f.add_control( control(self.section, 'file', 'FAVICON_ICO', label='favicon.ico')) f.add_control( textareacontrol(self.section, 'ROBOTS_TXT', self.ROBOTS_TXT, 'robots.txt', 90, 5)) f.add_control( checkboxcontrol(self.section, 'ENABLE_THEME_PREVIEW', self.ENABLE_THEME_PREVIEW, 'Enable theme preview')) f.add_control( checkboxcontrol(self.section, 'DEBUG_MODE', self.DEBUG_MODE, 'Debug mode')) f.add_control(control(self.section, 'submit', 'submit', 'Submit')) return '<h2>Edit configuration</h2>%s' % unicode(f)
def get_form(s, path, parent_path, name=None, title=None, keywords=None, description=None, theme=None, is_private=False, is_default=False, redirect_to=None, new_window=False): f = form(s, s.full_path) f.add_control(control(s, 'text', 'path', path, 'Path')) f.add_control(control(s, 'text', 'parent_path', parent_path if parent_path else '', 'Parent path')) f.add_control(control(s, 'text', 'name', name if name else '', 'Name', 30)) f.add_control(control(s, 'text', 'title', title if title else '', 'Title', 60)) f.add_control(textareacontrol(s, 'keywords', keywords if keywords else '', 'Keywords', 60, 5)) f.add_control(textareacontrol(s, 'description', description if description else '', 'Description', 60, 5)) combined_themes = get_local_theme_namespaces() + get_custom_theme_namespaces() default_theme = configuration.default_theme() if not default_theme: default_theme = template.DEFAULT_LOCAL_THEME_TEMPLATE f.add_control(selectcontrol(s, 'theme', combined_themes, theme if theme else default_theme, 'Theme')) f.add_control(checkboxcontrol(s, 'is_private', is_private, 'Is private')) if not is_default: f.add_control(checkboxcontrol(s, 'is_default', is_default, 'Is default')) f.add_control(control(s, 'text', 'redirect_to', redirect_to if redirect_to else '', 'Redirect to', 60)) f.add_control(checkboxcontrol(s, 'new_window', new_window, 'New window')) f.add_control(control(s, 'submit', 'submit')) return unicode(f)