예제 #1
0
파일: user.py 프로젝트: le-dawg/photobasket
def create_user_for_album(user_email, album_ident):
    db = get_db()

    # check if album exists
    cur = db.cursor()
    cur.execute("SELECT url FROM album WHERE url=?", (album_ident, ))
    albums = cur.fetchone()

    if albums is None:
        raise "Ablum not found"

    # check if user has already a key
    cur = db.cursor()
    cur.execute("SELECT key FROM users WHERE album_url=? AND email=?", (album_ident, user_email, ))
    users = cur.fetchone()

    if users is not None:
        return users[0]

    # create new user
    new_user_id = shortuuid.ShortUUID().random(length=15)
    cur = db.cursor()
    cur.execute("INSERT INTO users (album_url, email, key) VALUES (?, ?, ?)", (album_ident, user_email, new_user_id, ))
    db.commit()

    send_email(user_email, "Neuer Benutzer", "Dein Login wurde erfolgreich erstellt")

    return new_user_id
예제 #2
0
파일: user.py 프로젝트: helloworldzly/smiex
def update_temp_user_email(session, email):
    '''
        根据session更新email
        生成随机验证码,向邮箱发送验证码
        从temp_user中查找session记录,将email code 以及errtry=0 pass=0添加至其中
    '''

    from model.mongodb import MongoDB
    db = MongoDB().db
    temp_user = db.temp_user

    one = temp_user.find_one({'session':session})
    if one == None:
        return False

    from lib import generate_verify_code
    code = generate_verify_code()

    email_data = {
        'fromuser':'******',
        'touser':email,
        'subject':'X网站注册邮件验证码',
        'message':'你好,您的邮件验证码是%s,20分钟内输入有效'%code
    }

    from lib import send_email
    send_email(email_data)

    import time
    temp_user.update({'session':session},{'$set':{'email':email,'code':code,'errtry':0,'pass':0,'createtime':time.time()}})
    return True
예제 #3
0
def newuser(albumurl, userkey):
    # creates a new user for the album
    # params:
    #   useremail: email adress for the user
    
    jsonrequest = json.load(request.body)
    user_email = jsonrequest["useremail"]

    user_key = create_user_for_album(user_email, albumurl)

    db = get_db()

    # check if album exists
    cur = db.cursor()
    cur.execute("SELECT name FROM album WHERE url=?", (albumurl, ))
    albums = cur.fetchone()

    if albums is None:
        raise "Ablum not found"
    albumname = albums[0]
    
    # TODO: re-enable before live
    send_email(user_email, "You've been invited to share your memories of " + albumname + " with PhotoBasket", """Hello!

You've been invited to the album """ + albumname + """. 

With PhotoBasket, you can see your friends' photos and share your own from your phone or computer, download pictures you want to keep, and add the perfect soundtrack to your memories with SoundCloud. 
To start seeing and adding memories, follow this unique, personalized link:

""" + 'http://' + request.get_header('host') + "/album/" + albumurl + "/" + user_key + """

Just follow the link and the intuitive PhotoBasket interface will guide you through the process.

Can I share the link with others?
Your link is your unique identifier to access and add to this album on PhotoBasket, so make sure to keep it safe and don't share it -  or they might start sharing things under your name! Instead, you can add other users from the PhotoBasket album to have them sent their own personal link.

Is my data safe? Who can see my photos?
Your data will be stored on the server of your PhotoBasket host - so if you trust your friend, your data is in good hands. ;) None of it will be uploaded to third-party servers. 
Everyone who was invited to the group will be able to see and download your pictures but they will not be accessible without the correct access link.

Happy sharing!

Your friendly PhotoBasket bot""")
    
    return {
        "success": "created",
        "useremail": user_email,
        "userkey": user_key
    }
예제 #4
0
def submit_contact(title='Contact',site_name=site_name,site_author=site_author):
    email = request.forms.get('email')
    message = request.forms.get('message')
    send_email(email, message)
    navigation = get_navigation()[0]
    nav_exclude = get_navigation()[1]
    if title not in navigation:
        if title not in nav_exclude:
            title='Home'
    if request.get_cookie("authID") == str(True):
        userStatus = request.get_cookie("authID")
    else:
        userStatus = False
    page_dict = {'title':title,'navigation':navigation,'user':userStatus}
    return merge_dicts(page_dict, site_globals)
