Example #1
0
def list_bitcasa_files(base64="/"):
    bitcasa_utils = BitcasaUtils()
    client = bitcasa_utils.create_client()
    if not client:
        redirect("../auth")
    else:
        if not base64:
            base64 = "/"
        try:
            folder = client.get_folder(base64)
        except BitcasaException as e:
            if bitcasa_utils.test_auth():
                auth_name="View Files"
                auth_url="/bitcasafilelister/files/"
                msg = "You access token is stored locally. To retrieve base64 paths click view files below"
            else:
                auth_name="Login"
                auth_url="/bitcasafilelister/auth/"
                msg = "Your authentication token is either invalid or not set. Please set one by logging in. After authentication, you will also be able to view your files"

            return template("bitcasafilelister", is_error=True, error_msg=e,
                        auth_url=auth_url, authorization_code="",
                        auth_name=auth_name, msg=msg)
        parent_path = folder.path[:folder.path.rfind('/')]
        if not parent_path:
            parent_path = "/"
        download_url = "https://developer.api.bitcasa.com/v1/files/"
        return template("fileslist", folder=folder, access_token=client.access_token,
                        parent_path=parent_path, download_url=download_url, BitcasaFile=BitcasaFile)
Example #2
0
File: pur.py Project: Cloudef/PUR
def user_account(user=None):
    '''user account page'''
    # pylint: disable=too-many-branches

    if USER['name'] != user:
        abort(403)

    def gather_errors():
        '''validate edit'''
        errors = []
        jsstr = js_translations('register')
        email = request.forms.get('email')
        password1 = request.forms.get('password')
        password2 = request.forms.get('password_confirm')

        if password1 != password2:
            errors.append(jsstr['password_confirm'])
        if not email or not re.match(r'[^@]+@[^@]+\.[^@]+', email):
            errors.append(jsstr['email'])

        if not errors:
            if password1:
                ret = USERMANAGER.get_user(user, SESSION['sessionid'], (password1, SESSION['CSRF']), email)
            else:
                ret = USERMANAGER.get_user(user, SESSION['sessionid'], email=email)
            if not ret:
                errors.append(_('Database error: Failed to create user into database'))
            if password1:
                logout()

        return errors

    if request.method == 'POST':
        errors = gather_errors()
        if not errors:
            if is_json_request():
                return status_json_ok()
            return redirect('/user/{}/edit'.format(user))
        else:
            if is_json_request():
                return dump_json({'status': 'fail', 'errors': errors})
            return template('useredit', errors=errors)

    if is_json_request():
        sessions = []
        key_filter = ['CSRF', 'valid']
        for sid in USER.get('sessions'):
            data = SESSIONMANAGER.get_session(sid)
            if not data:
                continue
            for key in key_filter:
                if key in data:
                    del data[key]
            sessions.append(data)
        return dump_json({'sessions': sessions})
    return template('useredit', errors=[])
Example #3
0
def report():
    username = request.forms.get('username')
    password =  request.forms.get('password')
    res =login(username)
    if res and password == res[2] :
        menulist =getmenulist(res[0])
        
        return template('main',dict(mlist = menulist,uname= res[1],domain=SITE_DOMAIN))
    else :
        return template('index',dict(res=False,domain=SITE_DOMAIN))
Example #4
0
def grade(number=None):
    if not users.is_current_user_admin():
        q = lib.db.q("SELECT * FROM Page WHERE grade = :1 AND published = True ORDER BY timestamp DESC", number)
        #q = lib.db.Page.all()
        result = [[p.url, p.title] for p in q.run()]
        output = template('templates/index', rows=result, users=users)
    else:
        q = lib.db.q("SELECT * FROM Page WHERE grade = :1 ORDER BY timestamp DESC", number)
        #result = lib.db.q("SELECT * FROM Page")
        result = [[p.url, p.title, p.published] for p in q.run()]
        output = template('templates/admin', rows=result, users=users, todo=None, grade=True)
    return output
Example #5
0
def report():
    username = request.forms.get('username')
    password =  request.forms.get('password')
    if not username and not password:
        return index()
    password = dest(password)
    res =login(username)
    if res and password == res[2] :
        menulist =getmenulist(res[0])
        menutype = getmenutype()
        return template('main',dict(mlist = menulist,uname= res[1],domain=SITE_DOMAIN,menutype=menutype))
    else :
        return template('login',dict(res=False,domain=SITE_DOMAIN))
