Advertisement
Guest User

Untitled

a guest
Aug 7th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. class User(BaseModel):
  2. # User in our system
  3. username = models.CharField()
  4. email = models.EmailField()
  5. password = models.CharField() # DO NOT ACTUALLY DO THIS
  6.  
  7.  
  8. class DeviceLogin(BaseModel):
  9. # Different devices a user could potentially login from
  10. DESKTOP = 'DSK'
  11. PHONE = 'PHN'
  12. TABLET = 'TBL'
  13.  
  14. LOGIN_NAME_CHOICES = [
  15. (DESKTOP , 'Desktop'),
  16. (PHONE , 'Phone'),
  17. (TABLET , 'Tablet'),
  18. ]
  19.  
  20. logins = models.IntField()
  21. type = models.CharField(
  22. max_length=3,
  23. choices=LOGIN_NAME_CHOICES,
  24. db_index=True,
  25. unique=True
  26. )
  27.  
  28.  
  29. class UserDeviceLogin(BaseModel):
  30. # Represent a mapping of user to different devices logged in with
  31. user = models.ForeignKey(MoodyUser, on_delete=models.CASCADE)
  32. login = models.ForeignKey(DeviceLogin, on_delete=models.CASCADE)
  33.  
  34. class Meta:
  35. unique_together = ('user', 'login ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement