subscription - published threshold

This commit is contained in:
Corban-Lee Jones 2024-07-10 11:44:01 +01:00
parent d628911014
commit dbf943591a
12 changed files with 94 additions and 11 deletions

View File

@ -146,8 +146,8 @@ class SubscriptionSerializer_GET(DynamicModelSerializer):
class Meta: class Meta:
model = Subscription model = Subscription
fields = ( fields = (
"id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes", "id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes", "filters",
"filters", "article_title_mutators", "article_desc_mutators", "article_fetch_image", "embed_colour", "active" "article_title_mutators", "article_desc_mutators", "article_fetch_image", "published_threshold", "embed_colour", "active"
) )
@ -159,8 +159,8 @@ class SubscriptionSerializer_POST(DynamicModelSerializer):
class Meta: class Meta:
model = Subscription model = Subscription
fields = ( fields = (
"id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes", "id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes", "filters",
"filters", "article_title_mutators", "article_desc_mutators", "article_fetch_image", "embed_colour", "active" "article_title_mutators", "article_desc_mutators", "article_fetch_image", "published_threshold", "embed_colour", "active"
) )

View File

@ -189,7 +189,7 @@ class Subscription_ListView(generics.ListCreateAPIView):
filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter] filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter]
filterset_fields = [ filterset_fields = [
"id", "name", "url", "guild_id", "creation_datetime", "extra_notes", "filters", "id", "name", "url", "guild_id", "creation_datetime", "extra_notes", "filters",
"article_title_mutators", "article_desc_mutators", "embed_colour", "active" "article_title_mutators", "article_desc_mutators", "embed_colour", "published_threshold", "active"
] ]
search_fields = ["name", "extra_notes"] search_fields = ["name", "extra_notes"]
ordering_fields = ["creation_datetime", "guild_id"] ordering_fields = ["creation_datetime", "guild_id"]

View File

@ -0,0 +1,19 @@
# Generated by Django 5.0.4 on 2024-07-10 09:08
import django.utils.timezone
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0012_remove_trackedcontent_unique_guid_guild_id_pair_and_more'),
]
operations = [
migrations.AddField(
model_name='subscription',
name='published_theshold',
field=models.DateField(blank=True, default=django.utils.timezone.now),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2024-07-10 09:27
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0013_subscription_published_theshold'),
]
operations = [
migrations.RenameField(
model_name='subscription',
old_name='published_theshold',
new_name='published_threshold',
),
]

View File

@ -230,6 +230,8 @@ class Subscription(models.Model):
blank=True blank=True
) )
published_threshold = models.DateField(default=timezone.now, blank=True)
article_fetch_image = models.BooleanField( article_fetch_image = models.BooleanField(
default=True, default=True,
help_text="Will the resulting article have an image?" help_text="Will the resulting article have an image?"

File diff suppressed because one or more lines are too long

View File

@ -69,4 +69,11 @@ td {
td { td {
height: 100%; height: 100%;
} }
}
/* hide date picker calendar */
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-calendar-picker-indicator {
display: none;
-webkit-appearance: none;
} }

View File

@ -20,9 +20,12 @@ $(document).ready(function() {
theme: "bootstrap", theme: "bootstrap",
minimumResultsForSearch: 5, minimumResultsForSearch: 5,
dropdownParent: dropdownParent dropdownParent: dropdownParent
}) });
}); });
// Activate datepickers
$(".input-group.date").datepicker({format: "yyyy-mm-dd"});
// Load theme // Load theme
var theme = localStorage.getItem("theme"); var theme = localStorage.getItem("theme");
if (theme === null) if (theme === null)

File diff suppressed because one or more lines are too long

View File

