Open
Conversation
chenyijie2016
commented
Nov 16, 2018
| @@ -1,3 +1,7 @@ | |||
| from django.contrib import admin | |||
| from wechat.models import * | |||
chenyijie2016
commented
Nov 16, 2018
| from django.shortcuts import render | ||
| from django.contrib import auth | ||
| from django.utils import timezone | ||
| from codex.baseerror import * |
chenyijie2016
commented
Nov 16, 2018
| # else: | ||
| # raise ValidateError('Please login!') | ||
|
|
||
| #创建活动 |
chenyijie2016
commented
Nov 16, 2018
| # else: | ||
| # raise ValidateError('Please login!') | ||
|
|
||
| #删除活动 |
chenyijie2016
commented
Nov 16, 2018
| # else: | ||
| # raise ValidateError('Please login!') | ||
|
|
||
| #上传图像并保存到服务器 |
chenyijie2016
commented
Nov 16, 2018
| if t.status == Ticket.STATUS_VALID: | ||
| bookedTickets += 1 | ||
| elif t.status == Ticket.STATUS_USED: | ||
| usedTickets += 1 |
Author
There was a problem hiding this comment.
上面几行 可以直接使用QuerySet的count方法
chenyijie2016
commented
Nov 16, 2018
| if activity.remain_tickets == 0: | ||
| return self.reply_text('没有多的票了!请自行尝试劝退抢到票的朋友们~') | ||
| 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, |
Author
There was a problem hiding this comment.
这里没有考虑并发冲突的情况 并且判断条件为 activity.remain_tickets == 0 如果remain_tickets 被并发的修改为小于0的数,会导致之后可以无限抢票
chenyijie2016
commented
Nov 16, 2018
| activities = Activity.objects.filter(status = Activity.STATUS_PUBLISHED) | ||
| return activities | ||
|
|
||
| def get_tickets(self): |
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.