Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

dddddd #75

wants to merge 1 commit into from

Conversation

xsuler
Copy link

@xsuler 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']
Copy link
Author

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!")
Copy link
Author

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:
Copy link
Author

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()
Copy link
Author

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)
Copy link
Author

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()
Copy link
Author

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):
Copy link
Author

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):
Copy link
Author

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):
Copy link
Author

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:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该为<=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant