Coverage for sites/ptf_tools/comments_moderation/models.py: 69%

11 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-02-28 09:09 +0000

1from django.contrib.auth.models import User 

2from django.db import models 

3 

4from ptf.models import Collection 

5 

6 

7class CommentModerator(models.Model): 

8 """ 

9 Adds moderator data to the base Django User model. 

10 """ 

11 

12 user = models.OneToOneField( 

13 User, 

14 unique=True, 

15 on_delete=models.CASCADE, 

16 related_name="comment_moderator", 

17 primary_key=True, 

18 ) 

19 is_moderator = models.BooleanField(default=False) 

20 collections = models.ManyToManyField(Collection, blank=True) 

21 

22 def get_collections(self) -> str: 

23 return ", ".join([col.pid for col in self.collections.all()]) 

24 

25 def __str__(self) -> str: 

26 return self.user.username