Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

致命问题 #247

Open
harveyqiu opened this issue Jan 31, 2020 · 2 comments
Open

致命问题 #247

harveyqiu opened this issue Jan 31, 2020 · 2 comments

Comments

@harveyqiu
Copy link
Member

我们应该认为用户有多蠢?

@harveyqiu
Copy link
Member Author

  • 问题1: 现有的CreditDistributionn有两种创建方式
    一是一键批量创建,就是只要按一下,就会根据当前的学年和学期生成所有的Active的社团所对应的CreditDistribution 未考虑重复的情形
    第二种是选择创建,就是点击之后会弹出一个Modal,用户可以选择填写学年和学期 和 选择需要创建CD的相对应的社团 后端代码也没有进行查重的验证

到底应该当用户是傻子,我们写更加严格的验证
还是不当他们是傻子

@nichujie
Copy link
Member

2.1的话看这个:
https://docs.djangoproject.com/en/2.1/ref/models/options/#unique-together
升级2.2可以用这个:
https://docs.djangoproject.com/en/2.2/ref/models/constraints/#django.db.models.UniqueConstraint

简单来说unique_together就是把一堆field绑起来让他们唯一,
例如:(society_id, year, semester)
(303, 2019, 1)
(303, 2019, 2)
这个三元组是唯一的
不是pk,pk还是普通的id

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants