{"action":"created","comment":{"url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/comments/233698518","pull_request_review_id":175174259,"id":233698518,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMzY5ODUxOA==","diff_hunk":"@@ -1,3 +1,272 @@\n from django.shortcuts import render\n-\n+from codex.baseerror import *\n+from codex.baseview import APIView\n+from django.contrib.auth.models import User\n+from django.contrib.auth import authenticate, login, logout\n+from wechat.models import Activity\n+from wechat.models import Ticket\n+from wechat.views import CustomWeChatView\n+from WeChatTicket.settings import SITE_DOMAIN\n+import time\n+from datetime import datetime, timedelta\n # Create your views here.\n+\n+\n+class Login(APIView):\n+\n+    def get(self):\n+        if not self.request.user.is_authenticated():\n+            raise ValidateError('User not logged in')\n+        return 0\n+\n+    def post(self):\n+        self.check_input('username', 'password')\n+        username = self.input['username']\n+        password = self.input['password']\n+        user = authenticate(username=username, password=password)\n+\n+        if not username:\n+            raise ValidateError('Username is empty！')\n+        if not password:\n+            raise ValidateError('Password is empty！')\n+        if not User.objects.filter(username=username):\n+            raise ValidateError('Username does not exist！')\n+        if not user:\n+            raise ValidateError('Wrong password！')\n+\n+        if user.is_active:\n+            login(self.request, user)\n+            return 0\n+\n+\n+class Logout(APIView):\n+\n+    def post(self):\n+        if self.request.user.is_authenticated():\n+            logout(self.request)\n+        else:\n+            raise ValidateError('Logout failed！User has not logged in.')\n+\n+\n+class ActivityList(APIView):\n+\n+    def get(self):\n+        if not self.request.user.is_authenticated():\n+            raise ValidateError('User not logged in！')\n+\n+        activityList = Activity.objects.all()\n+        data = []\n+        for item in activityList:\n+            if item.status >= 0:\n+                temp = {\n+                    'id': item.id,\n+                    'name': item.name,\n+                    'description': item.description,\n+                    'startTime': int(time.mktime(item.start_time.timetuple())),\n+                    'endTime': int(time.mktime(item.end_time.timetuple())),\n+                    'place': item.place,\n+                    'bookStart': int(time.mktime(item.book_start.timetuple())),\n+                    'bookEnd': int(time.mktime(item.book_end.timetuple())),\n+                    'currentTime': int(time.time()),\n+                    'status': item.status,\n+                }\n+                data.append(temp)\n+            else:\n+                continue\n+        return data\n+\n+\n+class ActivityDelete(APIView):\n+\n+    def post(self):\n+        self.check_input('id')\n+        activity = Activity.get_by_id(self.input['id'])","path":"adminpage/views.py","position":84,"original_position":84,"commit_id":"1f18b53130068037a3ce633df8daf1b2d083e6c3","original_commit_id":"1f18b53130068037a3ce633df8daf1b2d083e6c3","user":{"login":"Imalne","id":40898021,"node_id":"MDQ6VXNlcjQwODk4MDIx","avatar_url":"https://avatars2.githubusercontent.com/u/40898021?v=4","gravatar_id":"","url":"https://api.github.com/users/Imalne","html_url":"https://github.com/Imalne","followers_url":"https://api.github.com/users/Imalne/followers","following_url":"https://api.github.com/users/Imalne/following{/other_user}","gists_url":"https://api.github.com/users/Imalne/gists{/gist_id}","starred_url":"https://api.github.com/users/Imalne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Imalne/subscriptions","organizations_url":"https://api.github.com/users/Imalne/orgs","repos_url":"https://api.github.com/users/Imalne/repos","events_url":"https://api.github.com/users/Imalne/events{/privacy}","received_events_url":"https://api.github.com/users/Imalne/received_events","type":"User","site_admin":false},"body":"get如果查找失败会报错，没有做错误处理，就算未处理，空元素也不存在delete属性","created_at":"2018-11-15T03:03:02Z","updated_at":"2018-11-15T03:03:02Z","html_url":"https://github.com/Imalne/WeChatTicket/pull/1#discussion_r233698518","pull_request_url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/comments/233698518"},"html":{"href":"https://github.com/Imalne/WeChatTicket/pull/1#discussion_r233698518"},"pull_request":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1","id":231051249,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMDUxMjQ5","html_url":"https://github.com/Imalne/WeChatTicket/pull/1","diff_url":"https://github.com/Imalne/WeChatTicket/pull/1.diff","patch_url":"https://github.com/Imalne/WeChatTicket/pull/1.patch","issue_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues/1","number":1,"state":"open","locked":false,"title":"Test","user":{"login":"Imalne","id":40898021,"node_id":"MDQ6VXNlcjQwODk4MDIx","avatar_url":"https://avatars2.githubusercontent.com/u/40898021?v=4","gravatar_id":"","url":"https://api.github.com/users/Imalne","html_url":"https://github.com/Imalne","followers_url":"https://api.github.com/users/Imalne/followers","following_url":"https://api.github.com/users/Imalne/following{/other_user}","gists_url":"https://api.github.com/users/Imalne/gists{/gist_id}","starred_url":"https://api.github.com/users/Imalne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Imalne/subscriptions","organizations_url":"https://api.github.com/users/Imalne/orgs","repos_url":"https://api.github.com/users/Imalne/repos","events_url":"https://api.github.com/users/Imalne/events{/privacy}","received_events_url":"https://api.github.com/users/Imalne/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-15T02:51:08Z","updated_at":"2018-11-15T03:03:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e09293ba54f60bc3b04ef489d29d07ac78654d4d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues/1/comments","statuses_url":"https://api.github.com/repos/Imalne/WeChatTicket/statuses/1f18b53130068037a3ce633df8daf1b2d083e6c3","head":{"label":"Imalne:dev-bob","ref":"dev-bob","sha":"1f18b53130068037a3ce633df8daf1b2d083e6c3","user":{"login":"Imalne","id":40898021,"node_id":"MDQ6VXNlcjQwODk4MDIx","avatar_url":"https://avatars2.githubusercontent.com/u/40898021?v=4","gravatar_id":"","url":"https://api.github.com/users/Imalne","html_url":"https://github.com/Imalne","followers_url":"https://api.github.com/users/Imalne/followers","following_url":"https://api.github.com/users/Imalne/following{/other_user}","gists_url":"https://api.github.com/users/Imalne/gists{/gist_id}","starred_url":"https://api.github.com/users/Imalne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Imalne/subscriptions","organizations_url":"https://api.github.com/users/Imalne/orgs","repos_url":"https://api.github.com/users/Imalne/repos","events_url":"https://api.github.com/users/Imalne/events{/privacy}","received_events_url":"https://api.github.com/users/Imalne/received_events","type":"User","site_admin":false},"repo":{"id":157642473,"node_id":"MDEwOlJlcG9zaXRvcnkxNTc2NDI0NzM=","name":"WeChatTicket","full_name":"Imalne/WeChatTicket","private":false,"owner":{"login":"Imalne","id":40898021,"node_id":"MDQ6VXNlcjQwODk4MDIx","avatar_url":"https://avatars2.githubusercontent.com/u/40898021?v=4","gravatar_id":"","url":"https://api.github.com/users/Imalne","html_url":"https://github.com/Imalne","followers_url":"https://api.github.com/users/Imalne/followers","following_url":"https://api.github.com/users/Imalne/following{/other_user}","gists_url":"https://api.github.com/users/Imalne/gists{/gist_id}","starred_url":"https://api.github.com/users/Imalne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Imalne/subscriptions","organizations_url":"https://api.github.com/users/Imalne/orgs","repos_url":"https://api.github.com/users/Imalne/repos","events_url":"https://api.github.com/users/Imalne/events{/privacy}","received_events_url":"https://api.github.com/users/Imalne/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Imalne/WeChatTicket","description":"Ticket management system based on WeChat public platform.","fork":true,"url":"https://api.github.com/repos/Imalne/WeChatTicket","forks_url":"https://api.github.com/repos/Imalne/WeChatTicket/forks","keys_url":"https://api.github.com/repos/Imalne/WeChatTicket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Imalne/WeChatTicket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Imalne/WeChatTicket/teams","hooks_url":"https://api.github.com/repos/Imalne/WeChatTicket/hooks","issue_events_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues/events{/number}","events_url":"https://api.github.com/repos/Imalne/WeChatTicket/events","assignees_url":"https://api.github.com/repos/Imalne/WeChatTicket/assignees{/user}","branches_url":"https://api.github.com/repos/Imalne/WeChatTicket/branches{/branch}","tags_url":"https://api.github.com/repos/Imalne/WeChatTicket/tags","blobs_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/refs{/sha}","trees_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Imalne/WeChatTicket/statuses/{sha}","languages_url":"https://api.github.com/repos/Imalne/WeChatTicket/languages","stargazers_url":"https://api.github.com/repos/Imalne/WeChatTicket/stargazers","contributors_url":"https://api.github.com/repos/Imalne/WeChatTicket/contributors","subscribers_url":"https://api.github.com/repos/Imalne/WeChatTicket/subscribers","subscription_url":"https://api.github.com/repos/Imalne/WeChatTicket/subscription","commits_url":"https://api.github.com/repos/Imalne/WeChatTicket/commits{/sha}","git_commits_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/commits{/sha}","comments_url":"https://api.github.com/repos/Imalne/WeChatTicket/comments{/number}","issue_comment_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues/comments{/number}","contents_url":"https://api.github.com/repos/Imalne/WeChatTicket/contents/{+path}","compare_url":"https://api.github.com/repos/Imalne/WeChatTicket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Imalne/WeChatTicket/merges","archive_url":"https://api.github.com/repos/Imalne/WeChatTicket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Imalne/WeChatTicket/downloads","issues_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues{/number}","pulls_url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls{/number}","milestones_url":"https://api.github.com/repos/Imalne/WeChatTicket/milestones{/number}","notifications_url":"https://api.github.com/repos/Imalne/WeChatTicket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Imalne/WeChatTicket/labels{/name}","releases_url":"https://api.github.com/repos/Imalne/WeChatTicket/releases{/id}","deployments_url":"https://api.github.com/repos/Imalne/WeChatTicket/deployments","created_at":"2018-11-15T02:47:26Z","updated_at":"2018-11-15T02:47:28Z","pushed_at":"2018-11-15T02:51:09Z","git_url":"git://github.com/Imalne/WeChatTicket.git","ssh_url":"git@github.com:Imalne/WeChatTicket.git","clone_url":"https://github.com/Imalne/WeChatTicket.git","svn_url":"https://github.com/Imalne/WeChatTicket","homepage":null,"size":919,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Imalne:master","ref":"master","sha":"b723ca6a3fb32737b344c4d9ada3f101de26b16d","user":{"login":"Imalne","id":40898021,"node_id":"MDQ6VXNlcjQwODk4MDIx","avatar_url":"https://avatars2.githubusercontent.com/u/40898021?v=4","gravatar_id":"","url":"https://api.github.com/users/Imalne","html_url":"https://github.com/Imalne","followers_url":"https://api.github.com/users/Imalne/followers","following_url":"https://api.github.com/users/Imalne/following{/other_user}","gists_url":"https://api.github.com/users/Imalne/gists{/gist_id}","starred_url":"https://api.github.com/users/Imalne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Imalne/subscriptions","organizations_url":"https://api.github.com/users/Imalne/orgs","repos_url":"https://api.github.com/users/Imalne/repos","events_url":"https://api.github.com/users/Imalne/events{/privacy}","received_events_url":"https://api.github.com/users/Imalne/received_events","type":"User","site_admin":false},"repo":{"id":157642473,"node_id":"MDEwOlJlcG9zaXRvcnkxNTc2NDI0NzM=","name":"WeChatTicket","full_name":"Imalne/WeChatTicket","private":false,"owner":{"login":"Imalne","id":40898021,"node_id":"MDQ6VXNlcjQwODk4MDIx","avatar_url":"https://avatars2.githubusercontent.com/u/40898021?v=4","gravatar_id":"","url":"https://api.github.com/users/Imalne","html_url":"https://github.com/Imalne","followers_url":"https://api.github.com/users/Imalne/followers","following_url":"https://api.github.com/users/Imalne/following{/other_user}","gists_url":"https://api.github.com/users/Imalne/gists{/gist_id}","starred_url":"https://api.github.com/users/Imalne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Imalne/subscriptions","organizations_url":"https://api.github.com/users/Imalne/orgs","repos_url":"https://api.github.com/users/Imalne/repos","events_url":"https://api.github.com/users/Imalne/events{/privacy}","received_events_url":"https://api.github.com/users/Imalne/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Imalne/WeChatTicket","description":"Ticket management system based on WeChat public platform.","fork":true,"url":"https://api.github.com/repos/Imalne/WeChatTicket","forks_url":"https://api.github.com/repos/Imalne/WeChatTicket/forks","keys_url":"https://api.github.com/repos/Imalne/WeChatTicket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Imalne/WeChatTicket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Imalne/WeChatTicket/teams","hooks_url":"https://api.github.com/repos/Imalne/WeChatTicket/hooks","issue_events_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues/events{/number}","events_url":"https://api.github.com/repos/Imalne/WeChatTicket/events","assignees_url":"https://api.github.com/repos/Imalne/WeChatTicket/assignees{/user}","branches_url":"https://api.github.com/repos/Imalne/WeChatTicket/branches{/branch}","tags_url":"https://api.github.com/repos/Imalne/WeChatTicket/tags","blobs_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/refs{/sha}","trees_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Imalne/WeChatTicket/statuses/{sha}","languages_url":"https://api.github.com/repos/Imalne/WeChatTicket/languages","stargazers_url":"https://api.github.com/repos/Imalne/WeChatTicket/stargazers","contributors_url":"https://api.github.com/repos/Imalne/WeChatTicket/contributors","subscribers_url":"https://api.github.com/repos/Imalne/WeChatTicket/subscribers","subscription_url":"https://api.github.com/repos/Imalne/WeChatTicket/subscription","commits_url":"https://api.github.com/repos/Imalne/WeChatTicket/commits{/sha}","git_commits_url":"https://api.github.com/repos/Imalne/WeChatTicket/git/commits{/sha}","comments_url":"https://api.github.com/repos/Imalne/WeChatTicket/comments{/number}","issue_comment_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues/comments{/number}","contents_url":"https://api.github.com/repos/Imalne/WeChatTicket/contents/{+path}","compare_url":"https://api.github.com/repos/Imalne/WeChatTicket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Imalne/WeChatTicket/merges","archive_url":"https://api.github.com/repos/Imalne/WeChatTicket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Imalne/WeChatTicket/downloads","issues_url":"https://api.github.com/repos/Imalne/WeChatTicket/issues{/number}","pulls_url":"https://api.github.com/repos/Imalne/WeChatTicket/pulls{/number}","milestones_url":"https://api.github.com/repos/Imalne/WeChatTicket/milestones{/number}","notifications_url":"https://api.github.com/repos/Imalne/WeChatTicket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Imalne/WeChatTicket/labels{/name}","releases_url":"https://api.github.com/repos/Imalne/WeChatTicket/releases{/id}","deployments_url":"https://api.github.com/repos/Imalne/WeChatTicket/deployments","created_at":"2018-11-15T02:47:26Z","updated_at":"2018-11-15T02:47:28Z","pushed_at":"2018-11-15T02:51:09Z","git_url":"git://github.com/Imalne/WeChatTicket.git","ssh_url":"git@github.com:Imalne/WeChatTicket.git","clone_url":"https://github.com/Imalne/WeChatTicket.git","svn_url":"https://github.com/Imalne/WeChatTicket","homepage":null,"size":919,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1"},"html":{"href":"https://github.com/Imalne/WeChatTicket/pull/1"},"issue":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/issues/1"},"comments":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Imalne/WeChatTicket/statuses/1f18b53130068037a3ce633df8daf1b2d083e6c3"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Imalne"}}