@@ -99,11 +99,11 @@ def lottery_mp_campaign_list_api(request): |
||
| 99 | 99 |
LotteryEntryInfo.objects.of_campaign(campaign.campaign_id).filter(status=True) |
| 100 | 100 |
) |
| 101 | 101 |
# 未登录时 user 为空,joined 一律 False |
| 102 |
- my_entries = [entry for entry in entries if user and entry.user_id == user.user_id] |
|
| 102 |
+ user_entries = [entry for entry in entries if user and entry.user_id == user.user_id] |
|
| 103 | 103 |
|
| 104 | 104 |
# 公开信息 + 当前用户的参与状态,合成一条给前端 |
| 105 | 105 |
item = campaign.overview_data(entries) |
| 106 |
- item.update(campaign.user_data(my_entries)) |
|
| 106 |
+ item.update(campaign.user_data(user_entries)) |
|
| 107 | 107 |
data.append(item) |
| 108 | 108 |
|
| 109 | 109 |
return response(200, 'Get Lottery Overview Success', u'抽奖活动信息获取成功', data={'campaigns': data})
|
@@ -193,7 +193,7 @@ class LotteryCampaignQuerySet(models.QuerySet): |
||
| 193 | 193 |
|
| 194 | 194 |
|
| 195 | 195 |
def mask_name(name): |
| 196 |
- """公开页面用的姓名脱敏:王诗云 → 王*云,两字 → 王*""" |
|
| 196 |
+ """公开页面用的姓名脱敏:只保留首位,其余用 * 代替。王诗云 → 王**,齐优 → 齐*""" |
|
| 197 | 197 |
text = (name or u'').strip() |
| 198 | 198 |
|
| 199 | 199 |
if not text: |
@@ -202,10 +202,7 @@ def mask_name(name): |
||
| 202 | 202 |
if len(text) == 1: |
| 203 | 203 |
return text + u'*' |
| 204 | 204 |
|
| 205 |
- if len(text) == 2: |
|
| 206 |
- return text[0] + u'*' |
|
| 207 |
- |
|
| 208 |
- return text[0] + u'*' * (len(text) - 2) + text[-1] |
|
| 205 |
+ return text[0] + u'*' * (len(text) - 1) |
|
| 209 | 206 |
|
| 210 | 207 |
|
| 211 | 208 |
class LotteryCampaignInfo(BaseModelMixin): |
@@ -260,24 +257,24 @@ class LotteryCampaignInfo(BaseModelMixin): |
||
| 260 | 257 |
|
| 261 | 258 |
return 'ongoing' |
| 262 | 259 |
|
| 263 |
- def user_data(self, my_entries): |
|
| 260 |
+ def user_data(self, user_entries): |
|
| 264 | 261 |
"""当前用户与这个活动的关系,给公开页区分「没参与 / 已参与 / 已中奖」用 |
| 265 | 262 |
|
| 266 |
- my_entries 是当前用户在该活动下的名额;未登录或没参与时传空。 |
|
| 263 |
+ user_entries 是当前用户在该活动下的名额;未登录或没参与时传空。 |
|
| 267 | 264 |
""" |
| 268 |
- my_entries = my_entries or [] |
|
| 265 |
+ user_entries = user_entries or [] |
|
| 269 | 266 |
|
| 270 |
- if any(entry.result == LotteryEntryInfo.WON for entry in my_entries): |
|
| 267 |
+ if any(entry.result == LotteryEntryInfo.WON for entry in user_entries): |
|
| 271 | 268 |
result = LotteryEntryInfo.WON |
| 272 |
- elif any(entry.result == LotteryEntryInfo.PENDING for entry in my_entries): |
|
| 269 |
+ elif any(entry.result == LotteryEntryInfo.PENDING for entry in user_entries): |
|
| 273 | 270 |
result = LotteryEntryInfo.PENDING |
| 274 |
- elif my_entries: |
|
| 271 |
+ elif user_entries: |
|
| 275 | 272 |
result = LotteryEntryInfo.LOST |
| 276 | 273 |
else: |
| 277 | 274 |
result = None |
| 278 | 275 |
|
| 279 | 276 |
return {
|
| 280 |
- 'joined': bool(my_entries), |
|
| 277 |
+ 'joined': bool(user_entries), |
|
| 281 | 278 |
'result': result, |
| 282 | 279 |
} |
| 283 | 280 |
|