-
Notifications
You must be signed in to change notification settings - Fork 80
Schedule publishing #1369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev_v4
Are you sure you want to change the base?
Schedule publishing #1369
Changes from all commits
f2d5a25
b1537eb
a5b6107
8d319ee
6f3889a
52bc765
07c6017
725be46
f79ea70
cef7095
6213ff5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -606,6 +606,12 @@ class VideoForm(forms.ModelForm): | |
| help_text=_("Who can see your content (everyone, just you, or those granted)."), | ||
| ) | ||
|
|
||
| enable_scheduling = forms.BooleanField( | ||
| label=_("Enable scheduling"), | ||
| required=False, | ||
| help_text=_("Enable scheduling for this video."), | ||
| ) | ||
|
|
||
| required_css_class = "required" | ||
| videoattrs = { | ||
| "class": "form-control-file", | ||
|
|
@@ -683,7 +689,7 @@ class VideoForm(forms.ModelForm): | |
| { | ||
| "legend": _("Advanced options"), | ||
| "classes": "", | ||
| "fields": ["allow_downloading", "is_360", "disable_comment", "order"], | ||
| "fields": ["allow_downloading", "is_360", "disable_comment", "order", "scheduled_publish_date", "enable_scheduling"], | ||
| }, | ||
| ), | ||
| ) | ||
|
|
@@ -947,6 +953,19 @@ def __init__(self, *args, **kwargs) -> None: | |
| # Manage required fields html | ||
| self.fields = add_placeholder_and_asterisk(self.fields) | ||
| self.fields = add_describedby_attr(self.fields) | ||
| self.fields['scheduled_publish_date'].widget.input_type = 'datetime-local' | ||
| self.fields['scheduled_publish_date'].widget.attrs['placeholder'] = 'AAAA-MM-JJTHH:MM' | ||
| self.fields['scheduled_publish_date'].help_text = _('Format attendu : AAAA-MM-JJTHH:MM (ex : 2025-06-11T14:30)') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. à mettre en anglais par défaut. |
||
| self.fields['scheduled_publish_date'].input_formats = ['%Y-%m-%dT%H:%M'] | ||
|
|
||
| # Handle scheduling | ||
| from django.utils import timezone | ||
| if self.instance and self.instance.scheduled_publish_date: | ||
| self.fields["enable_scheduling"].initial = True | ||
| local_dt = timezone.localtime(self.instance.scheduled_publish_date) | ||
| self.initial["scheduled_publish_date"] = local_dt.strftime("%Y-%m-%dT%H:%M") | ||
| self.fields["scheduled_publish_date"].widget.attrs.pop("style", None) | ||
|
|
||
| if self.fields.get("video"): | ||
| # Remove label, as it will be included in customclearablefileinput | ||
| self.fields["video"].label = "" | ||
|
|
@@ -1095,6 +1114,11 @@ class Meta(object): | |
| "date_evt": datetime.date.today(), | ||
| } | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| if self.instance and self.instance.scheduled_publish_date: | ||
| self.fields["enable_scheduling"].initial = True | ||
|
|
||
|
|
||
| class ChannelForm(forms.ModelForm): | ||
| """Form class for Channel editing.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -809,7 +809,6 @@ class Video(models.Model): | |
| default=False, | ||
| help_text=_("Check this box if you want to use the 360 player for the video"), | ||
| ) | ||
|
|
||
| is_draft = models.BooleanField( | ||
| verbose_name=_("Draft"), | ||
| help_text=_( | ||
|
|
@@ -819,6 +818,10 @@ class Video(models.Model): | |
| ), | ||
| default=True, | ||
| ) | ||
| scheduled_publish_date = models.DateTimeField( | ||
| null=True, blank=True, | ||
| help_text="Date and hour of the scheduled publication." | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. à traduire |
||
| ) | ||
| is_restricted = models.BooleanField( | ||
| verbose_name=_("Authentication restricted access"), | ||
| help_text=_( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,9 +87,20 @@ <h1 class="h2"> | |
| {{field_hidden}} | ||
| {% endfor %} | ||
|
|
||
| <div class="form-group mt-3"> | ||
| <div class="form-check"> | ||
| {{ form.enable_scheduling }} | ||
| <label for="id_enable_scheduling" class="form-check-label">{% trans "Schedule the post" %}</label> | ||
| </div> | ||
| </div> | ||
| <div class="form-group mt-2" id="scheduled_publish_date_group" {% if not form.enable_scheduling.value %}style="display:none;"{% endif %}> | ||
| <label for="id_scheduled_publish_date">{% trans "Scheduled publish date" %}</label> | ||
| {{ form.scheduled_publish_date }} | ||
| </div> | ||
|
|
||
| <div class="accordion"> | ||
| {% for fieldset in form.fieldsets %} | ||
| {% with options=fieldset|last name=fieldset|first%} | ||
| {% with options=fieldset|last name=fieldset|first %} | ||
| <div class="accordion-item"> | ||
| <h2 class="accordion-header"> | ||
| <button class="accordion-button{% if 'show' in options.classes %}" aria-expanded="true{% else %} collapsed{% endif %}" | ||
|
|
@@ -106,7 +117,7 @@ <h2 class="accordion-header"> | |
| {% endif %} | ||
|
|
||
| {% for field in form.visible_fields %} | ||
| {% if field.name in options.fields %} | ||
| {% if field.name in options.fields and field.name not in 'enable_scheduling scheduled_publish_date' %} | ||
| <div class="mt-3 field-{{ field.name }} {% if 'description_' in field.name or 'title_' in field.name %}collapse ms-4{% endif %}{% if 'description_' in field.name %} description{% endif %}{% if 'title_' in field.name %} title{% endif %}{% with 'is_restricted restrict_access_to_groups password' as res %} {% if field.name in res.split %}collapse restricted_access{% endif %}{% endwith %}"> | ||
| <div class="form-group{% if field.field.required %} form-group-required{% endif %}{% if field.errors %} errors{% endif %}{% if "form-control-file" in field.field.widget.attrs.class and form.instance.video %} pod-largelink{% endif %}"> | ||
| {% if "form-check-input" in field.field.widget.attrs.class %} | ||
|
|
@@ -303,6 +314,23 @@ <h2 class="h4 card-header card-title pod-card__title ps-2">{% trans "Help for fo | |
| }); | ||
| change_transcript(); | ||
| } | ||
|
|
||
| document.addEventListener("DOMContentLoaded", function() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ajouter un petit jsdoc |
||
| var checkbox = document.getElementById("id_enable_scheduling"); | ||
| var dateGroup = document.getElementById("scheduled_publish_date_group"); | ||
| if (checkbox) { | ||
| checkbox.addEventListener("change", function() { | ||
| if (checkbox.checked) { | ||
| dateGroup.style.display = "block"; | ||
| } else { | ||
| dateGroup.style.display = "none"; | ||
| var dateInput = document.getElementById("id_scheduled_publish_date"); | ||
| if (dateInput) dateInput.value = ""; | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| </script> | ||
| {% if USE_NOTIFICATIONS and form.instance.encoding_in_progress and request.user.owner.accepts_notifications is not False %} | ||
| <script> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
est-ce que ce fichier binaire peut être créé automatiquement s'il est manquant ?
Si oui, ne pas l'inclure dans le git