Open
Conversation
xsuler
commented
Nov 16, 2018
| book_start = self.input['bookStart'] | ||
| book_end = self.input['bookEnd'] | ||
| total_tickets = self.input['totalTickets'] | ||
| remain_tickets = self.input['totalTickets'] |
Author
There was a problem hiding this comment.
total_tickets和remain_tickets的类型为int,类型不匹配
| f.close() | ||
| return SITE_DOMAIN + '/img/activityImage/' + image.name | ||
| except: | ||
| raise ValidateError("Fail to upload image!") |
| ticket_List = Ticket.objects.filter(activity=activity) | ||
| bookedTickets = 0 | ||
| usedTickets = 0 | ||
| for t in ticket_List: |
Author
There was a problem hiding this comment.
求bookedTickets应该通过activity.total_tickets - activity.remain_tickets得出
求usedTickets最好用数据库Query 语句得出
| detail['picUrl'] = activity.pic_url | ||
| detail['bookedTickets'] = bookedTickets | ||
| detail['usedTickets'] = usedTickets | ||
| detail['currentTime'] = datetime.datetime.now().timestamp() |
| self.check_input('id') | ||
| id = self.input['id'] | ||
| try: | ||
| activity = Activity.objects.get(id=id) |
Author
There was a problem hiding this comment.
没有对activity是否存在作出异常检测
以及活动状态为Activity.STATUS_DELETED时应该抛出异常
| activity.total_tickets = self.input['totalTickets'] | ||
| activity.status = self.input['status'] | ||
|
|
||
| activity.save() |
Author
There was a problem hiding this comment.
对已发布的活动没有进行修改限制,对结束后的活动,抢票开始的活动也没有进行修改限制
| raise ValidateError("Fail to logout!") | ||
|
|
||
| #活动列表 | ||
| class activityList(APIView): |
| # raise ValidateError('Please login!') | ||
|
|
||
| #删除活动 | ||
| class activityDelete(APIView): |
| # raise ValidateError('Please login!') | ||
|
|
||
| #上传图像并保存到服务器 | ||
| class imageUpload(APIView): |
| return self.reply_text('一个人只能抢一张票哦 ^口..口^') | ||
| if Ticket.objects.filter(student_id = self.user.student_id, activity = activity, status = Ticket.STATUS_USED): | ||
| return self.reply_text('您已经抢过该活动的票且使用过') | ||
| if activity.remain_tickets == 0: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
异常处理错误种类单一,函数体过长,功能没有分开