Example #6
0
def index():
    if not users.is_current_user_admin():
        q = lib.db.q("SELECT * FROM Page WHERE published = True ORDER BY timestamp DESC")
        #q = lib.db.Page.all()
        result = [[p.url, p.title] for p in q.run()]
        output = template('templates/index', rows=result, users=users)
    else:
        #result = lib.db.q("SELECT * FROM Page")
        q = lib.db.Page.all()
        q.order('-timestamp')
        todo = lib.db.Todo.all()
        result = [[p.url, p.title, p.published] for p in q.run()]
        output = template('templates/admin', rows=result, users=users, todo=todo)
    return output
Example #7
0
def popular():
    cursor = get_cursor()
    desc = "Topics with the most links:"
    cursor.execute(
        "select count(1) as links, topic_name from link group by topic_name order by links desc"
    )
    return template('index', topics=cursor.fetchall(), desc=desc)
Example #8
0
def topular():
    cursor = get_cursor()
    desc = "Topics with the most votes:"
    cursor.execute(
        "select count(1) as votes, link_topic from link_vote group by link_topic order by votes desc"
    )
    return template('index', topics=cursor.fetchall(), desc=desc)
Example #9
0
def post_page_users():

    # This post script will delete the selected users from the database on the users page.

    # Request the selections the user has made in the HTML form.
    form_data = request.forms.getall('chkBox')
    submit_action = request.forms.getall('submit_btn')

    # Check if the user has clicked the 'create' button. If so, show create_user template where the user can create new users.
    if 'create' in submit_action:
        response.status = 303
        response.set_header('Location', '/create_user')

    # If none of the above, the user wants to delete the selected rules.
    elif 'remove' in submit_action:
        # If the checkboxes are empty (no user input), do nothing.
        if len(form_data) == 0:
            response.status = 303
            response.set_header('Location', '/users')

        for item in form_data:
            conn = sqlite3.connect(config["paths"]["file_auth_database"])
            c = conn.cursor()
            c.execute("DELETE FROM secure_login WHERE ID = ?", (item,))
            conn.commit()
            c.close()

        # Redirect back to the same page.
        return template('users', url=url, config=config, notification='User deleted successfully.')

    else:
        response.status = 303
        response.set_header('Location', '/users')
Example #10
0
def edit_post(name):
    if request.POST.get('publish','').strip():
        publish = True
    else:
        publish = False
    if request.POST.get('save','').strip() or publish:
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = request.POST.get('url', '').strip()

        q = lib.db.Page.gql("WHERE url = :1", name)
        p = q.get()
        lib.db.d(p)

        try:
            grade = int(request.POST.get('grade', '').strip())
        except:
            grade = None
        url = lib.db.getUrlString()
        lib.db.Page(title=title, grade=grade, content=data, url=url, published=publish, timestamp=today()).put()

        if not publish:
            message =  '<p>The draft has been saved.</p>' 
        else:
            message =  '<p>The page was published.</p>'

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
Example #11
0
def gotoindexsetting():
    moduleid = request.query.get('moduleid')
    if not moduleid :
        moduleid = 1
    settings = db.query_list('select * from gkgp_main_setting where module=%s',(moduleid))

    return template('main/main_list',dict(moduledict=moduledict,domain=SITE_DOMAIN,index_settings=settings),selectmodule=moduleid,itemdict=itemdict)
Example #12
0
def map():
    API_KEY = "TOow97ALT8euMLEjnd34wajjXB6AqiYL"

    try:
        lat = request.query.lat
        longi = request.query.long
        ville = request.query.ref

        urlParams = {
            'key': 'TOow97ALT8euMLEjnd34wajjXB6AqiYL',
            'locations': lat + ", " + longi + "||" + ville +
            ", france|marker-lg-D51A1A-A20000",
            'size': '600,400@2x'
        }
        url = "https://beta.mapquestapi.com/staticmap/v5/map?" + urlencode(
            urlParams)

        #url objectif : "https://beta.mapquestapi.com/staticmap/v5/map?key=TOow97ALT8euMLEjnd34wajjXB6AqiYL&locations="+lat+",%20"+longi+"||"+ville+",%20france|marker-lg-D51A1A-A20000&size=600,400@2x"

        proxy_host = 'proxyetu.iut-nantes.univ-nantes.prive:3128'
        requ = req.Request(url)
        requ.set_proxy(proxy_host, 'http')
        response = req.urlopen(requ)

        img = open("src/IHM/img/img.jpg", "wb")
        img.write(response.read())
        img.close()

        output = template('src/IHM/img.tpl')
        return output
    except Exception as err:
        print("Unexpected error: {0}".format(err))
        return ("clé périmée ou erreur encodage requête")
