track blocked content
This commit is contained in:
parent
2b2cd26bb2
commit
680924fc6e
@ -157,7 +157,7 @@ class TrackedContentSerializer_GET(DynamicModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = TrackedContent
|
||||
fields = ("guid", "title", "subscription", "creation_datetime")
|
||||
fields = ("guid", "title", "url", "subscription", "blocked", "creation_datetime")
|
||||
|
||||
class TrackedContentSerializer_POST(DynamicModelSerializer):
|
||||
"""
|
||||
@ -166,4 +166,4 @@ class TrackedContentSerializer_POST(DynamicModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = TrackedContent
|
||||
fields = ("guid", "title", "subscription", "creation_datetime")
|
||||
fields = ("guid", "title", "url", "subscription", "blocked", "creation_datetime")
|
||||
|
@ -387,10 +387,10 @@ class TrackedContent_ListView(generics.ListCreateAPIView):
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
pagination_class = DefaultPagination
|
||||
queryset = TrackedContent.objects.all().order_by("guid")
|
||||
queryset = TrackedContent.objects.all().order_by("-creation_datetime")
|
||||
|
||||
filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter]
|
||||
filterset_fields = ["guid", "title", "subscription", "subscription__guild_id", "creation_datetime"]
|
||||
filterset_fields = ["guid", "title", "url", "subscription", "subscription__guild_id", "blocked", "creation_datetime"]
|
||||
|
||||
read_serializer_class = TrackedContentSerializer_GET
|
||||
write_serializer_class = TrackedContentSerializer_POST
|
||||
@ -430,6 +430,6 @@ class TrackedContent_DetailView(generics.RetrieveUpdateDestroyAPIView):
|
||||
parser_classes = [MultiPartParser, FormParser]
|
||||
|
||||
serializer_class = TrackedContentSerializer_POST
|
||||
queryset = TrackedContent.objects.all().order_by("guid")
|
||||
queryset = TrackedContent.objects.all().order_by("-creation_datetime")
|
||||
|
||||
|
18
apps/home/migrations/0002_trackedcontent_blocked.py
Normal file
18
apps/home/migrations/0002_trackedcontent_blocked.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.4 on 2024-06-11 20:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='trackedcontent',
|
||||
name='blocked',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
@ -253,4 +253,5 @@ class TrackedContent(models.Model):
|
||||
title = models.CharField(max_length=128)
|
||||
url = models.URLField()
|
||||
subscription = models.ForeignKey(to=Subscription, on_delete=models.CASCADE)
|
||||
blocked = models.BooleanField(default=False)
|
||||
creation_datetime = models.DateTimeField(default=timezone.now, editable=False)
|
||||
|
@ -31,11 +31,26 @@ function initContentTable() {
|
||||
},
|
||||
{ title: "GUID", data: "guid", visible: false },
|
||||
{
|
||||
title: "Name", data: "title"
|
||||
title: "Name",
|
||||
data: "title",
|
||||
render: function(data, type, row) {
|
||||
return `<a href="${row.url}" class="text-decoration-none">${data}</a>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Subscription",
|
||||
data: "subscription.name",
|
||||
render: function(data, type, row) {
|
||||
return `<a href="#" onclick="goToSubscription(${row.subscription.id})" class="text-decoration-none">${data}</a>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Blocked",
|
||||
data: "blocked",
|
||||
className: "text-center col-1",
|
||||
render: function(data) {
|
||||
return data ? `<i class="bi bi-check-lg text-success"></i>` : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Created",
|
||||
@ -48,6 +63,11 @@ function initContentTable() {
|
||||
});
|
||||
}
|
||||
|
||||
async function goToSubscription(subId) {
|
||||
$("#subscriptionsTab").click();
|
||||
await showEditSubModal(subId);
|
||||
}
|
||||
|
||||
$("#deleteSelectedContentBtn").on("click", async function() {
|
||||
|
||||
var rows = contentTable.rows(".selected").data();
|
||||
|
@ -61,9 +61,6 @@
|
||||
<li class="nav-item" role="presentation">
|
||||
<button id="contentTab" class="nav-link rounded-1" data-bs-toggle="tab" data-bs-target="#contentTabPane" type="button" aria-controls="contentTabPane" aria-selected="false">Tracked Content</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button id="blockedTab" class="nav-link rounded-1" data-bs-toggle="tab" data-bs-target="#blockedTabPane" type="button" aria-controls="blockedTabPane" aria-selected="false">Blocked Content</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-pane-buttons">
|
||||
<div class="tab-pane-buttons-item" data-tab="subscriptionsTab">
|
||||
@ -159,11 +156,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="blockedTabPane" class="tab-pane fade" role="tabpanel" aria-labelledby="blockedTab" tabindex="0">
|
||||
<div class="table-responsive mt-3">
|
||||
<table id="blockedTable" class="table table-hover align-middle"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -189,5 +181,4 @@
|
||||
<script src="{% static 'js/home/subscriptions.js' %}"></script>
|
||||
<script src="{% static 'js/home/filters.js' %}"></script>
|
||||
<script src="{% static 'js/home/content.js' %}"></script>
|
||||
<script src="{% static 'js/home/blocked.js' %}"></script>
|
||||
{% endblock javascript %}
|
Loading…
x
Reference in New Issue
Block a user