sub recommendation model and data
This commit is contained in:
parent
4252a2c79e
commit
f7cfc9afc1
@ -13,6 +13,7 @@ from apps.home.models import (
|
||||
DiscordChannel,
|
||||
Subscription,
|
||||
Content,
|
||||
SubscriptionRecommendation
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -339,3 +340,13 @@ class ContentSerializer(DynamicModelSerializer):
|
||||
"item_feed_url",
|
||||
"blocked"
|
||||
)
|
||||
|
||||
class SubscriptionRecommendationSerializer(DynamicModelSerializer):
|
||||
class Meta:
|
||||
model = SubscriptionRecommendation
|
||||
fields = (
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
"url"
|
||||
)
|
||||
|
@ -15,7 +15,8 @@ from .views import (
|
||||
Subscription_ListView,
|
||||
Subscription_DetailView,
|
||||
Content_ListView,
|
||||
Content_DetailView
|
||||
Content_DetailView,
|
||||
SubscriptionRecommendations_ListView
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
@ -56,5 +57,10 @@ urlpatterns = [
|
||||
path("content/", include([
|
||||
path("", Content_ListView.as_view()),
|
||||
path("<int:pk>/", Content_DetailView.as_view())
|
||||
])),
|
||||
|
||||
# region Recommendations
|
||||
path("subscription-recommendations/", include([
|
||||
path("", SubscriptionRecommendations_ListView.as_view())
|
||||
]))
|
||||
]
|
||||
|
@ -17,7 +17,8 @@ from apps.home.models import (
|
||||
MessageMutator,
|
||||
MessageStyle,
|
||||
Subscription,
|
||||
Content
|
||||
Content,
|
||||
SubscriptionRecommendation
|
||||
)
|
||||
from apps.authentication.models import DiscordUser, ServerMember
|
||||
from .metadata import ExpandedMetadata
|
||||
@ -27,7 +28,8 @@ from .serializers import (
|
||||
MessageMutatorSerializer,
|
||||
MessageStyleSerializer,
|
||||
SubscriptionSerializer,
|
||||
ContentSerializer
|
||||
ContentSerializer,
|
||||
SubscriptionRecommendationSerializer
|
||||
)
|
||||
from .permissions import HasServerAccess
|
||||
from .errors import NotAMemberError
|
||||
@ -302,3 +304,10 @@ class Content_DetailView(ChangableDetailView):
|
||||
servers = ServerMember.objects.filter(user=self.request.user).values_list("server", flat=True)
|
||||
subscriptions = Subscription.objects.filter(server__in=servers).values_list("id", flat=True)
|
||||
return Content.objects.filter(subscription__in=subscriptions)
|
||||
|
||||
|
||||
# region Sub Recommendations
|
||||
|
||||
class SubscriptionRecommendations_ListView(ListView):
|
||||
queryset = SubscriptionRecommendation.objects.all().order_by("id")
|
||||
serializer_class = SubscriptionRecommendationSerializer
|
||||
|
@ -0,0 +1,29 @@
|
||||
# Generated by Django 5.0.4 on 2024-11-13 00:58
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0018_alter_content_item_author'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SubscriptionRecommendation',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('description', models.CharField(max_length=250)),
|
||||
('url', models.URLField()),
|
||||
],
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='subscription',
|
||||
name='unique_rules',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='UniqueContentRule',
|
||||
),
|
||||
]
|
47
apps/home/migrations/0020_autofill_sub_recs.py
Normal file
47
apps/home/migrations/0020_autofill_sub_recs.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Generated by Django 5.0.4 on 2024-11-13 00:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
def add_subscription_recommendations(apps, schema_editor):
|
||||
model = apps.get_model("home", "SubscriptionRecommendation")
|
||||
model.objects.create(
|
||||
name="BBC News",
|
||||
description="BBC News - News Front Page.",
|
||||
url="http://feeds.bbci.co.uk/news/rss.xml"
|
||||
)
|
||||
model.objects.create(
|
||||
name="BBC News · Entertainment",
|
||||
description="BBC News - Culture.",
|
||||
url="https://feeds.bbci.co.uk/news/entertainment_and_arts/rss.xml"
|
||||
)
|
||||
model.objects.create(
|
||||
name="BBC News · Technology",
|
||||
description="BBC News - Technology.",
|
||||
url="https://feeds.bbci.co.uk/news/technology/rss.xml"
|
||||
)
|
||||
model.objects.create(
|
||||
name="Sky News",
|
||||
description="The Latest News from the UK and Around the World.",
|
||||
url="https://feeds.skynews.com/feeds/rss/home.xml"
|
||||
)
|
||||
model.objects.create(
|
||||
name="Sky News · Strange News",
|
||||
description="Weird News - Strange and Odd News Stories.",
|
||||
url="https://feeds.skynews.com/feeds/rss/strange.xml"
|
||||
)
|
||||
model.objects.create(
|
||||
name="Free Games Finder",
|
||||
description="Free Games Finder's mission is to find and raise awareness of free games.",
|
||||
url="https://steamcommunity.com/groups/freegamesfinders/rss/"
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0019_subscriptionrecommendation_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_subscription_recommendations)
|
||||
]
|
@ -289,3 +289,15 @@ class BotLogicLogs(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.server.name} - {self.id}"
|
||||
|
||||
|
||||
# Subscription Recommendations
|
||||
|
||||
class SubscriptionRecommendation(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=32)
|
||||
description = models.CharField(max_length=250)
|
||||
url = models.URLField()
|
||||
|
||||
def __str__(self):
|
||||
return self.url
|
||||
|
Loading…
x
Reference in New Issue
Block a user