Coverage for src/accounts/models/user_photo.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-08-04 12:59 +0300

1""" 

2The UserPhoto model: 

3- Stores user profile pictures in the cloud via Cloudinary 

4- Uses one-to-one relationship with the user model 

5""" 

6 

7from django.contrib.auth import get_user_model 

8from django.db import models 

9 

10from cloudinary.models import CloudinaryField 

11 

12from src.accounts.constants import PhotoSize 

13from src.accounts.validators.models import FileSizeValidator 

14 

15UserModel = get_user_model() 

16 

17 

18class UserPhoto(models.Model): 

19 

20 photo = CloudinaryField( 

21 'image', 

22 null=True, 

23 blank=False, 

24 validators=[ 

25 FileSizeValidator(PhotoSize.MAX_SIZE), 

26 ], 

27 ) 

28 

29 user = models.OneToOneField( 

30 to=UserModel, 

31 on_delete=models.CASCADE, 

32 primary_key=True, 

33 )