-
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
xtypullrequest #65
base: master
Are you sure you want to change the base?
xtypullrequest #65
Conversation
class activityList(APIView): | ||
#获取活动列表 | ||
def get(self): | ||
# if self.request.user.is_authenticated(): |
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 activity_List | ||
# else: | ||
# raise ValidateError('Please login!') | ||
|
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.
作者将活动列表内的post接口额外写到了activityDelete类中。
activity = Activity.objects.get(id__exact = id) | ||
except: | ||
raise ValidateError("ID does not exit!") | ||
if activity: |
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.
此处条件判断与上面的try/except重复,没有必要。
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.book_end = self.input['bookEnd'] | ||
activity.total_tickets = self.input['totalTickets'] | ||
activity.status = self.input['status'] | ||
|
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.
以上修改未考虑活动时间限制条件。
整个项目关于登录状态的判断都被注释掉了,没有实现登录状态判断;测试通过后冗余的代码应该删除,不要以注释的方式保留在代码中;admin部分查找活动和票调用的都是get()函数,但get只返回第一个符合条件的对象,有几处需要找到所有符合条件的对象的地方应该用filter()函数。 |
No description provided.