Beispiel #1
0
#encoding: utf-8

from flask import render_template, request, current_app
from datetime import datetime
from flask import redirect, url_for, jsonify
from app.common import logger
from flask_login import login_url, current_user, login_required
from app.common.time_util import *
from app.common.action_log import action_log
from sqlalchemy import func

from . import admin
from app.models import User, Mail, Group, Role, users_roles, user_group

logger = logger.Logger(logger="admin-user").getlog()


@admin.route('/get_users', methods=['GET'])
def users_page():
    return render_template("admin/users.html")


@admin.route('/users', methods=['GET'])
#@login_required
def user_list():
    #page = request.args.get('page', 1, type=int)
    page_size = request.args.get('limit', 5, type=int)
    page = request.args.get('page', 1, type=int)
    type = request.args.get('type')
    if type == None:
        pagination = User.query.filter(User.type == '1').order_by(
Beispiel #2
0
#encoding: utf-8

from flask import render_template, request, current_app
from datetime import datetime
from flask import redirect, url_for, jsonify
from app.common import logger
from flask_login import login_url, current_user, login_required
from app.common.time_util import *
from sqlalchemy import func
from app.common.action_log import action_log

from . import admin
from app.models import User, Attachment, Catalog, Dictionary, ActionLog

logger = logger.Logger(logger="admin-common").getlog()

# @admin.route('/get_users',methods=['GET'])
# def users_page():
#     return render_template("admin/users.html")


@admin.route('/catalogs', methods=['GET'])
def catalog_list():
    page_size = request.args.get('limit', 5, type=int)
    page = request.args.get('page', 1, type=int)
    pagination = Catalog.query.order_by(Catalog.created_time.asc()).paginate(
        page, per_page=page_size, error_out=False)
    catalogs = pagination.items

    #prev = None
    #if pagination.has_prev:
Beispiel #3
0
from flask import jsonify

from app.common import logger
from app.common.time_util import get_localtime
from app.common.action_log import action_log
from app.common.extensions import cache

from app.api import api
from app.models import User,Post,Comment
from app.post import post,make_cache_key
from app.common.db import db

from flask_restful import Resource
from app.common.extensions import restful_api

logger = logger.Logger(logger="api-comments").getlog()



@api.route('/comments/', methods=['GET'])
def get_comments():
    page_size=request.args.get('limit', 5, type=int)
    page=request.args.get('page', 1, type=int)
    pagination = Comment.query.order_by(Comment.created_time.desc()).paginate(
        page, per_page=page_size,error_out=False)

    comments = pagination.items
    return jsonify({
        'data': [comment.to_json() for comment in comments],
        'msg': '',
        'code': 0,
Beispiel #4
0
from flask import session, abort
from app.common import logger
from app.common.action_log import action_log
from app.common.extensions import cache
from app.common.permission import permission, permission_required
import json
import re

from app.api import api
from app.models import User, Post, Tag
from app.post import post, make_cache_key
from app.common import utils
from app.common.db import db
#from .errors import forbidden

logger = logger.Logger(logger="api-posts").getlog()


@api.route('/posts/', methods=['GET', 'POST'])
@cache.cached(timeout=60)
def get_posts():
    page_size = request.args.get('limit', 5, type=int)
    page = request.args.get('page', 1, type=int)
    if request.method == 'GET':
        pagination = Post.query.order_by(Post.publish_date.asc()).paginate(
            page, per_page=page_size, error_out=False)
        posts = pagination.items
        return jsonify({
            'data': [post.to_json() for post in posts],
            'msg': '',
            'code': 0,
Beispiel #5
0
#encoding: utf-8

from flask import render_template,request,current_app
from datetime import datetime
from flask import redirect,url_for,jsonify,json,request
from app.common import logger
from flask_login import login_url,current_user,login_required
from app.common.time_util import get_localtime
from sqlalchemy import func
from app.common.action_log import  action_log
from . import admin
from app.models import User,Action,ActionLog,roles_actions,Role,Resource,roles_resources
from app.common.db import db

logger = logger.Logger(logger="admin-api").getlog()


@admin.route('/get_actions',methods=['GET'])
def actions_page():
    return render_template("admin/actions.html")


@admin.route('/actions',methods=['GET'])
def action_list():
    page_size=request.args.get('limit', 5, type=int)
    page=request.args.get('page', 1, type=int)

    pagination = Action.query.order_by(Action.created_time.asc()).paginate(
        page, per_page=page_size,
        error_out=False)
    actions = pagination.items
Beispiel #6
0
from flask_login import login_user, logout_user
from flask_login import login_required, current_user
from app.common.mails import send_mail
from app.common import logger
# from flask_principal import Identity, AnonymousIdentity
# from flask_principal import identity_changed, current_app

# from app import db,openid
from app.common.extensions import openid
from app.common.db import db

from . import main
from app.models import User, Mail
from app.common.forms import LoginForm, RegisterForm, OpenIDForm, ChangePasswordForm

logger = logger.Logger(logger="home_view").getlog()


@main.route('/')
def index(page=1):
    """View function for main page"""

    return render_template("index.html")


@main.route('/login', methods=['GET', 'POST'])
@openid.loginhandler
def login():
    """View function for login."""

    # Will be check the account whether rigjt.
Beispiel #7
0
# -*- coding: UTF-8 -*-

from threading import Thread
from flask import current_app, render_template
from flask_mail import Message
#from app.common.extensions import mail
from app.common import logger

logger = logger.Logger(logger="mails").getlog()


#发送邮箱的子线程类
class SendMailThread(Thread):
    def __init__(self, app, msg):
        super(SendMailThread, self).__init__()
        self.__app = app
        self.__msg = msg

    #异步发送邮件
    def send_async_mail(self, app, msg):
        with app.app_context():
            from app.common.extensions import mail
            logger.info("start send mail")
            mail.send(msg)

    # 发送邮件
    def run(self):
        self.send_async_mail(self.__app, self.__msg)


#封装邮件发送过程