예제 #5
0
def newuser(albumurl, userkey):
    # creates a new user for the album
    # params:
    #   useremail: email adress for the user

    jsonrequest = json.load(request.body)
    user_email = jsonrequest["useremail"]

    user_key = create_user_for_album(user_email, albumurl)

    db = get_db()

    # check if album exists
    cur = db.cursor()
    cur.execute("SELECT name FROM album WHERE url=?", (albumurl, ))
    albums = cur.fetchone()

    if albums is None:
        raise "Ablum not found"
    albumname = albums[0]

    # TODO: re-enable before live
    send_email(
        user_email, "You've been invited to share your memories of " +
        albumname + " with PhotoBasket", """Hello!

You've been invited to the album """ + albumname + """. 

With PhotoBasket, you can see your friends' photos and share your own from your phone or computer, download pictures you want to keep, and add the perfect soundtrack to your memories with SoundCloud. 
To start seeing and adding memories, follow this unique, personalized link:

""" + 'http://' + request.get_header('host') + "/album/" + albumurl + "/" +
        user_key + """

Just follow the link and the intuitive PhotoBasket interface will guide you through the process.

Can I share the link with others?
Your link is your unique identifier to access and add to this album on PhotoBasket, so make sure to keep it safe and don't share it -  or they might start sharing things under your name! Instead, you can add other users from the PhotoBasket album to have them sent their own personal link.

Is my data safe? Who can see my photos?
Your data will be stored on the server of your PhotoBasket host - so if you trust your friend, your data is in good hands. ;) None of it will be uploaded to third-party servers. 
Everyone who was invited to the group will be able to see and download your pictures but they will not be accessible without the correct access link.

Happy sharing!

Your friendly PhotoBasket bot""")

    return {"success": "created", "useremail": user_email, "userkey": user_key}
예제 #6
0
파일: run.py 프로젝트: bighotguy/api_test
def run(suite):

    logging.info(
        "==============================测试开始====================================="
    )

    with open(report_file, 'wb') as f:
        HTMLTestRunner(stream=f,
                       title='Api Test',
                       description='测试描述',
                       tester='咪咪').run(suite)

    send_email(report_file)
    logging.info(
        "=============================测试结束======================================"
    )
    f.close()
예제 #7
0
def run(suite):
    logging.info(
        "================================== 测试开始 =================================="
    )
    with open(report_file, 'wb') as f:
        result = HTMLTestRunner(stream=f,
                                title='API Test',
                                description='发券接口测试',
                                tester='syr').run(suite)

    if result.failures:  # 保存失败用例的序列化文件
        save_failures(result, last_fails_file)

    if send_email_after_run:  # 是否发送邮件
        send_email(report_file)
    logging.info(
        "================================== 测试结束 =================================="
    )
예제 #8
0
파일: user.py 프로젝트: helloworldzly/smiex
def resend_verify_code(session, email):
    '''
        根据session查找temp_user里的记录
        检查记录中上次create时间与当前时间差是否超过一分钟
        重新发送验证码邮件
        更新创建时间和验证码
    '''
    from model.mongodb import MongoDB
    db = MongoDB().db
    temp_user = db.temp_user

    one = temp_user.find_one({'session':session,'email':email})
    if one == None:
        return False

    if not 'pass' in one:
        return False

    if one['pass'] == 1:
        return False

    old_createtime = one['createtime']

    import time
    now_time = time.time()

    if now_time - old_createtime < 60:
        return False

    from lib import generate_verify_code
    code = generate_verify_code()

    email_data = {
        'fromuser':'******',
        'touser':email,
        'subject':'X网站注册邮件验证码',
        'message':'你好,您的邮件验证码是%s,20分钟内输入有效'%code
    }

    from lib import send_email
    send_email(email_data)

    temp_user.update({'session':session,'email':email},{'$set':{'code':code,'errtry':0,'pass':0,'createtime':now_time}})
    return True
예제 #9
0
def error404(error):
    crash_data = {'requests': request.environ}
    other_dict = {'title':error}
    send_email(site_support, crash_data)
    return merge_dicts(crash_data, other_dict)
예제 #10
0
import unittest
from lib.HTMLTestReportCN import HTMLTestRunner
from lib.send_email import *
from config.config import *

logging.info(
    "================================== 测试开始 =================================="
)
suite = unittest.defaultTestLoader.discover(test_path)
with open(report_file, "wb") as f:
    HTMLTestRunner(stream=f, title="Api_Test", description="ceshi").run(suite)
