-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dddddd #75
base: master
Are you sure you want to change the base?
dddddd #75
Conversation
book_start = self.input['bookStart'] | ||
book_end = self.input['bookEnd'] | ||
total_tickets = self.input['totalTickets'] | ||
remain_tickets = self.input['totalTickets'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total_tickets和remain_tickets的类型为int,类型不匹配
f.close() | ||
return SITE_DOMAIN + '/img/activityImage/' + image.name | ||
except: | ||
raise ValidateError("Fail to upload image!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
错误类型不该为ValidateError
ticket_List = Ticket.objects.filter(activity=activity) | ||
bookedTickets = 0 | ||
usedTickets = 0 | ||
for t in ticket_List: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
求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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有问题,应该用int(time.time())得出
self.check_input('id') | ||
id = self.input['id'] | ||
try: | ||
activity = Activity.objects.get(id=id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有对activity是否存在作出异常检测
以及活动状态为Activity.STATUS_DELETED时应该抛出异常
activity.total_tickets = self.input['totalTickets'] | ||
activity.status = self.input['status'] | ||
|
||
activity.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对已发布的活动没有进行修改限制,对结束后的活动,抢票开始的活动也没有进行修改限制
raise ValidateError("Fail to logout!") | ||
|
||
#活动列表 | ||
class activityList(APIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有进行管理员权限验证
# raise ValidateError('Please login!') | ||
|
||
#删除活动 | ||
class activityDelete(APIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有进行管理员权限验证
# raise ValidateError('Please login!') | ||
|
||
#上传图像并保存到服务器 | ||
class imageUpload(APIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有进行管理员权限验证
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该为<=0
异常处理错误种类单一,函数体过长,功能没有分开