@ -149,6 +149,7 @@ $("#subTable").on("change", ".sub-toggle-active", async function () {
}, },
sub.embed_colour, sub.embed_colour,
sub.article_fetch_image, sub.article_fetch_image,
sub.published_threshold,
active, active,
handleErrorMsg=false handleErrorMsg=false
); );
@ -226,6 +227,8 @@ async function showEditSubModal(subId) {
subSetHexColour(`#${subscription.embed_colour}`); subSetHexColour(`#${subscription.embed_colour}`);
$("#subArticleFetchImage").prop("checked", subscription.article_fetch_image); $("#subArticleFetchImage").prop("checked", subscription.article_fetch_image);
$("#subPubThreshold").val(subscription.published_threshold);
} }
$("#subId").val(subId); $("#subId").val(subId);
@ -248,9 +251,10 @@ $("#subForm").on("submit", async function(event) {
} }
subEmbedColour = $("#subEmbedColour").val().split("#")[1]; subEmbedColour = $("#subEmbedColour").val().split("#")[1];
articleFetchImage = $("#subArticleFetchImage").prop("checked") articleFetchImage = $("#subArticleFetchImage").prop("checked")
publishedThreshold = $("#subPubThreshold").val();
active = $("#subActive").prop("checked"); active = $("#subActive").prop("checked");
var subPrimaryKey = await saveSubscription(id, name, url, guildId, extraNotes, subFilters, subMutators, subEmbedColour, articleFetchImage, active); var subPrimaryKey = await saveSubscription(id, name, url, guildId, extraNotes, subFilters, subMutators, subEmbedColour, articleFetchImage, publishedThreshold, active);
if (!subPrimaryKey) { if (!subPrimaryKey) {
alert("prevented /subscriptions/false/subchannels"); alert("prevented /subscriptions/false/subchannels");
@ -269,7 +273,7 @@ $("#subForm").on("submit", async function(event) {
$("#subFormModal").modal("hide"); $("#subFormModal").modal("hide");
}); });
async function saveSubscription(id, name, url, guildId, extraNotes, filters, mutators, embedColour, articleFetchImage, active, handleErrorMsg=true) { async function saveSubscription(id, name, url, guildId, extraNotes, filters, mutators, embedColour, articleFetchImage, publishedTheshold, active, handleErrorMsg=true) {
var formData = new FormData(); var formData = new FormData();
formData.append("name", name); formData.append("name", name);
formData.append("url", url); formData.append("url", url);
@ -279,7 +283,8 @@ async function saveSubscription(id, name, url, guildId, extraNotes, filters, mut
mutators.title.forEach(mutator => formData.append("article_title_mutators", mutator)); mutators.title.forEach(mutator => formData.append("article_title_mutators", mutator));
mutators.desc.forEach(mutator => formData.append("article_desc_mutators", mutator)); mutators.desc.forEach(mutator => formData.append("article_desc_mutators", mutator));
formData.append("embed_colour", embedColour); formData.append("embed_colour", embedColour);
formData.append("article_fetch_image", articleFetchImage) formData.append("article_fetch_image", articleFetchImage);
formData.append("published_threshold", publishedTheshold);
formData.append("active", active); formData.append("active", active);
var response; var response;

View File

@ -59,7 +59,7 @@
</div> </div>
<div class="modal-footer px-4"> <div class="modal-footer px-4">
<!-- form-create --> <!-- form-create -->
<button type="button" id="devGenerateSub" class="btn btn-outline-info rounded-1 me-3 ms-0 d-none" tabindex="7">&#40;Dev&#41; Generate</button> <button type="button" id="devGenerateSub" class="btn btn-outline-info rounded-1 me-3 ms-0 d-none" tabindex="7">&#40;Dev&#41; Generate</button>
<button type="button" id="deleteEditSub" class="btn btn-danger rounded-1 me-3 ms-0 form-edit" tabindex="8">Delete</button> <button type="button" id="deleteEditSub" class="btn btn-danger rounded-1 me-3 ms-0 form-edit" tabindex="8">Delete</button>
<button type="button" class="btn btn-outline-primary rounded-1 me-auto ms-0" data-bs-toggle="modal" data-bs-target="#subAdvancedModal" tabindex="9">Advanced</button> <button type="button" class="btn btn-outline-primary rounded-1 me-auto ms-0" data-bs-toggle="modal" data-bs-target="#subAdvancedModal" tabindex="9">Advanced</button>
<button type="submit" class="btn btn-primary rounded-1 me-0" tabindex="9"> <button type="submit" class="btn btn-primary rounded-1 me-0" tabindex="9">
@ -117,7 +117,7 @@
</div> </div>
</div> </div>
<div class="col-lg-6 pe-lg-4"> <div class="col-lg-6 pe-lg-4">
<div> <div class="mb-4">
<label for="subEmbedColour" class="form-label">Embed Colour</label> <label for="subEmbedColour" class="form-label">Embed Colour</label>
<div class="input-group"> <div class="input-group">
<input type="color" name="subEmbedColour" id="subEmbedColour" class="form-control-color input-group-text"> <input type="color" name="subEmbedColour" id="subEmbedColour" class="form-control-color input-group-text">
@ -133,6 +133,18 @@
</div> </div>
</div> </div>
<div class="col-lg-6 ps-lg-4"> <div class="col-lg-6 ps-lg-4">
<div class="mb-4">
<label for="subPubThreshold" class="form-label">Publish Date Threshold</label>
<div class="input-group date">
<input type="date" name="subPubThreshold" id="subPubThreshold" class="form-control" placeholder="yyyy-mm-dd" >
<div class="input-group-addon input-group-text">
<i class="bi bi-calendar2-event"></i>
</div>
</div>
<div class="form-text">RSS content older than this date will be skipped.</div>
</div>
</div>
<div class="col-lg-6 pe-lg-4">
<div class="form-switch ps-0"> <div class="form-switch ps-0">
<label for="subArticleFetchImage" class="form-check-label mb-2">Show Images on Embed?</label> <label for="subArticleFetchImage" class="form-check-label mb-2">Show Images on Embed?</label>
<br> <br>

View File

@ -26,6 +26,7 @@
<link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/select/2.0.1/css/select.dataTables.min.css"> <link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/select/2.0.1/css/select.dataTables.min.css">
<link type="text/css" rel="stylesheet" href="{% static '/css/select2.min.css' %}"> <link type="text/css" rel="stylesheet" href="{% static '/css/select2.min.css' %}">
<link type="text/css" rel="stylesheet" href="{% static '/css/select2-bootstrap.min.css' %}"> <link type="text/css" rel="stylesheet" href="{% static '/css/select2-bootstrap.min.css' %}">
<link type="text/css" rel="stylesheet" href="{% static '/css/bootstrap-datepicker3.min.css' %}">
{% block stylesheets %}{% endblock stylesheets %} {% block stylesheets %}{% endblock stylesheets %}
</head> </head>
@ -51,6 +52,7 @@
<script src="https://cdn.datatables.net/select/2.0.1/js/dataTables.select.min.js"></script> <script src="https://cdn.datatables.net/select/2.0.1/js/dataTables.select.min.js"></script>
<script src="{% static '/js/bootstrap.bundle.min.js' %}"></script> <script src="{% static '/js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static '/js/select2.min.js' %}"></script> <script src="{% static '/js/select2.min.js' %}"></script>
<script src="{% static '/js/bootstrap-datepicker.min.js' %}"></script>
<script src="{% static '/js/toasts.js' %}"></script> <script src="{% static '/js/toasts.js' %}"></script>
<script src="{% static '/js/base.js' %%}"></script> <script src="{% static '/js/base.js' %%}"></script>