Example #13
0
def index():
    cursor = get_cursor()
    desc = "Topics with the most subscribers:"
    cursor.execute(
        'select count(1) as subscribers, topic_name from subscribes group by topic_name order by subscribers desc limit 20;'
    )
    return template('index', topics=cursor.fetchall(), desc=desc)
Example #14
0
def comments(topic, link_id):
  cursor = get_cursor()
  cursor.execute("select address, headline, description, user_email, topic_name from link where id='"+link_id+"' and topic_name='"+topic+"'")
  link = cursor.fetchall()
  cursor.execute("select user_email, contents, id from comment where link_topic='"+topic+"' and link_address='"+str(link[0][0])+"'")
  comments = cursor.fetchall()
  comments = render_comments(comments, 0)
  return template('comments', link=link[0], comments=comments)
Example #15
0
 def logout(self):
     accepted = request.query.accepted or 0
     if accepted:
         self.user = None
         response.delete_cookie('session_id')
         return template('login_result', user=None)
     else:
         return dict(user=self.user)
Example #16
0
File: pur.py Project: Cloudef/PUR
def search_recipes_query():
    '''redirect query syntaxed search to pretty syntax search'''
    if is_json_request():
        abort(400, _('use /search/<query> instead'))
    query = request.query.get('q')
    if not query:
        return template('recipes', user=None, results=[])
    return redirect('/search/{}'.format(query))
Example #17
0
 def change_password(self):
     self._check_cookie()
     success = request.query.success or 0
     if str(success) == '1':
         return template('change_password', user=self.user, success=True)
     else:
         if self.user: return dict(user=self.user, success=False)
         else: abort(401, 'You are not authorised')
Example #18
0
def topic(topic):
    cursor = get_cursor()
    cursor.execute(
        "select sum(score) as score, link_address, headline, id from link left join link_vote on (address = link_address) where link_topic='"
        + topic +
        "' group by id, link_address, link.headline order by score desc")
    links = cursor.fetchall()
    return template('topic', topic=topic, links=links)
Example #19
0
File: pur.py Project: Cloudef/PUR
def standards_page():
    '''standards page'''
    recipes = RECIPEMANAGER.query_recipes('ORDER BY datemodify DESC LIMIT 10')
    num_recipes = RECIPEMANAGER.get_recipe_count()
    num_users = USERMANAGER.get_user_count()
    num_contributors = USERMANAGER.query_users_count('WHERE level >= ?', (LEVELS['contributor'],))
    num_moderators = USERMANAGER.query_users_count('WHERE level >= ?', (LEVELS['moderator'],))
    return template('standards', recipes=recipes, num_recipes=num_recipes, num_users=num_users, num_moderators=num_moderators, num_contributors=num_contributors)
Example #20
0
def post_create_user():

    # This post script will create a new user in the database or modify an existing one.

    # Request the selections the user has made in the HTML form.
    submit_action = request.forms.getall('submit_btn')

    if 'create' in submit_action:
        # Get the user details from the registration form.
        new_username = request.forms.get('new_uname')
        new_password = request.forms.get('new_passwd')
        new_password_check = request.forms.get('new_passwd_check')

        # Some serverside checks on the user input for the required fields to protect the server from invalid input.
        if len(new_username) == 0:
            return template('create_user', url=url, config=config, notification='The username field is required.')
        if len(new_password) == 0:
            return template('create_user', url=url, config=config, notification='The password field is required.')
        if new_password != new_password_check:
            return template('create_user', url=url, config=config, notification='Password mismatch.')

        # Hash the password.
        hash = sha512_crypt.encrypt(new_password)

        # Generate unique session ID.
        session_start_time = str(datetime.datetime.now())
        secret = sha512_crypt.encrypt(session_start_time)

        # Connect to the database.
        conn = sqlite3.connect(config["paths"]["file_auth_database"])
        c = conn.cursor()

        # Save new user in the database.
        c.execute("INSERT INTO `secure_login`(`ID`,`Username`,`Password`) VALUES (?,?,?)", (None, new_username, hash))
        conn.commit()
        c.close()

        # Redirect.
        response.status = 303
        response.set_header('Location', '/users')

    else:
        # Redirect.
        response.status = 303
        response.set_header('Location', '/users')
