-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# @name: api/repo.py | ||
# @create: Apr. 22th, 2014 | ||
# @update: Aug. 22th, 2014 | ||
# @update: Aug. 27th, 2014 | ||
# @author: [email protected] | ||
from __future__ import print_function | ||
import re | ||
|
@@ -12,6 +12,7 @@ | |
from oauth.protector import authenticated | ||
from scm.git import GitRepo | ||
from models.repo import Repo | ||
from models.team import Team | ||
|
||
_SUB_FILTER = { | ||
'password': False, | ||
|
@@ -33,12 +34,6 @@ class RepoHandler(BaseHandler): | |
|
||
@authenticated(scopes=['repos']) | ||
def get(self, *args, **kwargs): | ||
# /repos | ||
# /repos/:path | ||
# /repos?username= | ||
# /repos?team= | ||
# /repos?project= | ||
# /repos?tag= | ||
if 'user' not in kwargs: | ||
self.raise401() | ||
user = kwargs['user'] | ||
|
@@ -63,15 +58,18 @@ def get(self, *args, **kwargs): | |
self.raise404() | ||
repo_data = document_to_json(repo, filter_set=_FILTER) | ||
else: | ||
username = self.get_argument('username', None) | ||
team = self.get_argument('team_name', None) | ||
project = self.get_argument('project_name', None) | ||
if username: | ||
pass | ||
elif team: | ||
pass | ||
elif project: | ||
pass | ||
team_name = self.get_argument('team_name', None) | ||
try: | ||
team_name = parse_path(team_name)[0] | ||
except IndexError: | ||
team_name = None | ||
if team_name: | ||
team = Team.objects(name=team_name).first() | ||
if not team: | ||
self.raise404() | ||
if user not in team.member: | ||
self.raise403() | ||
repos = Repo.objects(team=team).all() | ||
else: | ||
repos = Repo.objects(owner=user).all() | ||
repo_data = query_to_json(repos, filter_set=_FILTER) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# @name: api/project.py | ||
# @create: Jun. 10th, 2014 | ||
# @update: Aug. 23th, 2014 | ||
# @update: Aug. 27th, 2014 | ||
# @author: [email protected] | ||
from __future__ import print_function | ||
from utils import get_utc_time | ||
|
@@ -47,13 +47,6 @@ class TaskHandler(BaseHandler): | |
|
||
@authenticated(scopes=['tasks']) | ||
def get(self, *args, **kwargs): | ||
# 1, all tasks in your projects | ||
# 2, all user's tasks | ||
# 3, specified task (id) | ||
# /tasks | ||
# /tasks/:id | ||
# /tasks/?project= | ||
# /tasks/?username= | ||
if 'user' not in kwargs: | ||
self.raise401() | ||
|
||
|
@@ -68,27 +61,18 @@ def get(self, *args, **kwargs): | |
self.raise401() | ||
task_data = document_to_json(task, filter_set=_FILTER) | ||
else: | ||
username = self.get_argument('username', None) | ||
project_name = self.get_argument('project', None) | ||
try: | ||
project_name = parse_path(project_name)[0] | ||
except IndexError: | ||
project_name = None | ||
try: | ||
username = parse_path(username)[0] | ||
except IndexError: | ||
username = None | ||
if project_name and username: | ||
user = User.objects(username=username).first() | ||
project = Project.objects(name=project_name).first() | ||
tasks = Task.objects( | ||
project=project, assign_to__in=[user]).all() | ||
elif project_name: | ||
if project_name: | ||
project = Project.objects(name=project_name).first() | ||
if not project: | ||
self.raise404() | ||
if user not in project.members: | ||
self.raise403() | ||
tasks = Task.objects(project=project).all() | ||
elif username: | ||
user = User.objects(username=username).first() | ||
tasks = Task.objects(assign_to__in=[user]).all() | ||
else: | ||
projects = Project.objects(members__in=[user]).all() | ||
tasks = [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# @name: api/user.py | ||
# @create: Apr. 27th, 2014 | ||
# @update: Aug. 22th, 2014 | ||
# @update: Aug. 27th, 2014 | ||
# @author: [email protected] | ||
from __future__ import print_function | ||
from utils import parse_path, create_password | ||
|