Esempio n. 1
0
# -*- coding: utf-8 -*-
from flask import Module,render_template,request,g,jsonify
from nuteam.controllers.filters import login_filter
from nuteam.services import teamservice, issueservice

issue = Module(__name__)
issue.before_request(login_filter)

@issue.route('/Project/Issue/<int:project_id>')
def list(project_id):
    member_list = teamservice.member_in_project(project_id)
    category = issueservice.available_category()
    return render_template('Issue/List.html',ProjectId=project_id,MemberList=member_list,Category=category)

@issue.route('/Issue/Create/<int:project_id>')
def create(project_id):
    member_list = teamservice.member_in_project(project_id)
    category = issueservice.available_category()
    return render_template('Issue/Create.html',ProjectId=project_id,MemberList=member_list,Category=category)

@issue.route('/Issue/CreateNew',methods=['POST'])
def create_new():
    issueservice.create(request.json['ProjectId'],request.json['Subject'],request.json['Priority'],request.json['AssignTo'],request.json['Description'],request.json['CategoryId'],g.user_id)
    return jsonify(created=True,ProjectId=request.json['ProjectId'])

@issue.route('/Issue/Query',methods=['POST'])
def query():
    subject = request.json['Subject']
    assign_to = int(request.json['AssignTo'])
    if assign_to == -1:
        assign_to = g.user_id
Esempio n. 2
0
from flask import (Module)
from flaskcma.stories.documents import Story

mod = Module(__name__, name="stories")

mod.flaskcma = {
    'content_list': [Story]
}
Esempio n. 3
0
# -*- coding: utf-8 -*-
from flask import Module,render_template,redirect,request,session,jsonify,g
from nuteam.services import userservice
from nuteam.controllers.filters import login_filter

user = Module(__name__)
user.before_request(login_filter)

@user.route('/SignOut')
def sign_out():
    response = redirect('/')
    session['username'] = None
    session['userid'] = None
    return response

@user.route('/Profile')
def profile():
    u = userservice.get(session['username'])
    return render_template('Profile/Detail.html',User=u)

@user.route('/ChangePassword',methods=['POST'])
def change_password():
    raw_password = request.json['RawPassword']
    password = request.json['Password']
    updated = userservice.change_password(raw_password,password,g.user_id)
    return jsonify(Updated=updated)

@user.route('/UpdateProfile',methods=['POST'])
def update_profile():
    email = request.json['Email']
    nick = request.json['Nick']
Esempio n. 4
0
from flask import (
    g,
    Module,
    redirect,
    render_template,
    request,
    session,
    url_for,
)
from flatland.out.markup import Generator

from cockerel.models.schema import db, User
from cockerel.forms import LoginForm, SignupForm

admin = Module(__name__)


@admin.route('/login', methods=['GET', 'POST'])
def login():
    # TODO: make this do better auth, it needs to set a cookie for a period of
    #  time
    if request.method == 'POST':
        form = LoginForm.from_flat(request.form)
        if form.validate():
            user = User.query.filter_by(
                username=request.form['username']).first()

            if user == None:
                form['username'].add_error(
                    'Username %s not found' % form['username'].value)
                gen = Generator()
Esempio n. 5
0
# -*- coding: utf-8 -*-
from flask import Module,render_template,request,jsonify,g
from nuteam.controllers.filters import login_filter
from nuteam.services import taskservice, teamservice

task = Module(__name__)
task.before_request(login_filter)

@task.route('/Project/Task/<int:project_id>')
def list(project_id):
    member_list = teamservice.member_in_project(project_id)
    return render_template('Task/List.html',ProjectId=project_id,MemberList=member_list)

@task.route('/Task/Query',methods=['POST'])
def query():
    task_name = request.json['TaskName']
    assign_to = int(request.json['AssignTo'])
    if assign_to == -1:
        assign_to = g.user_id
    status_new = request.json['New']
    status_in_progress = request.json['InProgress']
    status_completed = request.json['Completed']
    status_canceled = request.json['Canceled']
    page_no = request.json['PageNo']
    (row_count,page_count,page_no,page_size,data) = taskservice.query(task_name,assign_to,status_new,status_in_progress,status_completed,status_canceled,'Priority',page_no)
    tasks = []
    for t in data.all():
        tasks.append({'TaskId':t.TaskId,'TaskName':t.TaskName,'Priority':t.Priority,'Progress':t.Progress,'Status':t.Status,'Effort':t.Effort,'AssignTo':t.AssignToProfile.Nick,'Creator':t.CreatorProfile.Nick,'LastUpdateDate':t.LastUpdateDate.isoformat()})
    return jsonify(row_count=row_count,page_count=page_count,page_no=page_no,page_size=page_size,data=tasks)

