示例#1
0
文件: views.py 项目: ZheYuan/gitshell
def email_verify(request, eid):
    usermail = GsuserManager.get_useremail_by_id(eid)
    email = usermail.email
    via = ''
    if usermail and usermail.is_verify == 0 and usermail.user_id == request.user.id:
        Mailer().send_verify_email(request.user, eid, email)
        email_suffix = email.split('@')[-1]
        if email_suffix in COMMON_EMAIL_DOMAIN:
            via = COMMON_EMAIL_DOMAIN[email_suffix]
        return json_httpResponse({'code': 200, 'message': u'请尽快验证邮箱', 'via': via})
    return json_httpResponse({'code': 500, 'message': u'邮箱不对,或者没有相关权限', 'via': via})
示例#2
0
def login_github_relieve(request):
    thirdpartyUser_find = GsuserManager.get_thirdpartyUser_by_id(
        request.user.id)
    if thirdpartyUser_find is not None:
        thirdpartyUser_find.delete()
    response_dictionary = {'code': 200, 'result': 'success'}
    return json_httpResponse(response_dictionary)
示例#3
0
文件: views.py 项目: drew-sj/gitshell
def add_scene(request, env_scene_id):
    scene_id = 0
    name = request.POST.get('name', '').strip()
    if name != '':
        scene_id = ToDoListManager.add_scene(request.user.id, name)
    response_dictionary = {'scene_id': scene_id, 'name': name}
    return json_httpResponse(response_dictionary)
示例#4
0
文件: views.py 项目: drew-sj/gitshell
def update_scene_meta(request, env_scene_id):
    scene = get_scene(request.user.id, env_scene_id)
    todo_str_ids = request.POST.get('todo_ids', '')
    todo_ids = [int(x) for x in todo_str_ids.split(',')]
    result = ToDoListManager.update_scene_meta(request.user.id, scene.id, todo_ids)
    response_dictionary = {'result': result}
    return json_httpResponse(response_dictionary)
示例#5
0
def change(request):
    thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
    user = None
    is_user_exist = True
    is_exist_repo = False
    username = request.POST.get('username')
    if username is not None and re.match(
            "^[a-zA-Z0-9_-]+$", username
    ) and username != request.user.username and username not in MAIN_NAVS and not username.startswith(
            '-'):
        repo_count = RepoManager.count_repo_by_userId(request.user.id)
        if repo_count > 0:
            return json_httpResponse({'is_exist_repo': True})
        user = GsuserManager.get_user_by_name(username)
        if user is None:
            request.user.username = username
            request.userprofile.username = username
            request.user.save()
            request.userprofile.save()
            for repo in RepoManager.list_repo_by_userId(
                    request.user.id, 0, 100):
                repo.username = username
                repo.save()
            is_user_exist = False
    goto = ''
    email = request.POST.get('email')
    if email is not None and email_re.match(email):
        user = GsuserManager.get_user_by_email(email)
        if user is None:
            Mailer().send_change_email(request.user, email)
            email_suffix = email.split('@')[-1]
            if email_suffix in COMMON_EMAIL_DOMAIN:
                goto = COMMON_EMAIL_DOMAIN[email_suffix]
            is_user_exist = False
    if thirdpartyUser is not None:
        thirdpartyUser.init = 1
        thirdpartyUser.save()
    if username == request.user.username:
        is_user_exist = False
    response_dictionary = {
        'is_exist_repo': is_exist_repo,
        'is_user_exist': is_user_exist,
        'goto': goto,
        'new_username': username,
        'new_email': email
    }
    return json_httpResponse(response_dictionary)
示例#6
0
文件: views.py 项目: drew-sj/gitshell
def add_todo(request, env_scene_id):
    scene = get_scene(request.user.id, env_scene_id)
    todo_text = request.POST.get('todo_text', '').strip()
    todo_id = 0
    if todo_text != '':
        todo_id = ToDoListManager.add_todo(request.user.id, scene.id, todo_text)
    response_dictionary = {'todo_id': todo_id}
    return json_httpResponse(response_dictionary)
示例#7
0
文件: views.py 项目: drew-sj/gitshell
def email_verify(request, eid):
    usermail = GsuserManager.get_useremail_by_id(eid)
    email = usermail.email
    via = ''
    if usermail and usermail.is_verify == 0 and usermail.user_id == request.user.id:
        Mailer().send_verify_email(request.user, eid, email)
        email_suffix = email.split('@')[-1]
        if email_suffix in COMMON_EMAIL_DOMAIN:
            via = COMMON_EMAIL_DOMAIN[email_suffix]
        return json_httpResponse({
            'code': 200,
            'message': u'请尽快验证邮箱',
            'via': via
        })
    return json_httpResponse({
        'code': 500,
        'message': u'邮箱不对,或者没有相关权限',
        'via': via
    })
