Beispiel #1
0
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})
Beispiel #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)
Beispiel #3
0
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)
Beispiel #4
0
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)
Beispiel #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)
Beispiel #6
0
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)
Beispiel #7
0
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
    })
Beispiel #8
0
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)
Beispiel #9
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)
Beispiel #10
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)
Beispiel #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)
Beispiel #12
0
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)
Beispiel #13
0
def _json_ok():
    return json_httpResponse({'result': 'ok'})
Beispiel #14
0
def _json_ok():
    return json_httpResponse({'result': 'ok'})
Beispiel #15
0
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)
Beispiel #16
0
def _json_failed():
    return json_httpResponse({'result': 'failed'})
Beispiel #17
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)
Beispiel #18
0
def _json_failed():
    return json_httpResponse({'result': 'failed'})