@task.route('/Task/Create/<int:project_id>')
Esempio n. 6
0
flask-odesk version 0.4.1
(C) 2011 oDesk
"""

from __future__ import absolute_import
from functools import wraps
from flask import Module, request, redirect, session, flash,\
    url_for, current_app
from odesk import Client


ODESK_REQUEST_TOKEN = '_ort'
ODESK_ACCESS_TOKEN = '_oat'

odesk = Module(__name__)


def is_authorized():
    """
    Check authorization for current user
    """
    return session.get(ODESK_ACCESS_TOKEN, False) and True
odesk.is_authorized = is_authorized


@odesk.app_context_processor
def inject_is_authorized():
    """
    Context processor for is_authorized method
    """
Esempio n. 7
0
import os
from uuid import uuid4

from flask import Module, jsonify, request, Response
from flask.views import MethodView

from core.api import API
from core.api.decorators import jsonp
from core.backends.UNIX import UNIXBackend
from core.utils.RequestValidator import CreateUnikernelValidator
from ..RedisQueue import Q

api = Module(
    __name__,
    # url_prefix='/api'
)


def jsonify_status_code(*args, **kw):
    response = jsonify(*args, **kw)
    response.status_code = kw['code']
    return response


@api.route('/')
def index():
    """
    The root of the API returns an error
    """
    return jsonify_status_code(
        code=400,
Esempio n. 8
0
# -*- coding: UTF-8 -*-
import json

from flask import Module, render_template, jsonify, redirect, request, session, g
from src.fitnessconfig import *
from src.services import userservice, employeeservice, memberservice
from src.models.userprofile import UserStatus

fitnessmanages = Module(__name__)


@fitnessmanages.route('/fitnessmanages')
def fitnessmanage():
    return render_template('FitnessManages/index.html')
Esempio n. 9
0
from flask import Module, request, render_template

mod = Module(__name__)

import logging
import json

log = logging.getLogger('svg-web')

import svgweb.util.phantomjs as pjs
import svgweb.util.pdf_util as pdf


@mod.route('/')
def index():
    return render_template('index.html')


@mod.route('/ajax/convert/')
def convert():
    a = request.args
    if not 'url' in a:
        return ajax_error('no url given')

    if not 'ext' in a:
        return ajax_error('no extension given')

    ext = a['ext']
    if ext != '.png' and ext != '.pdf':
        return ajax_error('invalid format png/pdf only')
Esempio n. 10
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Module, redirect, url_for, session, flash, \
    abort, request, current_app

from flask.ext.babel import gettext as _
from flask.ext.principal import Identity, identity_changed

from newsmeme.models import User
from newsmeme.helpers import slugify, render_template
from newsmeme.forms import OpenIdSignupForm, OpenIdLoginForm
from newsmeme.extensions import oid, db

openid = Module(__name__)


@oid.after_login
def create_or_login(response):

    openid = response.identity_url

    user, authenticated = \
        User.query.authenticate_openid(response.email, openid)

    next_url = session.pop('next', None)

    if user is None:
        session['openid'] = openid

        username = response.fullname or response.nickname
Esempio n. 11
0
from __future__ import unicode_literals, division, absolute_import
from flexget.ui.webui import manager, register_plugin, app
from flexget.task import Task
from flask import render_template, request, flash, redirect, Module
import yaml
import logging
from flask.helpers import url_for

configure = Module(__name__, url_prefix='/configure')

log = logging.getLogger('ui.configure')


@configure.route('/')
def index():
    return render_template('configure/configure.html')


@configure.route('/new/<root>', methods=['POST', 'GET'])
def new_text(root):
    if root not in ['tasks', 'presets']:
        flash('Invalid root.', 'error')
        return redirect(url_for('index'))
    config_type = root.rstrip('s')
    context = {'root': root, 'config_type': config_type}
    if request.method == 'POST':
        context['config'] = request.form.get('config')
        name = request.form.get('name')
        if not name:
            flash('You must enter a name for this %s' % config_type, 'error')
        elif name in manager.config.get(root, []):
Esempio n. 12
0
# -*- coding: utf-8 -*-
from flask import Module,render_template,request,jsonify
from nuteam.controllers.filters import admin_filter
from nuteam.services import userservice, issueservice

admin = Module(__name__)
admin.before_request(admin_filter)

@admin.route('/Admin')
def index():
    return render_template('Admin/index.html')

@admin.route('/Admin/CategorySetting')
def category():
    return render_template('Admin/CategorySetting.html')

@admin.route('/QueryUser',methods=['POST'])
def query():
    mail_or_nick = request.json['Word']
    status = request.json['Status']
    page_no = request.json['PageNo']

    (row_count,page_count,page_no,page_size,data) = userservice.query_user(mail_or_nick,int(status),"RegDate desc",page_no)
    user_list = []
    for i in data.all():
        user_list.append({'UserId':i.UserId,'Email':i.Email,'Nick':i.Nick,'Status':i.Status,'IsAdmin':i.IsAdmin,'RegDate':i.RegDate.isoformat()})
    return jsonify(row_count=row_count,page_count=page_count,page_no=page_no,page_size=page_size,data=user_list)

@admin.route('/EnableUser',methods=['POST'])
def enable_user():
    userid = request.json['UserId']
Esempio n. 13
0
"""
"""
import os
import urllib, urlparse
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from .decorators import login_required, guest_or_login_required, with_lock
from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext

worksheet_listing = Module('sagenb.flask_version.worksheet_listing')


def render_worksheet_list(args, pub, username):
    """
    Returns a rendered worksheet listing.

    INPUT:

    -  ``args`` - ctx.args where ctx is the dict passed
       into a resource's render method

    -  ``pub`` - boolean, True if this is a listing of
       public worksheets

    -  ``username`` - the user whose worksheets we are
       listing

    OUTPUT:

    a string
    """
Esempio n. 14
0
import os
from flask import Module, url_for, render_template, request

from .models import get_posts, num_posts
import config

blog = Module(__name__, 'blog')


@blog.route('/')
def index():
    page_size = config.BLOG_POSTS_PR_PAGE
    total_posts = num_posts()
    page = int(request.args.get('page', 1))
    if page < 1:
        page = 1
    posts = get_posts((page - 1) * page_size, page * page_size)
    return render_template('blog/index.html', **locals())
Esempio n. 15
0
#! /usr/bin/env python
# coding:utf-8

from flask import Module, jsonify, request
from flask.views import MethodView

from core.api import API
from core.api.decorators import jsonp
from core.api.utils.RequestValidator import PaymentDataValidator

api = Module(
    __name__,
    url_prefix='/api'
)


def jsonify_status_code(*args, **kw):
    response = jsonify(*args, **kw)
    response.status_code = kw['code']
    return response


@api.route('/')
def index():
    """
    The root of the API returns an error
    """
    return jsonify_status_code(
        code=400,
        message='Room no 404: File not found. HTTP GET requests to API root are not allowed.'
    )
Esempio n. 16
0
        expires = domain = None
        if session.permanent:
            expires = datetime.utcnow() + self.permanent_session_lifetime
        if self.config['SERVER_NAME'] is not None:
            domain = '.' + self.config['SERVER_NAME']
        session.save_cookie(response, self.session_cookie_name,
                            expires=expires, httponly=False, domain=domain)

    def message(self, msg, cont='/', username=None, **kwds):
        """Returns an error message to the user."""
        template_dict = {'msg': msg, 'cont': cont, 'username': username}
        template_dict.update(kwds)
        return render_template(os.path.join('html', 'error_message.html'),
                               **template_dict)

base = Module('flask_version.base')

#############
# Main Page #
#############
@base.route('/')
def index():
    if 'username' in session:
        # If there is a next request use that.  See issue #76
        if 'next' in request.args:
            response = redirect(request.values.get('next', ''))
            return response
        response = redirect(url_for('worksheet_listing.home', username=session['username']))
        if 'remember' in request.args:
            response.set_cookie('nb_session_%s'%g.notebook.port,
                                expires=(time.time() + 60 * 60 * 24 * 14))
Esempio n. 17
0
# coding:utf-8
# Copyright 2011 Litl, LLC. All Rights Reserved.
import logging

from flask import Module, render_template, request, redirect, url_for, session, flash
from portal.models import PortalUser
from portal.forms import UserForm, NewUserForm, PasswordForm
from login import check_login

portal = Module(__name__, url_prefix='/user')

portal.before_request(check_login)

@portal.route('/all/')
def list_users():
    users = PortalUser.all()
    return render_template('user_list.html', users=users)

@portal.route('/save/', methods=['POST'])
def save_user():
    needs_password = '******' in request.form
    if needs_password:
        form = NewUserForm(request.form)
    else:
        form = UserForm(request.form)
    if form.validate():
        email = form.email.data
        if form.id.data:
            user = PortalUser.find_by_key(form.id.data)
        else:
            user = PortalUser.find_by_email(email)
Esempio n. 18
0
from flask import (Flask, request, Markup, Response, render_template,
                   make_response, Module, current_app)

NSDEF = 'xmlns:gml="http://www.opengis.net/gml" \
    xmlns:xlink="http://www.w3.org/1999/xlink" \
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
    xmlns:wtr="http://www.cuahsi.org/waterML/" \
    xmlns="http://www.cuahsi.org/waterML/1.0/"'

try:
    from flask import Blueprint
    rest = Blueprint(__name__, __name__)
except ImportError:
    rest = Module(__name__)


@rest.route('/')
def index():

    return render_template('index.html',
                           p=current_app.wof_inst.network,
                           s=current_app.wof_inst.default_site,
                           v=current_app.wof_inst.default_variable,
                           sd=current_app.wof_inst.default_start_date,
                           ed=current_app.wof_inst.default_end_date)


@rest.route('/GetSites', methods=['GET'])
def get_sites():
Esempio n. 19
0
"""
Flask Module Docs:  http://flask.pocoo.org/docs/api/#flask.Module

