Exemplo n.º 1
0
        menu.connect('/post/add', AddPost, name='post_add')
        menu.connect(r('/post/<post_id:int>/edit'), EditPost, name='post_edit')
        menu.connect(r('/post/<post_id:int>/delete'),
                     DeletePost,
                     name='post_delete')


from .model import Post
from zephyr.lib.validator import Validator
from zephyr.helper import site

from zephyr.session import security, ADMIN, EDITOR
from zephyr.breeze import Thing, Backend
from zephyr.lang import text

post_service = Thing('Post')
category_service = Thing('Category')
extend_service = Thing('Extend')

STATUSES = {
    'published': text('global.published'),
    'draft': text('global.draft'),
    'archived': text('global.archived'),
}


class PostPage:
    @security(EDITOR)
    def get(self, page=1, category=None):
        page = int(page)
        if category is not None:
Exemplo n.º 2
0
from .model import Page
from zephyr.lib.validator import Validator
from zephyr.helper import site

from zephyr.session import security, ADMIN, EDITOR
from zephyr.breeze import Thing, Backend
from zephyr.lang import text

PAGE_STATUSES = {
    'published': text('global.published'),
    'draft': text('global.draft'),
    'archived': text('global.archived'),
}

page_service, extend_service = Thing('Page'), Thing('Extend')


class PagePage:
    @security(EDITOR)
    def get(self, page=1, status='all'):
        pagination = page_service.page(status, page, site.posts_per_page())
        self.render('admin/page/index.html', status=status, pages=pagination)


class EditPage:
    @security(EDITOR)
    def get(self, page_id):
        page_id = int(page_id)
        pages = Backend('Page').dropdown(show_empty_option=True)
        page = Backend('Page').find(page_id)
Exemplo n.º 3
0
        menu.connect('/comment', CommentPage, name="comment_page1")
        menu.connect(r('/comment/<status>'), CommentPage, name="comment_page2")
        menu.connect(r('/comment/<status>/<page:int>'), CommentPage, name="comment_page3")
        menu.connect(r('/comment/<comment_id:int>/edit'), EditComment, name="comment_edit")
        menu.connect(r('/comment/<comment_id:int>/delete'), DeleteComment, name="comment_delete")


from zephyr.session import security, ADMIN, EDITOR
from zephyr.breeze import Thing
from zephyr.lang import text
from zephyr.lib.validator import Validator

from zephyr.helper import site


comment_service = Thing('Comment')

COMMENT_STATUSES = [
    {'url': 'all', 'lang': text('global.all'), 'class': 'all'},
    {'url': 'pending', 'lang': text('global.pending'), 'class': 'pending'},
    {'url': 'approved', 'lang': text('global.approved'), 'class': 'approved'},
    {'url': 'spam', 'lang': text('global.spam'), 'class': 'spam'}
]


class CommentPage:

    @security(EDITOR)
    def get(self, page=1, status='all'):
        page = int(page)
        pagination = comment_service.page(status, page, site.posts_per_page())
Exemplo n.º 4
0
        menu.connect(r('/user/<uid:int>/delete'),
                     DeleteUser,
                     name="user_delete")
        menu.connect('/user', UserPage, name='user_page1')
        menu.connect(r('/user/<page:int>'), UserPage, name='user_page')
        menu.connect(r('/user/<uid:int>/edit'), EditUser, name='user_edit')
        menu.connect('/user/add', AddUser, name="user_add")


from .model import User
from zephyr.breeze import Thing
from zephyr.helper import site as config
from zephyr.lang import text
from zephyr.session import security, ROOT, Account

user_service = Thing('User')

from zephyr.session import SessionManager


class Login:
    def get(self):
        if self.account.is_guest():
            return self.render('admin/user/login.html')
        self.redirect(self.reverse_url('post_page'))

    def post(self):
        _ = self.get_argument
        username, password = _('username'), _('password')

        result = user_service.auth(username, password)
Exemplo n.º 5
0
class ServiceMixin:
    """services"""
    post_service = Thing('Post')
    category_service = Thing('Category')
    comment_service = Thing('Comment')
    page_service = Thing('Page')
Exemplo n.º 6
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


def menu_menu(m):
    m.connect('/admin/menu', MenuPage, name='menu_page')
    m.connect('/admin/menu/update', UpdateMenu, name='menu_update')


from zephyr.session import security, ADMIN
from zephyr.breeze import Thing

menuservice = Thing('Menu')


class MenuPage:
    @security(ADMIN)
    def get(self):
        pages = menuservice.menu(True)
        self.render('admin/menu/index.html', messages='', pages=pages)


class UpdateMenu:
    @security(ADMIN)
    def post(self):
        sort = self.get_arguments('sort')
        menuservice.update(sort)
        self.jsonify({'return': True})
Exemplo n.º 7
0
                     name="category_page")
        menu.connect('/category/add', AddCategory, name="category_add")
        menu.connect(r('/category/<category_id:int>/edit'),
                     EditCategory,
                     name="category_edit")
        menu.connect(r('/category/<category_id:int>/delete'),
                     DeleteCategory,
                     name="category_delete")


from zephyr.breeze import Thing
from zephyr.lang import text
from zephyr.lib.validator import Validator
from zephyr.session import security, ADMIN

category_service = Thing('Category')


class CategoryPage:
    @security(ADMIN)
    def get(self, page=1):
        pagination = category_service.page(page)
        self.render('admin/category/index.html', categories=pagination)


class AddCategory:
    @security(ADMIN)
    def get(self):
        self.render('admin/category/add.html')

    @security(ADMIN)
Exemplo n.º 8
0
        menu.connect('/field/add', AddField, name='field_add')
        menu.connect(r('/field/<extend_id:int>/edit'),
                     EditField,
                     name='field_edit')
        menu.connect(r('/field/<extend_id:int>/delete'),
                     DeleteField,
                     name='field_delete')


from zephyr.lib.validator import Validator
from zephyr.helper import site
from zephyr.session import security, ADMIN, EDITOR
from zephyr.breeze import Thing
from zephyr.lang import text

extend_service = Thing('Extend')


class FieldPage:
    @security(ADMIN)
    def get(self, page=1):
        page = int(page)
        extends = extend_service.field_page(page)
        self.render('admin//extend/field/index.html', fields=extends)


class AddField:
    @security(ADMIN)
    def get(self):
        self.render('admin//extend/field/add.html')