Esempio n. 1
0
def _q_index(request):
    errors = []
    user = request.user
    githubs = user.githubs
    if request.method == "POST":
        user_name = request.get_form_var('github')
        errors = CodeDoubanUserGithub.validate(user.name, user_name)
        if not errors:
            CodeDoubanUserGithub.add(user.name, user_name)
            return request.redirect('/settings/github')
    return st('/settings/github.html', **locals())
Esempio n. 2
0
def _q_lookup(request, github_id):
    if request.get_form_var('_method') == 'delete':
        user = request.user
        github = CodeDoubanUserGithub.check_own_by_user(user.name, github_id)
        if github:
            github.delete()
        return request.redirect('/settings/github')
Esempio n. 3
0
 def test_get_by_user_name(self):
     g1 = CodeDoubanUserGithub.add('testu1', 'testug1')
     g2 = CodeDoubanUserGithub.add('testu2', 'testug2')
     g3 = CodeDoubanUserGithub.get_by_user_name('testug2')
     assert g3.user_id == 'testu2'
Esempio n. 4
0
 def test_add_github(self):
     github = CodeDoubanUserGithub.add('testu', 'testug')
     assert github.user_name == 'testug'
     assert github.user_id == 'testu'
Esempio n. 5
0
 def test_simple_github(self):
     github = CodeDoubanUserGithub(-1, 'testu', 'testug')
     assert github.user_name == 'testug'
     assert github.user_id == 'testu'
Esempio n. 6
0
 def test_get_by_user_name(self):
     g1 = CodeDoubanUserGithub.add('testu1', 'testug1')
     g2 = CodeDoubanUserGithub.add('testu2', 'testug2')
     g3 = CodeDoubanUserGithub.get_by_user_name('testug2')
     assert g3.user_id == 'testu2'
Esempio n. 7
0
 def test_add_github(self):
     github = CodeDoubanUserGithub.add('testu', 'testug')
     assert github.user_name == 'testug'
     assert github.user_id == 'testu'