Coverage for api/models/models.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 06:14 +0000

1from django.db import models 

2 

3from api.constants.media_types import MEDIA_TYPE_CHOICES 

4from api.models.base import OpenLedgerModel 

5 

6 

7class ContentSource(models.Model): 

8 """ 

9 A content source instance can only be mapped to a single media type. 

10 

11 For sources with multiple media types, use different identifiers while 

12 keeping the same display name. 

13 

14 For example, 

15 - Wikimedia for audio can have 

16 ``source_identifier`` as "wikimedia_audio" and 

17 ``source_name`` as "Wikimedia" 

18 - Wikimedia for images can have 

19 ``source_identifier`` as "wikimedia_images" or "wikimedia" and 

20 ``source_name`` as "Wikimedia" 

21 """ 

22 

23 source_identifier = models.CharField( 

24 max_length=80, unique=True, db_column="provider_identifier" 

25 ) 

26 source_name = models.CharField(max_length=250, db_column="provider_name") 

27 created_on = models.DateTimeField(auto_now=False) 

28 domain_name = models.CharField(max_length=500) 

29 filter_content = models.BooleanField( 

30 null=False, default=False, verbose_name="Hide content" 

31 ) 

32 notes = models.TextField(null=True) 

33 media_type = models.CharField( 

34 max_length=80, 

35 choices=MEDIA_TYPE_CHOICES, 

36 ) 

37 

38 class Meta: 

39 db_table = "content_provider" 

40 

41 

42class Tag(OpenLedgerModel): 

43 foreign_identifier = models.CharField(max_length=255, blank=True, null=True) 

44 name = models.CharField(max_length=1000, blank=True, null=True) 

45 source = models.CharField(max_length=255, blank=True, null=True) 

46 slug = models.SlugField(blank=True, null=True, max_length=255) 

47 

48 class Meta: 

49 db_table = "tag"