f.close()
send_email(report_file)
logging.info(
    "================================== 测试结束 =================================="
)
예제 #11
0
# coding:UTF-8 -*-

import unittest
from config.config import *
from lib.send_email import *
from lib.HTMLTestReportCN import HTMLTestRunner

logging.info(
    "================================== 测试开始 =================================="
)

suite = unittest.defaultTestLoader.discover(test_path)

with open(report_file, "wb") as f:
    HTMLTestRunner(stream=f,
                   title="API Report",
                   description="测试详情",
                   tester="C罗").run(suite)

send_email()

logging.info(
    "================================== 测试开始 =================================="
)
예제 #12
0
def index():
    error_list = None
    # CHECK IF THE USER IS LOGGED IN, OTHERWISE REDIRECT
    if not session.get('logged_in'):
        return redirect(url_for('login'))
    # GET THE USER INFO, REDIRECT IF NOTHING IS RETURNED
    user = controls.get_user_info(session.get('username'))
    if not user:
        redirect(url_for('logout'))
    authorized_users = controls.get_authorized_users()
    # RETURNS A JSON ObJECT OF USERNAME, FIRST AND LAST
    lead = controls.get_lead(session.get('username'))
    if len(lead) == 0:
        lead = {'username': '', 'first_name': '', 'last_name': ''}
    else:
        lead = lead[0]
    notebooks = []
    if session.get('auth_token'):
        # CHECK AND SEE IF USER HAS SELECTED NOTEBOOKS
        if user['notebook_ids'] is not None and len(user['notebook_ids']) > 0:
            guid_list = user['notebook_ids'].split(',')
            flash("Getting Notebooks and Notes")
            notebooks = get_notebooks(session.get('auth_token'),
                                      session.get('shard_id'), guid_list)
        else:
            return redirect(url_for('configure', guid_list=None))
    # POST REQUESTS
    if request.method == 'POST':
        error_list = []
        note_list = request.form.getlist('note')
        # GET THE NOTE CONTENT FOR EACH NOTES GUID
        for value in note_list:
            try:
                title, guid = value.split(':')
                note = get_note(session.get('auth_token'),
                                session.get('shard_id'), guid)
            except Exception as e:
                error = "Error retrieving note using guid %s" % e
                return render_template('main.html', error=error)
            # ATTEMPT TO PARSE THE NOTE INTO A ENXML OBJECT
            # GET DOCTYPE FROM NOTE CONTENT
            rg = re.compile('(<!DOCTYPE .*?>)')
            m = rg.search(note)
            try:
                # CREATE EN OBJECT INITILIZING WITH NOTE AND DOCTYPE
                en = EN(note, doctype=m.group(1))
                # BREAK OUT TABLES
                en.break_out_tables()
                try:
                    en.set_activity_type('O')
                    en.set_activity_type('I')
                except:
                    error_list.append(
                        "Using an old Template, update your template in the future"
                    )
                    error_list.append(
                        "Unable to set Issues and Activities within the note")
                flash(
                    update_note(session.get('auth_token'),
                                session.get('shard_id'),
                                en.tostring(),
                                guid=guid,
                                title=title))
                # IF EMAIL IS SET
                if user['use_email'] == 1:
                    lib.send_email(en, app.config['EMAIL_SERVER'],
                                   user['email_address'])
                    flash("Note sent as email to %s" % user['email_address'])
                # IF LEAD IS SET
                if request.form['lead'] != 'None':
                    # GET LEAD AUTH_TOKEN
                    lead = controls.get_user_info(request.form['lead'])
                    flash(
                        new_note(shard_id=lead['shard_id'],
                                 content=en.tostring(),
                                 title=title,
                                 auth_token=lead['auth_token']))
                    flash("Sent note to lead: %s" % request.form['lead'])
                    controls.set_lead(session.get('username'),
                                      request.form['lead'])
                # CHANGE THE USERS LEAD ID TO THAT USED
                else:
                    controls.delete_lead(session.get('username'))
                    lead = {'username': '', 'first_name': '', 'last_name': ''}
                flash("Bug Time: %s" % en.times['B'])
                flash("Setup Time: %s" % en.times['S'])
                flash("Test Time: %s" % en.times['T'])
                flash("Session Length: %s" % en.session_length)
                en.export_xml(app.config['UPLOADED_FILE_DEST'],
                              "%s.xml" % title)
            except Exception as e:
                error_list.append(
                    "ERROR parsing out data from note %s. Exception: [%s]" %
                    (title, e))
    return render_template('main.html',
                           notebooks=notebooks,
                           error=error_list,
                           authorized_users=authorized_users,
                           lead=lead)
예제 #13
0
파일: run.py 프로젝트: sugber/wasui
import unittest
from config.config import *
from lib.send_email import *
from lib.HTMLTestReportCN import *

logging.info(
    "================================== 测试开始 =================================="
)

discover = unittest.defaultTestLoader.discover(testpath, pattern="testcase.py")

with open(report_file, 'wb') as f:  # 从配置文件中读取
    HTMLTestRunner(stream=f, title="warehousee Test",
                   description="测试描述").run(discover)

send_email(report_file)  # 从配置文件中读取

logging.info(
    "================================== 测试结束 =================================="
)
예제 #14
0
from test.case.user.test_user_login import TestUserLogin
from test.case.rule_test.rule_special import TestRuleSpecial
import unittest
import HTMLTestRunner
from lib.send_email import *
from config.config import *

logging.debug('=======================测试开始=======================')
# 添加测试集
suite = unittest.TestSuite()
suite.addTests([
    TestUserLogin("test_user_login_noraml"),
    TestUserLogin("test_user_login_wrong")
])
suite.addTest(TestRuleSpecial("test_rule_special_keyanshouru"))
# suite=unittest.defaultTestLoader.discover("./")
# unittest.TextTestRunner(suite)

# 发送html测试报告
fp = open(report_path, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                       title='经费监管测试报告',
                                       description='测试用例情况:')
# 执行测试用例
runner.run(suite)
fp.close()
# 发送邮件
send_email(report_path)
logging.debug('=======================测试结束=======================')
예제 #15
0
def register():
	form = request.form
	required = ['challenge_type', 'username', 'password', 'teamname', 'caption_name', 'caption_email', 'caption_organization', 'member_num']
	for item in required:
		if not item in form:
			return jsonify(res=PARAMETER_ERROR)

	challenge_type = form['challenge_type']
	username = form['username']
	password = form['password']
	teamname = form['teamname']

	if username == "" or len(password) < 6 or teamname == "":
		return jsonify(res=PARAMETER_ERROR)

	caption_name = form['caption_name']
	caption_email = form['caption_email']
	caption_organization = form['caption_organization']

	if caption_name == "" or caption_email == "" or caption_organization == "":
		return jsonify(res=PARAMETER_ERROR)

	member_num = int(form['member_num'])
	member = [{
		'name':caption_name,
		'email':caption_email,
		'organization':caption_organization
	}]
	for i in range(1, member_num):
		required = ['member%d_name'%i, 'member%d_email'%i, 'member%d_organization'%i]
		for item in required:
			if not item in form:
				return jsonify(res=PARAMETER_ERROR)

		member_name = form['member%d_name'%i]
		member_email = form['member%d_email'%i]
		member_organization = form['member%d_organization'%i]

		if member_name == "" or member_email == "" or member_organization == "":
			return jsonify(res=PARAMETER_ERROR)

		member.append({
			'name':member_name,
			'email':member_email,
			'organization':member_organization
			})

	from lib import check_team_member
	status, err, place = check_team_member(challenge_type, username, password, teamname, member)
	if status == False:
		if err == TEAM_NAME_UNAVALIABLE:
			return jsonify(res=TEAM_NAME_UNAVALIABLE)
		elif err == USER_NAME_UNAVALIABLE:
			return jsonify(res=USER_NAME_UNAVALIABLE)
		else:
			return jsonify(res=MEMBER_UNAVALIABLE, place=place)
	else:
		from lib import send_email
		import json
                msg = "Registration\n"
                for item in member:
                    msg += "%s %s %s\n"%(item['name'],item['email'],item['organization'])
		send_email("*****@*****.**", msg)
                print msg
		resp = jsonify(res=SUCCESS)
		resp.set_cookie('session', place)
		return resp
예제 #16
0
import unittest
from lib.HTMLTestRunner_PY3 import HTMLTestRunner
from lib.send_email import *
from config.config import *

logging.info("=" * 25 + "测试开始" + "=" * 25)
#suite = unittest.defaultTestLoader.discover("./") #自动取根目录下所有test开头的.py去执行
suite = unittest.defaultTestLoader.discover(testcase_path)

f = open(report_file, 'wb')  #读取配置文件中路径(不然报告会写入项目路径下)
HTMLTestRunner(stream=f, title="LT_db_unittest",
               description="添加、绑定加油卡测试报告").run(suite)

send_email(report_file)  #读取配置文件中路径
logging.info("邮件已发送")
logging.info("=" * 25 + "测试结束" + "=" * 25)
예제 #17
0
파일: views.py 프로젝트: 3-form/ENTSM
def index():
    error_list = None
    # CHECK IF THE USER IS LOGGED IN, OTHERWISE REDIRECT
    if not session.get('logged_in'):
        return redirect(url_for('login'))
    # GET THE USER INFO, REDIRECT IF NOTHING IS RETURNED
    user = controls.get_user_info(session.get('username'))
    if not user:
        redirect(url_for('logout'))
    authorized_users = controls.get_authorized_users()
    # RETURNS A JSON ObJECT OF USERNAME, FIRST AND LAST 
    lead = controls.get_lead(session.get('username'))
    if len(lead) == 0:
        lead = {'username':'', 'first_name':'', 'last_name':''}
    else:
        lead = lead[0]
    notebooks = []
    if session.get('auth_token'):
        # CHECK AND SEE IF USER HAS SELECTED NOTEBOOKS
        if user['notebook_ids'] is not None and len(user['notebook_ids']) > 0:
            guid_list = user['notebook_ids'].split(',')
            flash("Getting Notebooks and Notes")
            notebooks = get_notebooks(session.get('auth_token'), 
                                      session.get('shard_id'),
                                      guid_list) 
        else:
            return redirect(url_for('configure', guid_list=None))         
    # POST REQUESTS
    if request.method=='POST':
        error_list = []
        note_list = request.form.getlist('note')
        # GET THE NOTE CONTENT FOR EACH NOTES GUID
        for value in note_list:
            try:
                title, guid = value.split(':')
                note = get_note(session.get('auth_token'), 
                                session.get('shard_id'),
                                guid)
            except Exception as e:
                error = "Error retrieving note using guid %s" %e
                return render_template('main.html', 
                                       error=error)
            # ATTEMPT TO PARSE THE NOTE INTO A ENXML OBJECT
            # GET DOCTYPE FROM NOTE CONTENT
            rg = re.compile('(<!DOCTYPE .*?>)')
            m = rg.search(note)
            try:
                # CREATE EN OBJECT INITILIZING WITH NOTE AND DOCTYPE
                en = EN(note, doctype=m.group(1))
                # BREAK OUT TABLES
                en.break_out_tables()
                try:
                    en.set_activity_type('O')
                    en.set_activity_type('I')
                except:
                    error_list.append("Using an old Template, update your template in the future")
                    error_list.append("Unable to set Issues and Activities within the note")
                flash(update_note(session.get('auth_token'),
                                  session.get('shard_id'),
                                  en.tostring(), 
                                  guid=guid, 
                                  title=title))
                # IF EMAIL IS SET
                if user['use_email'] == 1:
                    lib.send_email(en, app.config['EMAIL_SERVER'], user['email_address'])
                    flash("Note sent as email to %s" %user['email_address'])
                # IF LEAD IS SET
                if request.form['lead'] != 'None':
                    # GET LEAD AUTH_TOKEN
                    lead = controls.get_user_info(request.form['lead'])
                    flash(new_note(shard_id=lead['shard_id'],
                                   content=en.tostring(), 
                                   title=title, 
                                   auth_token=lead['auth_token']))
                    flash("Sent note to lead: %s" %request.form['lead'])
                    controls.set_lead(session.get('username'), request.form['lead'])
                # CHANGE THE USERS LEAD ID TO THAT USED
                else: 
                    controls.delete_lead(session.get('username'))
                    lead = {'username':'', 'first_name':'', 'last_name':''}
                flash("Bug Time: %s" %en.times['B'])
                flash("Setup Time: %s" %en.times['S'])
                flash("Test Time: %s" %en.times['T'])
                flash("Session Length: %s" %en.session_length)
                en.export_xml(app.config['UPLOADED_FILE_DEST'], "%s.xml" %title)
            except Exception as e:
                error_list.append("ERROR parsing out data from note %s. Exception: [%s]" %(title, e))
    return render_template('main.html',
                            notebooks=notebooks, 
                            error=error_list,
                            authorized_users=authorized_users,
                            lead=lead)