Open
Conversation
DimLight1998
commented
Nov 16, 2018
| # Create your views here. | ||
|
|
||
| # 登录 | ||
| class adminLogin(APIView): |
Author
There was a problem hiding this comment.
Class name should use PascalCase.
DimLight1998
commented
Nov 16, 2018
| def get(self): | ||
| # if self.request.user.is_authenticated(): | ||
| activity_List = [] | ||
| activites = Activity.objects.all() |
Author
There was a problem hiding this comment.
Why not use built-in objects filtering functions of django?
DimLight1998
commented
Nov 16, 2018
| ticket_List = Ticket.objects.filter(activity=activity) | ||
| bookedTickets = 0 | ||
| usedTickets = 0 | ||
| for t in ticket_List: |
Author
There was a problem hiding this comment.
Why not use built-in counting functions of django?
DimLight1998
commented
Nov 16, 2018
| raise ValidateError('Not found') | ||
| activity = activity_list[0] | ||
| if(activity.status != Activity.STATUS_PUBLISHED): | ||
| raise ValidateError("活动已截止") |
DimLight1998
commented
Nov 16, 2018
| for index in image.chunks(): | ||
| f.write(index) | ||
| f.close() | ||
| return SITE_DOMAIN + '/img/activityImage/' + image.name |
DimLight1998
commented
Nov 16, 2018
|
|
||
| allActs = Activity.objects.all() | ||
| for a in allActs: | ||
| if a not in acts: |
DimLight1998
commented
Nov 16, 2018
| 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 |
DimLight1998
commented
Nov 16, 2018
| 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: |
DimLight1998
commented
Nov 16, 2018
Author
DimLight1998
left a comment
There was a problem hiding this comment.
- No authenticating for admin.
- Use unified naming convention.
- Add
to_jsonandcreate_from_jsonmethod to models to reduce meaningless code when get information of create object. - Don't comment code when committing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.