Graphs and tables for your Spotify account.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
922 B

  1. from django.db import models
  2. # id's are 22 in length in examples but set to 30 for buffer
  3. MAX_ID = 30
  4. # saw tokens being about ~150 chars in length
  5. TOKEN_LENGTH = 200
  6. class User(models.Model):
  7. class Meta:
  8. verbose_name = "User"
  9. verbose_name_plural = "Users"
  10. # the user's Spotify ID
  11. id = models.CharField(primary_key=True, max_length=MAX_ID)
  12. secret = models.CharField(max_length=50, default='')
  13. refresh_token = models.CharField(max_length=TOKEN_LENGTH)
  14. access_token = models.CharField(max_length=TOKEN_LENGTH)
  15. access_obtained_at = models.DateTimeField(auto_now=True)
  16. access_expires_in = models.PositiveIntegerField()
  17. def __str__(self):
  18. return self.id
  19. class HistoryUpload(models.Model):
  20. user = models.ForeignKey(User, on_delete=models.CASCADE)
  21. document = models.FileField(upload_to='history/')
  22. uploaded_at = models.DateTimeField(auto_now_add=True)