示例#8
0
文件: views.py 项目: drew-sj/gitshell
def feed_by_ids(request):
    ids_str = request.POST.get('ids_str', '')
    feeds = []
    if re.match('^\w+$', ids_str):
        feeds = _list_feeds(request, ids_str)
    _fillwith_push_revref(request, feeds)
    _fillwith_commit_message(request, feeds)
    _fillwith_issue_event(request, feeds)
    _fillwith_pull_event(request, feeds)
    relative_obj_not_none_feeds = [
        x for x in feeds if x.relative_obj is not None
    ]
    response_dictionary = {'feeds': relative_obj_not_none_feeds}
    return json_httpResponse(response_dictionary)
示例#9
0
文件: views.py 项目: ZheYuan/gitshell
def change(request):
    thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
    user = None
    is_user_exist = True
    is_exist_repo = False
    username = request.POST.get('username')
    if username is not None and re.match("^[a-zA-Z0-9_-]+$", username) and username != request.user.username and username not in MAIN_NAVS and not username.startswith('-'):
        repo_count = RepoManager.count_repo_by_userId(request.user.id)
        if repo_count > 0:
            return json_httpResponse({'is_exist_repo': True})
        user = GsuserManager.get_user_by_name(username)
        if user is None:
            request.user.username = username
            request.userprofile.username = username
            request.user.save()
            request.userprofile.save()
            for repo in RepoManager.list_repo_by_userId(request.user.id, 0, 100):
                repo.username = username
                repo.save()
            is_user_exist = False
    goto = ''
    email = request.POST.get('email')
    if email is not None and email_re.match(email):
        user = GsuserManager.get_user_by_email(email)
        if user is None:
            Mailer().send_change_email(request.user, email)
            email_suffix = email.split('@')[-1]
            if email_suffix in COMMON_EMAIL_DOMAIN:
                goto = COMMON_EMAIL_DOMAIN[email_suffix]
            is_user_exist = False
    if thirdpartyUser is not None:
        thirdpartyUser.init = 1
        thirdpartyUser.save()
    if username == request.user.username:
        is_user_exist = False
    response_dictionary = { 'is_exist_repo': is_exist_repo, 'is_user_exist': is_user_exist, 'goto': goto, 'new_username': username, 'new_email': email }
    return json_httpResponse(response_dictionary)
示例#10
0
文件: views.py 项目: ZheYuan/gitshell
def find(request):
    user = None
    is_user_exist = False
    username = request.POST.get('username')
    if username is not None:
        if username in MAIN_NAVS:
            is_user_exist = True
        user = GsuserManager.get_user_by_name(username)
    email = request.POST.get('email')
    if email is not None:
        user = GsuserManager.get_user_by_email(email)
    if user is not None:
        is_user_exist = True
    response_dictionary = { 'is_user_exist': is_user_exist }
    return json_httpResponse(response_dictionary)
示例#11
0
def find(request):
    user = None
    is_user_exist = False
    username = request.POST.get('username')
    if username is not None:
        if username in MAIN_NAVS:
            is_user_exist = True
        user = GsuserManager.get_user_by_name(username)
    email = request.POST.get('email')
    if email is not None:
        user = GsuserManager.get_user_by_email(email)
    if user is not None:
        is_user_exist = True
    response_dictionary = {'is_user_exist': is_user_exist}
    return json_httpResponse(response_dictionary)
示例#12
0
文件: views.py 项目: drew-sj/gitshell
def done_todo(request, env_scene_id):
    todo_id = int(request.POST.get('todo_id', '0'))
    result_todo_id = ToDoListManager.done_todo(request.user.id, todo_id)
    response_dictionary = {'todo_id': result_todo_id}
    return json_httpResponse(response_dictionary)
示例#13
0
def _json_ok():
    return json_httpResponse({'result': 'ok'})
示例#14
0
文件: views.py 项目: ZheYuan/gitshell
def _json_ok():
    return json_httpResponse({'result': 'ok'})
示例#15
0
文件: views.py 项目: drew-sj/gitshell
def remove_scene(request, env_scene_id):
    scene_id = ToDoListManager.remove_scene(request.user.id, env_scene_id)
    response_dictionary = {'scene_id': scene_id}
    return json_httpResponse(response_dictionary)
示例#16
0
文件: views.py 项目: ZheYuan/gitshell
def _json_failed():
    return json_httpResponse({'result': 'failed'})
示例#17
0
文件: views.py 项目: ZheYuan/gitshell
def login_github_relieve(request):
    thirdpartyUser_find = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
    if thirdpartyUser_find is not None:
        thirdpartyUser_find.delete()
    response_dictionary = {'code': 200, 'result': 'success'}
    return json_httpResponse(response_dictionary)
示例#18
0
def _json_failed():
    return json_httpResponse({'result': 'failed'})