diff --git a/apps/bookmark/migrations/0003_add_article_service_choice.py b/apps/bookmark/migrations/0003_add_article_service_choice.py new file mode 100644 index 0000000..a3a1c45 --- /dev/null +++ b/apps/bookmark/migrations/0003_add_article_service_choice.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.8 on 2025-11-21 03:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookmark', '0002_rate'), + ] + + operations = [ + migrations.AlterField( + model_name='bookmark', + name='service', + field=models.CharField(choices=[('library', 'Library'), ('podcast', 'Podcast'), ('hadith', 'Hadith'), ('video', 'Video'), ('article', 'Article')], max_length=20, verbose_name='Service'), + ), + ] diff --git a/apps/bookmark/models/bookmark.py b/apps/bookmark/models/bookmark.py index 108a02d..948affa 100644 --- a/apps/bookmark/models/bookmark.py +++ b/apps/bookmark/models/bookmark.py @@ -15,6 +15,7 @@ class Bookmark(models.Model): PODCAST = 'podcast', 'Podcast' HADITH = 'hadith', 'Hadith' VIDEO = 'video', 'Video' + ARTICLE = 'article', 'Article' user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='bookmarks', verbose_name='User') service = models.CharField(max_length=20, choices=ServiceChoices.choices, verbose_name='Service') @@ -75,4 +76,7 @@ class Bookmark(models.Model): elif service == cls.ServiceChoices.VIDEO: from apps.video.models import Video return Video.objects.filter(id=content_id).exists() + elif service == cls.ServiceChoices.ARTICLE: + from apps.article.models import Article + return Article.objects.filter(id=content_id).exists() return False