This file is used for both the routing and logic of your
application.
"""

from flask import Module, url_for, render_template, request, redirect,\
                  session, g, flash
from flaskext.oauth import OAuth
import models
from forms import TodoForm

views = Module(__name__, 'views')
oauth = OAuth()
twitter = oauth.remote_app(
    'twitter',
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='http://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='http://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    #authorize_url='http://api.twitter.com/oauth/authenticate',
    authorize_url='https://api.twitter.com/oauth/authorize',
    consumer_key='qbAWqQcTBtOxPqbTh5Uag',
    consumer_secret='TdKlsHpqaSzVfZircnOEoANdsylCskNsgQcvJNMqfk')
Esempio n. 20
0
__author__ = 'jmpews'

from flask import Module, request
from flask import render_template

from app.models import Proxy

from . import index_blue as index_blue
index_module = Module(__name__)


@index_blue.route('/')
def index():
    r_type = request.args.get('proxytype', 'http')
    # proxylist=Proxy.query.all()
    proxylist = Proxy.query.filter_by(type=r_type).order_by(
        Proxy.id.desc()).limit(100)
    return render_template('index.html', proxylist=proxylist)
from flask import Module, jsonify

from . import auth

consumer = Module(__name__)

consumer.test_consumer_key = None
consumer.test_consumer_user = None

@consumer.route('/token')
def generate_token():
    if not consumer.test_consumer_key:
        raise Exception, "No test_consumer_key specified."

    if not consumer.test_consumer_user:
        raise Exception, "No test_consumer_user specified."

    tokenData = auth.generate_token(
        consumer.test_consumer_key,
        consumer.test_consumer_user
    )

    return jsonify(**tokenData)
Esempio n. 22
0
# -*- coding: UTF-8 -*-
from flask import Module, render_template, jsonify, redirect, request, session, g
from src.agentconfig import *
import os
import logging
import json
from src.services.component import server
import httplib
import re
import operator
logging.basicConfig(level=logging.DEBUG)
registryV2Server = Module(__name__)


@registryV2Server.route('/')
def hello_registryV2Server():
    print dir(request)
    return 'Hello registryV2Server!'


@registryV2Server.route('/nexus/1.0/package/delete', methods=['DELETE'])
def imagesList():
    return 'Hello nexusServer_info!'
Esempio n. 23
0
from flask import Module, request, abort, render_template, current_app
from flaskcma.content.documents import Content
from flaskcma import utils


mod = Module(__name__, name="content", url_prefix="")


@mod.route("/<path>/edit/<content_type>/")
def edit_content(path, content_type="Content"):
    path = "/%s/"

    # Get the content type otherwise 404
    try:
        Document = utils.content_type(current_app, content_type)
    except KeyError:
        abort(404)

    content = Document.objects(path=path).first()

    if content is None:
        content = Document()

    Form = content.admin_form()

    if Form is None:
        abort(404)  # We can't edit this content item

    form = Form(request.forms, instance=content)

    if request.method == "post" and form.validate():
Esempio n. 24
0
# -*- coding: UTF-8 -*-

from flask import Module, render_template, jsonify, redirect, request, session, g
from testTeam.testteamconfig import *
from testTeam.services import userservice
from testTeam.models.userprofile import UserStatus

home = Module(__name__)


@home.route('/')
def index():
    if 'username' in session and not session['username'] == None:
        return redirect('/Project')
    return render_template('Login.html', title=u'登陆')


@home.route('/Login', methods=['POST'])
def login():
    email = request.json['Email']
    password = request.json['Password']
    user = userservice.get(email)
    if user == None:
        response = jsonify(isDisabled=False, isMatch=False)
        return response

    if user.Status == UserStatus.Disabled:
        response = jsonify(isDisabled=True, isMatch=None)
        return response

    if not user.Password == password:
Esempio n. 25
0
from flask import Module, abort, jsonify, request
from flask.ext.login import current_user, login_user, logout_user
from flask.views import MethodView
from flask_mail import Message
from werkzeug import secure_filename

from backend.backend.decorators import jsonp
from backend.backend.models.my_model import MyModel
from backend.backend.models.user import User


api = Module(__name__, url_prefix='/api')

def jsonify_status_code(status_code, *args, **kw):
    response = jsonify(*args, **kw)
    response.status_code = status_code
    return response

@api.route('/')
def index():
    '''
    The root of the api returns an error
    '''
    abort(404)


class MyModelAPI(MethodView):
    @jsonp
    def get(self, id=None):
        if id:
            my_model = MyModel.objects.get(id=id)
Esempio n. 26
0
from flask import Module, g, render_template

__all__ = ('commits', )

SEARCH_TERM = 'github.com/'

WINDOW_MAP = {
    'day': 'd',
    '3day': 'd3',
    'week': 'w',
    'month': 'm',
    'year': 'y',
}

topsy = Module(__name__)


@topsy.before_request
def configure_redi():
    redi.config.redis = g.r


def get_by_window(term, n, pages=3):

    for page in range(pages):

        r = otter.Resource('search')
        r(q=term, window=n, offset=page * 10)

        for link in r.response.list:
Esempio n. 27
0
# -*- coding: utf-8 -*-
from flask import Module,render_template, request, jsonify,g
from nuteam.controllers.filters import login_filter
from nuteam.services import teamservice, projectservice

team = Module(__name__)
team.before_request(login_filter)

@team.route('/Project/Team/<int:project_id>')
def list(project_id):
    p = projectservice.get(project_id)
    return render_template('Team/List.html',ProjectId=project_id,Creator =p.Creator,CurrentUser=g.user_id)

@team.route('/Team/GetMemberCandidate',methods=['POST'])
def member_candidate():
    project_id = request.json['ProjectId']
    member_list = teamservice.member_candidate(project_id)
    result = []
    for m in member_list:
        result.append({'Email':m.Email,'Nick':m.Nick})
    return jsonify(data=result)

@team.route('/Team/GetMemberInProject',methods=['POST'])
def member_in_project():
    project_id = request.json['ProjectId']
    member_list = teamservice.member_in_project(project_id)
    result = []
    for m in member_list:
        result.append({'Email':m.Email,'Nick':m.Nick,'UserId':m.UserId})
    return jsonify(data=result)
Esempio n. 28
0
# -*- coding: UTF-8 -*- 
from flask import Module,render_template,redirect,request,session,jsonify,g
from src.services import roleservice
from src.controllers.filters import login_filter

role = Module(__name__)
role.before_request(login_filter)

roleName={ 
    u"用户管理" : 0x01,
    u"课程管理" : 0x02,
    u"商品添加" : 0x04,
    u"商品查询" : 0x08
    }

@role.route('/role/permissionQury',methods=['POST'])
def queryPermission():
    key=request.json.get('id',"")
    data= []
    roleName.keys()
    for item in roleName.keys():
        role={"right":roleName[item],"wrong":0,"name":item}
        if key != "":
            if roleservice.varifyPermission(roleName[item], key):
                role['checked']=1
            else:
                role['checked']=-1
        data.append(role)
    return jsonify(got=True,data=data)

@role.route('/role/add',methods=['POST'])
Esempio n. 29
0
from google.appengine.api.users import User
from livecount.counter import PeriodType, LivecountCounter
from jsmin import jsmin
from fogbugz import FogBugz
import settings
from extensions import context_processor
from models import SchemaVersion, Style, StyleRevision, Site, Invitation, Page, PageChannel, UserSettings
from tasks import queue_import
from tasks import IMPORT_DONE, CAN_IMPORT
from proxy import get_html, check_for_tags
from count import count_view, get_period_and_count
from forms import StyleForm, InviteForm, PageForm, SiteForm
from decorators import requires_auth, requires_admin
from docs import doc_list

views = Module(__name__, 'views')

views.app_context_processor(context_processor)

def _localeselector():
    locale = UserSettings.get_locale() or session.get('locale', None)
    if locale:
        return locale
    locale = request.accept_languages.best_match([locale[0] for locale in settings.available_locales])
    if locale:
        return locale
    return 'en' # Default if we still have no match.

def _timezoneselector():
    return None
Esempio n. 30
0
# -*- coding: utf-8 -*-
from flask import Module,request,jsonify
from nuteam.controllers.filters import login_filter
import os
from nuteam.nuteamconfig import *
import uuid

upload = Module(__name__)
upload.before_request(login_filter)

@upload.route('/uploadimg',methods=['POST'])
def uploadimg():
    file = request.files['upfile']
    ext = file.filename.split('.')[-1]
    filename = str(uuid.uuid4()) + '.' + ext
    if not os.path.exists(UPLOADPATH):
        os.makedirs(UPLOADPATH)
    file.save(os.path.join(UPLOADPATH, filename))
    return jsonify(url=os.path.join(UPLOADDIR, filename))
Esempio n. 31
0
# -*- coding: UTF-8 -*- 
from flask import Module,render_template,jsonify, redirect, request,session,g
from testTeam.testteamconfig import *
from testTeam.controllers.filters import login_filter
from testTeam.services import classesservice

classes = Module(__name__)
classes.before_request(login_filter)

@classes.route('/Classes/Create',methods=['POST'])
def create():
    classname = request.json['Name']
    projects = request.json['Project']
    projects = projects if (len(projects) != 0) else []
    isexist = classesservice.isexist(classname)
    if not isexist:
        classesservice.create(classname,projects,g.user_id)
#         if len(projects) != 0:
#                 classesservice.create(classname,projects,g.user_id)
#         else:
#             classesservice.create(classname,None,g.user_id)
#     existname = classesservice.get_name()
# 
#     if not classname in existname:
#         isexist = False
#         for project in projects:
#             classesservice.create(classname,project,g.user_id)
#     else:
#         isexist = True
    return jsonify(isexist=isexist)
Esempio n. 32
0
from flask import Module,render_template,jsonify, request,g
from src.dcosconfig import *
from src.controllers.filters import login_filter
dashboard = Module(__name__)

dashboard.before_request(login_filter)

@dashboard.route('/Dashboard')
def index():
    menuList = {
        'index': {
            'main': 'active'
        },

        'template': {
            'main': '',
            'sub1': '',
            'sub2': '',
        }
    }
    return render_template('Dashboard/index.html', menu = menuList)

@dashboard.route('/template/container')
def container():
    menuList = {
        'index': {
            'main': ''
        },

        'template': {
            'main': 'active',
Esempio n. 33
0
# -*- coding: UTF-8 -*- 

from flask import Module,render_template,jsonify, request,g
from testTeam.testteamconfig import *
from testTeam.services import projectservice,teamservice
from testTeam.controllers.filters import login_filter

project = Module(__name__)
project.before_request(login_filter)

@project.route('/Project')
def index():
    return render_template('Project/List.html')

@project.route('/Project/Create',methods=['POST'])
def create():
    projectservice.create(request.json['ProjectName'],request.json['Introduction'],g.user_id)
    return jsonify(created=True)

@project.route('/Project/Query',methods=['POST'])
def query():
    page_no = request.json['PageNo']
    class_name = request.json['ClassName']
    checked_list = request.json['CheckedList']
    (data,subdata,row_count,page_count,page_no) = projectservice.query(page_no,PAGESIZE_project,'LastUpdateDate',g.user_id,class_name)
    projects = []
    for p in data.all():
        if subdata == []:
            isChecked = True if p.ProjectId in checked_list else False
            projects.append({'ProjectId':p.ProjectId,'ProjectName':p.ProjectName,'Introduction':p.Introduction,'CreateDate':p.CreateDate.isoformat(),'LastUpdateDate':p.LastUpdateDate.isoformat(),'Creator':p.UserProfile.Nick,'IsChecked':isChecked})
        else :
Esempio n. 34
0
import hashlib
import smtplib

from flask import g, Module, redirect, render_template, request, session, url_for

from flaskext.principal import Identity, identity_changed, ActionNeed
from flatland.out.markup import Generator

from cockerel.models.schema import db, User, Action
from cockerel.forms import LoginForm, SignupForm, ActivateLoginForm
from cockerel.auth.security import get_activationcode, load_identity, save_identity
from cockerel.auth.permissions import read_action
import cockerel.webapp

admin = Module(__name__)


@admin.route("/login", methods=["GET", "POST"])
def login():
    gen = Generator()
    if request.method == "POST":
        form = LoginForm.from_flat(request.form)
        if form.validate():
            user = User.query.filter_by(username=request.form["username"]).first()
            if user != None:
                if not user.activestatus:
                    form.add_error(
                        """Username %s need to be activated before 1st login.
                        It can only be activated with the link sent to email
                        of this username."""
                        % form["username"].value
Esempio n. 35
0
# -*- coding: UTF-8 -*- 
from flask import Module,render_template,jsonify, redirect, request,session,g
from testTeam.testteamconfig import *
from testTeam.services import modelservice,projectservice,teamservice
from testTeam.models.userprofile import UserStatus
from testTeam.controllers.filters import login_filter

model = Module(__name__)
model.before_request(login_filter)

@model.route('/Model/<int:project_id>')
def index(project_id):
    project = projectservice.get(project_id)
    return render_template('Model/List.html',Project = project,title = project.ProjectName, CurrentUser = g.user_id)

@model.route('/Model/Create',methods=['POST'])
def create():
    modelname = request.json["ModelName"]
    description = request.json["Description"]
    project = request.json["Project"]
    isExist = modelservice.create(modelname, description, project, g.user_id)
    return jsonify(isExist=isExist)

@model.route('/Model/Query',methods=['POST'])
def query():
    project = request.json["Project"]
    models = modelservice.query(project)
    models_dict_list = []
    for m in models:
        m_dict = {}
        m_dict.update(m.__dict__)
Esempio n. 36
0
from uuid import uuid4

from flask import Module, jsonify, request
from flask.views import MethodView

from core.api.decorators import jsonp
from core.backends.UNIX import UNIXBackend
from core.utils.RequestValidator import CreateUnikernelValidator
from ..RedisQueue import Q

from core.api import API

api = Module(
    __name__,
    url_prefix='/api'
)


def jsonify_status_code(*args, **kw):
    response = jsonify(*args, **kw)
    response.status_code = kw['code']
    return response


@api.route('/')
def index():
    """
    The root of the API returns an error
    """
    return jsonify_status_code(
        code=400,
Esempio n. 37
0
            fmt = '%s/%s'
        for ident, theme in ctx.app.theme_manager.themes.iteritems():
            res.extend((fmt % (ident, t)).encode("utf8")
                       for t in theme.jinja_loader.list_templates())
        return res


def template_exists(templatename):
    ctx = _request_ctx_stack.top
    return templatename in containable(ctx.app.jinja_env.list_templates())


### theme functionality


themes_mod = Module(__name__, name='_themes', url_prefix='/_themes')
themes_mod.jinja_loader     # prevent any of the property's methods from
                            # taking effect
themes_mod.jinja_loader = ThemeTemplateLoader(False)


if USING_BLUEPRINTS:
    themes_blueprint = Blueprint('_themes', __name__, url_prefix='/_themes')
    themes_blueprint.jinja_loader
    themes_blueprint.jinja_loader = ThemeTemplateLoader(True)


@themes_mod.route('/<themeid>/<path:filename>')
def static(themeid, filename):
    try:
        ctx = _request_ctx_stack.top
Esempio n. 38
0
from flask import Module, render_template

frontend = Module(__name__)


@frontend.route('/')
def index():
    return render_template('frontend/login.html')