Example #21
0
def view_rrd_list():
    # Returns HTML of rrd list and urls
    rrds = [{'filename': filename,
             'info': app.get_url('rrd-info', filename=filename),
             'fetch': app.get_url('rrd-fetch', filename=filename),
             'graph': app.get_url('rrd-graph', filename=filename),
             'igraph': app.get_url('rrd-igraph', filename=filename)}
                 for filename in sorted(rrd_list().get('files')) or []]
    return bottle.template('views/rrd-list', rrds=rrds)
Example #22
0
def new_post():
    if request.POST.get('save','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        lib.db.Todo(title=title, content=data, open=True).put()

        message =  '<p>The new task was inserted into the database</p>'

        return template('templates/simple.tpl', body=message)
Example #23
0
def system_page(project=None, branch=None, system=None):
    '''got branch delete request from client'''
    validate_build(project, branch, system)
    data = get_build_data(project, branch, system, 'current')
    if not data:
        abort(404, 'Builds for system not found')
    if is_json_request():
        return dump_json(clean_build_json(data))
    admin = True if request.environ.get('REMOTE_ADDR') == '127.0.0.1' else False
    return template('build', admin=admin, build=data, standalone=True)
Example #24
0
File: pur.py Project: Cloudef/PUR
def index_page(header=None, content=None):
    '''main page with information'''
    if is_json_request():
        return dump_json({'CSRF': SESSION['CSRF']})
    recipes = RECIPEMANAGER.query_recipes('ORDER BY datemodify DESC LIMIT 10')
    num_recipes = RECIPEMANAGER.get_recipe_count()
    num_users = USERMANAGER.get_user_count()
    num_contributors = USERMANAGER.query_users_count('WHERE level >= ?', (LEVELS['contributor'],))
    num_moderators = USERMANAGER.query_users_count('WHERE level >= ?', (LEVELS['moderator'],))
    return template('index', header=header, content=content, recipes=recipes, num_recipes=num_recipes, num_users=num_users, num_moderators=num_moderators, num_contributors=num_contributors)
Example #25
0
def index():
    data = dict(
        events=get_events(),
        weather_data=get_weather_data(),
        menu_img_url=get_menu_url(),
        today=datetime.datetime.now(),
        news=get_news(),
    )

    return template("index.tpl", title="index", **data)
Example #26
0
def view(name):
    q = lib.db.Page.gql("WHERE url = :1", name)
    p = q.get()
    if not p:
        p = Object()
        p.title = "Unknown Page"
        p.content = "This page does not exist."
    title = p.title
    content = addLineBreaks(p.content)
    return template('templates/view_page.tpl', title=title, body=content)
Example #27
0
def show__page_install():

    # This page should only be viewed if there is no user database.
    if os.path.isfile(config["paths"]["file_auth_database"]):
        # Userdatabase is found!
        # Kick user away from page.
        response.status = 303
        response.set_header('Location', '/logout')
    else:
        return template('install')
Example #28
0
def handle_github(project, branch, system, fsdate, metadata):
    '''handle github posthook for build'''
    github = metadata['github']

    if 'issueid' not in github:
        github['issueid'] = None

    failed = failure_for_metadata(metadata)

    if not github or (not failed and not github['issueid']):
        return # nothing to do

    build = get_build_data(project, branch, system, fsdate, get_history=False, in_metadata=metadata)
    for idx in range(len(build['url'])):
        build['url'][idx] = absolute_link(build['url'][idx][1:])
    build['systemimage'] = absolute_link(build['systemimage'][1:])

    subject = template('github_issue', build=build, subject=True)
    body = template('github_issue', build=build, subject=False)
    github['issueid'] = github_issue(github['user'], github['repo'], subject, body, github['issueid'], not failed)
Example #29
0
def index():
    '''main page with information of all builds'''
    if is_json_request():
        projects = get_projects()
        for project in projects:
            del project['date']
            for build in project['builds']:
                clean_build_json(build)
        return dump_json(projects)
    admin = True if request.environ.get('REMOTE_ADDR') == '127.0.0.1' else False
    return template('projects', admin=admin, projects=get_projects())
Example #30
0
def edit(name):
    q = lib.db.Page.gql("WHERE url = :1", name)
    p = q.get()
    if not p:
        p = Object()
        p.title = ""
        p.content = ""
    title = p.title
    content = p.content
    #lib.db.d(p)
    return template('templates/edit_preview.tpl', name=name, body=content, url=name, title=title, data=addLineBreaks(content))
Example #31
0
def todo_post():
    if request.POST.get('save','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        lib.db.Todo(title=title, content=data, creator=users.User(), open=True, timestamp=today()).put()

        todo = lib.db.Todo.all()
        todo.order('-timestamp')
        message =  '<p style="background: yellow;">The new task was inserted into the database</p>'

        return template('templates/todo.tpl', solo=True, todo=todo, message=message)
Example #32
0
def edit_post(name):
    if request.POST.get('save','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = request.POST.get('url', '').strip()

        q = lib.db.Page.gql("WHERE url = :1", name)
        p = q.get()
        lib.db.d(p)

        if url == name:
            message = '<p>The ID %s was successfully updated</p>' % (url)
            #lib.db.q('UPDATE Page SET url = ?, data = ? WHERE url = :1', url)
        else:
            message =  '<p>The new task was inserted into the database, the ID is %s</p>' % (url)
            #lib.db.Page(title=title, content=data, url=url).put()

        lib.db.Page(title=title, content=data, url=url, published=False, timestamp=today()).put()

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
    elif request.POST.get('publish','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = request.POST.get('url', '').strip()

        q = lib.db.Page.gql("WHERE url = :1", name)
        p = q.get()
        lib.db.d(p)

        if url == name:
            message = '<p>The ID %s was successfully updated</p>' % (url)
            #lib.db.q('UPDATE Page SET url = ?, data = ? WHERE url = :1', url)
        else:
            message =  '<p>The new task was inserted into the database, the ID is %s</p>' % (url)
            #lib.db.Page(title=title, content=data, url=url).put()

        lib.db.Page(title=title, content=data, url=url, published=True, timestamp=today()).put()

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
Example #33
0
def installation():
    db = sqlite3.connect('test.db')
    c = db.cursor()
    c.execute("SELECT numero, nom from activite order by nom asc;")
    data = c.fetchall()
    c.execute("SELECT DISTINCT ville from installation order by ville asc;")
    databis = c.fetchall()
    c.close()

    liste = [data, databis]
    output = template('src/IHM/Interface.tpl', rows=liste)
    return output
Example #34
0
def show(name):
    if not users.is_current_user_admin():
        pass
    q = lib.db.Page.gql("WHERE url = :1", name)
    p = q.get()
    if not p:
        p = Object()
        p.title = "Unknown Page"
        p.content = "This page does not exist."
    title = p.title
    content = addLineBreaks(p.content)
    return template('templates/show_page.tpl', title=title, body=content)
Example #35
0
def comments(topic, link_id):
    cursor = get_cursor()
    cursor.execute(
        "select address, headline, description, user_email, topic_name from link where id='"
        + link_id + "' and topic_name='" + topic + "'")
    link = cursor.fetchall()
    cursor.execute(
        "select user_email, contents, id from comment where link_topic='" +
        topic + "' and link_address='" + str(link[0][0]) + "'")
    comments = cursor.fetchall()
    comments = render_comments(comments, 0)
    return template('comments', link=link[0], comments=comments)
Example #36
0
File: pur.py Project: Cloudef/PUR
def search_recipes(query=None):
    '''search recipes'''
    if is_json_request():
        return dump_json(RECIPEMANAGER.query_recipes('WHERE pkgname MATCH ? ORDER BY pkgname', (query,)))
    results, matches, pages, options = search(RECIPEMANAGER.query_recipes, RECIPEMANAGER.query_recipes_count, 'WHERE pkgname MATCH ?', (query,))
    if len(results) == 1:
        return redirect('/recipe/{}'.format(results[0]['pkgname']))
    elif not results:
        users = USERMANAGER.query_users('WHERE name MATCH ? LIMIT 1', (query,))
        if users:
            return redirect('/user/{}/recipes'.format(users[0]['name']))
    return template('results', title=_('Search'), user=None, results=results, pages=pages, matches=matches, options=options)
Example #37
0
File: pur.py Project: Cloudef/PUR
def recipes_page():
    '''recipes page'''
    if is_json_request():
        cachepath = 'userdata/cache/recipes.json'
        if not os.path.exists(cachepath) or os.path.getmtime(cachepath) < RECIPEMANAGER.modified():
            with open(cachepath, 'w') as fle:
                import json
                recipes = RECIPEMANAGER.query_recipes('ORDER BY pkgname')
                fle.write(json.dumps(recipes))
        return static_file('recipes.json', 'userdata/cache')
    results, matches, pages, options = search(RECIPEMANAGER.query_recipes, RECIPEMANAGER.query_recipes_count)
    return template('results', title=_('Recipes'), user=None, results=results, pages=pages, matches=matches, options=options)
Example #38
0
File: pur.py Project: Cloudef/PUR
def login():
    '''login page'''
    # pylint: disable=too-many-return-statements

    if USER:
        if is_json_request():
            return status_json_ok()
        return redirect('/')

    # regenerate CSRF token
    if request.method == 'GET':
        # pylint: disable=global-statement
        global SESSION
        SESSION = session.regenerate_csrf(SESSIONMANAGER)

    def gather_errors():
        '''validate login'''
        username = request.forms.get('username')
        password = request.forms.get('password')
        if not USERMANAGER.test_password(username, password):
            return [_('Invalid username or password')]
        return []

    if request.method == 'POST':
        errors = gather_errors()
        if not errors:
            SESSION['valid'] = True
            SESSION['name'] = request.forms.get('username')
            SESSIONMANAGER.regenerate_session(SESSION)
            if is_json_request():
                return status_json_ok()
            return redirect('/')
        else:
            if is_json_request():
                return dump_json({'status': 'fail', 'errors': errors})
            return template('login', errors=errors)

    if is_json_request():
        return abort(400, _('username and password fields missing as POST request'))
    return template('login', errors=[])
Example #39
0
def reg():
    userdata=dict(domain=SITE_DOMAIN,uerr="",nerr="",perr="",verr="",ref="")
    username = request.forms.get('username')
    password =  request.forms.get('password')
    nickname = request.forms.get('nickname')
    varifycode = request.forms.get('varifycode')
    ref = request.forms.get('ref')
    sessionCode = getValInCookie(VREYCODE)
    delValFromCookie(VREYCODE)
    if(username.strip()==""):
        userdata['uerr']="邮箱不能为空!"
        return template('reg',userdata)

    if(not utils.ProcessMail(username)):
        userdata['uerr']="邮箱格式不正确!"
        return template('reg',userdata)

    if(getUserByUsername(username)!=None):
        userdata['uerr']="该邮箱已经存在!"
        return template('reg',userdata)

    if(len(password)<4 or len(password)>20):
        userdata['perr']="密码的长度在4-20之间!"
        return template('reg',userdata)

    if(getUserByNickname(nickname)!=None):
        userdata['nerr']="昵称已经存在!"
        return template('reg',userdata)

    if(varifycode.strip()==""):
        userdata['verr']="验证码不能为空!"
        return template('reg',userdata)

    if(varifycode.upper()!=sessionCode.upper()):
        userdata['verr']="验证码输入不一致!"
        return template('reg',userdata)


    sql = '''insert into gkgp_user
    ( username,    password,
	nickname,
	create_time,
	last_login_time
	)
	values
	(%s,%s,%s,%s,%s)
    '''
    try:
        uid = dbsetting.update(sql,(username,utils.dest(password),nickname,datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
        print "uid is %d" % uid
        addUidInCookie(uid)
    except Exception,e:
        print e
Example #40
0
File: pur.py Project: Cloudef/PUR
def recipe_revision_page(pkgname=None, revision=None):
    '''recipe revision page'''
    if revision:
        recipe = RECIPEMANAGER.get_revision(pkgname, revision)
    else:
        recipe = RECIPEMANAGER.get_recipe(pkgname)
    if not recipe:
        abort(404)
    comments = RECIPEMANAGER.query_comments('WHERE pkgname = ? AND revision = ?', (pkgname, recipe['revision']))
    if is_json_request():
        del recipe['recipedir']
        recipe['comments'] = comments
        return dump_json(recipe)
    return template('recipe', recipe=recipe, comments=comments)
Example #41
0
 def do_login(self):
     username = request.forms.get('username')
     password = request.forms.get('password')
     session_id = self.db_engine.validate_user(username, password)
     if session_id:
         self.user = username
         response.set_cookie(
             'session_id',
             session_id,
             expires=datetime.now() +
             timedelta(days=int(self.web_settings['session_expire_days'])))
     else:
         self.user = None
     return template('login_result', user=self.user)
Example #42
0
def recherche():
    try:
        ville = request.query.ville
        sport = request.query.sport

        db = sqlite3.connect('test.db')
        c = db.cursor()
        if (ville != "all" and sport != "all"):
            c.execute(
                "SELECT e.nom, i.nom, i.adresse, i.code_postal, i.ville, i.latitude, i.longitude from installation i, equipement e, equipement_activite ea, activite a where i.numero=e.numero_installation and e.numero=ea.numero_equipement and ea.numero_activite=a.numero and a.numero=\""
                + sport + "\" and i.ville=\"" + ville + "\";")
            output = template('src/IHM/resultat.tpl', rows=c)

        if (ville == "all" and sport != "all"):
            c.execute(
                "SELECT e.nom, i.nom, i.adresse, i.code_postal, i.ville, i.latitude, i.longitude from installation i, equipement e, equipement_activite ea, activite a where i.numero=e.numero_installation and e.numero=ea.numero_equipement and ea.numero_activite=a.numero and a.numero=\""
                + sport + "\";")
            output = template('src/IHM/resultat.tpl', rows=c)

        if (ville != "all" and sport == "all"):
            c.execute(
                "SELECT a.nom, e.nom, i.nom, i.adresse, i.code_postal, i.ville, i.latitude, i.longitude from installation i, equipement e, equipement_activite ea, activite a where i.numero=e.numero_installation and e.numero=ea.numero_equipement and ea.numero_activite=a.numero and i.ville=\""
                + ville + "\";")
            output = template('src/IHM/resultatSP.tpl', rows=c)

        if (ville == "all" and sport == "all"):
            c.execute(
                "SELECT a.nom, e.nom, i.nom, i.adresse, i.code_postal, i.ville, i.latitude, i.longitude from installation i, equipement e, equipement_activite ea, activite a where i.numero=e.numero_installation and e.numero=ea.numero_equipement and ea.numero_activite=a.numero;"
            )
            output = template('src/IHM/resultatSP.tpl', rows=c)

        c.close()
        return output

    except Exception as err:
        print("Unexpected error: {0}".format(err))
        return ("erreur bd corrompu")
Example #43
0
 def index():
     self.manager.update_servicesinfos()
     action = 'STOP' if self.running else 'START'
     services = {
         s.name: {
             'enabled': s.config['enabled'],
             'infos': s.infos
         }
         for s in self.manager.services.values()
     }
     return bottle.template('data/theme/remote.tpl',
                            action=action,
                            services=services,
                            refresh=int(
                                self.manager.config['base']['reload']))
Example #44
0
def index():
    all_lists = get_all_list_names()

    return template("index.tpl", title="index", lists=sorted(all_lists))
Example #45
0
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)
Example #46
0
def index():
    output.warning("Webpanel access from %s" % request.remote_addr,
                   "WEBSERVER")
    return template('index.html')
Example #47
0
def list_view(name):
    validate_list(name)

    list_contents = get_list(name)

    return template("list.tpl", list_name=name, list_contents=list_contents)
Example #48
0
def login():
    if verify(request.cookies.auth):
        return redirect('/')
    return template('login.html')
Example #49
0
def index(id):
    return template('Message ID: {{id}}', id=id)