subscription - published threshold
This commit is contained in:
parent
d628911014
commit
dbf943591a
@ -146,8 +146,8 @@ class SubscriptionSerializer_GET(DynamicModelSerializer):
|
||||
class Meta:
|
||||
model = Subscription
|
||||
fields = (
|
||||
"id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes",
|
||||
"filters", "article_title_mutators", "article_desc_mutators", "article_fetch_image", "embed_colour", "active"
|
||||
"id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes", "filters",
|
||||
"article_title_mutators", "article_desc_mutators", "article_fetch_image", "published_threshold", "embed_colour", "active"
|
||||
)
|
||||
|
||||
|
||||
@ -159,8 +159,8 @@ class SubscriptionSerializer_POST(DynamicModelSerializer):
|
||||
class Meta:
|
||||
model = Subscription
|
||||
fields = (
|
||||
"id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes",
|
||||
"filters", "article_title_mutators", "article_desc_mutators", "article_fetch_image", "embed_colour", "active"
|
||||
"id", "name", "url", "guild_id", "channels_count", "creation_datetime", "extra_notes", "filters",
|
||||
"article_title_mutators", "article_desc_mutators", "article_fetch_image", "published_threshold", "embed_colour", "active"
|
||||
)
|
||||
|
||||
|
||||
|
@ -189,7 +189,7 @@ class Subscription_ListView(generics.ListCreateAPIView):
|
||||
filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter]
|
||||
filterset_fields = [
|
||||
"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"]
|
||||
ordering_fields = ["creation_datetime", "guild_id"]
|
||||
|
19
apps/home/migrations/0013_subscription_published_theshold.py
Normal file
19
apps/home/migrations/0013_subscription_published_theshold.py
Normal 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),
|
||||
),
|
||||
]
|
@ -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',
|
||||
),
|
||||
]
|
@ -230,6 +230,8 @@ class Subscription(models.Model):
|
||||
blank=True
|
||||
)
|
||||
|
||||
published_threshold = models.DateField(default=timezone.now, blank=True)
|
||||
|
||||
article_fetch_image = models.BooleanField(
|
||||
default=True,
|
||||
help_text="Will the resulting article have an image?"
|
||||
|
7
apps/static/css/bootstrap-datepicker3.min.css
vendored
Normal file
7
apps/static/css/bootstrap-datepicker3.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -69,4 +69,11 @@ td {
|
||||
td {
|
||||
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;
|
||||
}
|
@ -20,9 +20,12 @@ $(document).ready(function() {
|
||||
theme: "bootstrap",
|
||||
minimumResultsForSearch: 5,
|
||||
dropdownParent: dropdownParent
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// Activate datepickers
|
||||
$(".input-group.date").datepicker({format: "yyyy-mm-dd"});
|
||||
|
||||
// Load theme
|
||||
var theme = localStorage.getItem("theme");
|
||||
if (theme === null)
|
||||
|
8
apps/static/js/bootstrap-datepicker.min.js
vendored
Normal file
8
apps/static/js/bootstrap-datepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -149,6 +149,7 @@ $("#subTable").on("change", ".sub-toggle-active", async function () {
|
||||
},
|
||||
sub.embed_colour,
|
||||
sub.article_fetch_image,
|
||||
sub.published_threshold,
|
||||
active,
|
||||
handleErrorMsg=false
|
||||
);
|
||||
@ -226,6 +227,8 @@ async function showEditSubModal(subId) {
|
||||
|
||||
subSetHexColour(`#${subscription.embed_colour}`);
|
||||
$("#subArticleFetchImage").prop("checked", subscription.article_fetch_image);
|
||||
|
||||
$("#subPubThreshold").val(subscription.published_threshold);
|
||||
}
|
||||
|
||||
$("#subId").val(subId);
|
||||
@ -248,9 +251,10 @@ $("#subForm").on("submit", async function(event) {
|
||||
}
|
||||
subEmbedColour = $("#subEmbedColour").val().split("#")[1];
|
||||
articleFetchImage = $("#subArticleFetchImage").prop("checked")
|
||||
publishedThreshold = $("#subPubThreshold").val();
|
||||
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) {
|
||||
alert("prevented /subscriptions/false/subchannels");
|
||||
@ -269,7 +273,7 @@ $("#subForm").on("submit", async function(event) {
|
||||
$("#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();
|
||||
formData.append("name", name);
|
||||
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.desc.forEach(mutator => formData.append("article_desc_mutators", mutator));
|
||||
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);
|
||||
|
||||
var response;
|
||||
|
@ -59,7 +59,7 @@
|
||||
</div>
|
||||
<div class="modal-footer px-4">
|
||||
<!-- form-create -->
|
||||
<button type="button" id="devGenerateSub" class="btn btn-outline-info rounded-1 me-3 ms-0 d-none" tabindex="7">(Dev) Generate</button>
|
||||
<button type="button" id="devGenerateSub" class="btn btn-outline-info rounded-1 me-3 ms-0 d-none" tabindex="7">(Dev) 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" 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">
|
||||
@ -117,7 +117,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 pe-lg-4">
|
||||
<div>
|
||||
<div class="mb-4">
|
||||
<label for="subEmbedColour" class="form-label">Embed Colour</label>
|
||||
<div class="input-group">
|
||||
<input type="color" name="subEmbedColour" id="subEmbedColour" class="form-control-color input-group-text">
|
||||
@ -133,6 +133,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<label for="subArticleFetchImage" class="form-check-label mb-2">Show Images on Embed?</label>
|
||||
<br>
|
||||
|
@ -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="{% 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/bootstrap-datepicker3.min.css' %}">
|
||||
|
||||
{% block stylesheets %}{% endblock stylesheets %}
|
||||
</head>
|
||||
@ -51,6 +52,7 @@
|
||||
<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/select2.min.js' %}"></script>
|
||||
<script src="{% static '/js/bootstrap-datepicker.min.js' %}"></script>
|
||||
<script src="{% static '/js/toasts.js' %}"></script>
|
||||
<script src="{% static '/js/base.js' %%}"></script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user