2019-02-26 08:10:37 +00:00
|
|
|
"""passbook pretend GitHub Views"""
|
2020-06-07 14:35:08 +00:00
|
|
|
from django.http import HttpRequest, HttpResponse, JsonResponse
|
2019-02-26 08:10:37 +00:00
|
|
|
from django.views import View
|
|
|
|
|
2020-08-19 08:32:44 +00:00
|
|
|
from passbook.providers.oauth2.models import RefreshToken
|
2019-02-26 08:10:37 +00:00
|
|
|
|
|
|
|
|
2020-08-19 08:32:44 +00:00
|
|
|
class GitHubUserView(View):
|
2020-06-07 14:35:08 +00:00
|
|
|
"""Emulate GitHub's /user API Endpoint"""
|
|
|
|
|
2020-08-19 08:32:44 +00:00
|
|
|
def get(self, request: HttpRequest, token: RefreshToken) -> HttpResponse:
|
2019-02-26 08:10:37 +00:00
|
|
|
"""Emulate GitHub's /user API Endpoint"""
|
2020-08-19 08:32:44 +00:00
|
|
|
user = token.user
|
2019-12-31 11:51:16 +00:00
|
|
|
return JsonResponse(
|
|
|
|
{
|
|
|
|
"login": user.username,
|
|
|
|
"id": user.pk,
|
|
|
|
"node_id": "",
|
|
|
|
"avatar_url": "",
|
|
|
|
"gravatar_id": "",
|
|
|
|
"url": "",
|
|
|
|
"html_url": "",
|
|
|
|
"followers_url": "",
|
|
|
|
"following_url": "",
|
|
|
|
"gists_url": "",
|
|
|
|
"starred_url": "",
|
|
|
|
"subscriptions_url": "",
|
|
|
|
"organizations_url": "",
|
|
|
|
"repos_url": "",
|
|
|
|
"events_url": "",
|
|
|
|
"received_events_url": "",
|
|
|
|
"type": "User",
|
|
|
|
"site_admin": False,
|
|
|
|
"name": user.name,
|
|
|
|
"company": "",
|
|
|
|
"blog": "",
|
|
|
|
"location": "",
|
|
|
|
"email": user.email,
|
|
|
|
"hireable": False,
|
|
|
|
"bio": "",
|
|
|
|
"public_repos": 0,
|
|
|
|
"public_gists": 0,
|
|
|
|
"followers": 0,
|
|
|
|
"following": 0,
|
|
|
|
"created_at": user.date_joined,
|
|
|
|
"updated_at": user.date_joined,
|
|
|
|
"private_gists": 0,
|
|
|
|
"total_private_repos": 0,
|
|
|
|
"owned_private_repos": 0,
|
|
|
|
"disk_usage": 0,
|
|
|
|
"collaborators": 0,
|
|
|
|
"two_factor_authentication": True,
|
|
|
|
"plan": {
|
|
|
|
"name": "None",
|
|
|
|
"space": 0,
|
|
|
|
"private_repos": 0,
|
|
|
|
"collaborators": 0,
|
|
|
|
},
|
2019-02-26 08:10:37 +00:00
|
|
|
}
|
2019-12-31 11:51:16 +00:00
|
|
|
)
|
2020-06-07 14:35:08 +00:00
|
|
|
|
|
|
|
|
2020-08-19 08:32:44 +00:00
|
|
|
class GitHubUserTeamsView(View):
|
2020-06-07 14:35:08 +00:00
|
|
|
"""Emulate GitHub's /user/teams API Endpoint"""
|
|
|
|
|
2020-08-19 08:32:44 +00:00
|
|
|
# pylint: disable=unused-argument
|
|
|
|
def get(self, request: HttpRequest, token: RefreshToken) -> HttpResponse:
|
2020-06-07 14:35:08 +00:00
|
|
|
"""Emulate GitHub's /user/teams API Endpoint"""
|
|
|
|
return JsonResponse([], safe=False)
|