-
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
随意填写 #62
base: master
Are you sure you want to change the base?
随意填写 #62
Conversation
|
||
# Create your views here. | ||
|
||
# 登录 | ||
class adminLogin(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.
Class name should use PascalCase.
def get(self): | ||
# if self.request.user.is_authenticated(): | ||
activity_List = [] | ||
activites = Activity.objects.all() |
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.
Why not use built-in objects filtering functions of django?
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.
Why not use built-in counting functions of django?
raise ValidateError('Not found') | ||
activity = activity_list[0] | ||
if(activity.status != Activity.STATUS_PUBLISHED): | ||
raise ValidateError("活动已截止") |
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.
Is this a ValidateError
?
for index in image.chunks(): | ||
f.write(index) | ||
f.close() | ||
return SITE_DOMAIN + '/img/activityImage/' + image.name |
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.
Use os.path.join
.
|
||
allActs = Activity.objects.all() | ||
for a in allActs: | ||
if a not in acts: |
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.
Use built-in functions.
unique_id = uuid.uuid5(uuid.NAMESPACE_DNS,self.user.student_id + activity.name + str(currentTime)) | ||
Ticket.objects.create(student_id = self.user.student_id, unique_id = unique_id, | ||
activity = activity, status = Ticket.STATUS_VALID) | ||
activity.remain_tickets -= 1 |
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.
Use lock.
@@ -52,10 +82,10 @@ def reply_text(self, content): | |||
)) | |||
|
|||
def reply_news(self, articles): | |||
if len(articles) > 10: | |||
self.logger.warn('Reply with %d articles, keep only 10', len(articles)) | |||
if len(articles) > 8: |
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.
Move 8
to a variable.
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.
- No authenticating for admin.
- Use unified naming convention.
- Add
to_json
andcreate_from_json
method to models to reduce meaningless code when get information of create object. - Don't comment code when committing.
No description provided.