Skip to content

Conversation

787809089
Copy link

No description provided.

class activityList(APIView):
#获取活动列表
def get(self):
# if self.request.user.is_authenticated():
Copy link
Author

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!')

Copy link
Author

@787809089 787809089 Nov 16, 2018

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

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

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']

Copy link
Author

Choose a reason for hiding this comment

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

以上修改未考虑活动时间限制条件。

@787809089
Copy link
Author

787809089 commented Nov 16, 2018

整个项目关于登录状态的判断都被注释掉了,没有实现登录状态判断;测试通过后冗余的代码应该删除,不要以注释的方式保留在代码中;admin部分查找活动和票调用的都是get()函数,但get只返回第一个符合条件的对象,有几处需要找到所有符合条件的对象的地方应该用filter()函数。

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