"Sync now" button
This commit is contained in:
		
							parent
							
								
									e871983707
								
							
						
					
					
						commit
						55c58b4836
					
				| 
						 | 
					@ -65,6 +65,7 @@ readers do not read off random characters that represent icons */
 | 
				
			||||||
.#{$fa-css-prefix}-arrows-alt-h:before { content: fa-content($fa-var-arrows-alt-h); }
 | 
					.#{$fa-css-prefix}-arrows-alt-h:before { content: fa-content($fa-var-arrows-alt-h); }
 | 
				
			||||||
.#{$fa-css-prefix}-arrows-alt-v:before { content: fa-content($fa-var-arrows-alt-v); }
 | 
					.#{$fa-css-prefix}-arrows-alt-v:before { content: fa-content($fa-var-arrows-alt-v); }
 | 
				
			||||||
.#{$fa-css-prefix}-artstation:before { content: fa-content($fa-var-artstation); }
 | 
					.#{$fa-css-prefix}-artstation:before { content: fa-content($fa-var-artstation); }
 | 
				
			||||||
 | 
					.#{$fa-css-prefix}-arrow-rotate-right:before { content: fa-content($fa-var-arrow-rotate-right); }
 | 
				
			||||||
.#{$fa-css-prefix}-assistive-listening-systems:before { content: fa-content($fa-var-assistive-listening-systems); }
 | 
					.#{$fa-css-prefix}-assistive-listening-systems:before { content: fa-content($fa-var-assistive-listening-systems); }
 | 
				
			||||||
.#{$fa-css-prefix}-asterisk:before { content: fa-content($fa-var-asterisk); }
 | 
					.#{$fa-css-prefix}-asterisk:before { content: fa-content($fa-var-asterisk); }
 | 
				
			||||||
.#{$fa-css-prefix}-asymmetrik:before { content: fa-content($fa-var-asymmetrik); }
 | 
					.#{$fa-css-prefix}-asymmetrik:before { content: fa-content($fa-var-asymmetrik); }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,6 +80,7 @@ $fa-var-arrow-right: \f061;
 | 
				
			||||||
$fa-var-arrow-up: \f062;
 | 
					$fa-var-arrow-up: \f062;
 | 
				
			||||||
$fa-var-arrows-alt: \f0b2;
 | 
					$fa-var-arrows-alt: \f0b2;
 | 
				
			||||||
$fa-var-arrows-alt-h: \f337;
 | 
					$fa-var-arrows-alt-h: \f337;
 | 
				
			||||||
 | 
					$fa-var-arrow-rotate-right: \f01e;
 | 
				
			||||||
$fa-var-arrows-alt-v: \f338;
 | 
					$fa-var-arrows-alt-v: \f338;
 | 
				
			||||||
$fa-var-artstation: \f77a;
 | 
					$fa-var-artstation: \f77a;
 | 
				
			||||||
$fa-var-assistive-listening-systems: \f2a2;
 | 
					$fa-var-assistive-listening-systems: \f2a2;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,3 +17,13 @@ html {
 | 
				
			||||||
    visibility: visible;
 | 
					    visibility: visible;
 | 
				
			||||||
    opacity: 1;
 | 
					    opacity: 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.flex-collection-container {
 | 
				
			||||||
 | 
					    display: flex !important;
 | 
				
			||||||
 | 
					    align-items: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.flex-grow {
 | 
				
			||||||
 | 
					    flex-grow: 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
| 
						 | 
					@ -24,15 +24,18 @@
 | 
				
			||||||
  <div class="col s12">
 | 
					  <div class="col s12">
 | 
				
			||||||
    <div class="collection">
 | 
					    <div class="collection">
 | 
				
			||||||
    {% for source in sources %}
 | 
					    {% for source in sources %}
 | 
				
			||||||
      <a href="{% url 'sync:source' pk=source.pk %}" class="collection-item">
 | 
					      <span class="collection-item flex-collection-container">
 | 
				
			||||||
        {{ source.icon|safe }} <strong>{{ source.name }}</strong> ({{ source.get_source_type_display }} "{{ source.key }}")<br>
 | 
					        <a href="{% url 'sync:source' pk=source.pk %}" class="flex-grow">
 | 
				
			||||||
        {{ source.format_summary }}<br>
 | 
					          {{ source.icon|safe }} <strong>{{ source.name }}</strong> ({{ source.get_source_type_display }} "{{ source.key }}")<br>
 | 
				
			||||||
        {% if source.has_failed %}
 | 
					          {{ source.format_summary }}<br>
 | 
				
			||||||
        <span class="error-text"><i class="fas fa-exclamation-triangle"></i> <strong>Source has permanent failures</strong></span>
 | 
					          {% if source.has_failed %}
 | 
				
			||||||
        {% else %}
 | 
					          <span class="error-text"><i class="fas fa-exclamation-triangle"></i> <strong>Source has permanent failures</strong></span>
 | 
				
			||||||
        <strong>{{ source.media_count }}</strong> media items, <strong>{{ source.downloaded_count }}</strong> downloaded{% if source.delete_old_media and source.days_to_keep > 0 %}, keeping {{ source.days_to_keep }} days of media{% endif %}
 | 
					          {% else %}
 | 
				
			||||||
        {% endif %}
 | 
					          <strong>{{ source.media_count }}</strong> media items, <strong>{{ source.downloaded_count }}</strong> downloaded{% if source.delete_old_media and source.days_to_keep > 0 %}, keeping {{ source.days_to_keep }} days of media{% endif %}
 | 
				
			||||||
      </a>
 | 
					          {% endif %}
 | 
				
			||||||
 | 
					        </a>
 | 
				
			||||||
 | 
					        <a href="{% url 'sync:source-sync-now' pk=source.pk %}" class="collection-item"><i class="fas fa-arrow-rotate-right"></i></a>
 | 
				
			||||||
 | 
					      </span>
 | 
				
			||||||
    {% empty %}
 | 
					    {% empty %}
 | 
				
			||||||
      <span class="collection-item no-items"><i class="fas fa-info-circle"></i> You haven't added any sources.</span>
 | 
					      <span class="collection-item no-items"><i class="fas fa-info-circle"></i> You haven't added any sources.</span>
 | 
				
			||||||
    {% endfor %}
 | 
					    {% endfor %}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,7 +66,7 @@
 | 
				
			||||||
      {% for task in scheduled %}
 | 
					      {% for task in scheduled %}
 | 
				
			||||||
        <a href="{% url task.url pk=task.instance.pk %}" class="collection-item">
 | 
					        <a href="{% url task.url pk=task.instance.pk %}" class="collection-item">
 | 
				
			||||||
          <i class="fas fa-stopwatch"></i> <strong>{{ task }}</strong><br>
 | 
					          <i class="fas fa-stopwatch"></i> <strong>{{ task }}</strong><br>
 | 
				
			||||||
          {% if task.instance.index_schedule %}Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.<br>{% endif %}
 | 
					          {% if task.instance.index_schedule and task.repeat > 0 %}Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.<br>{% endif %}
 | 
				
			||||||
          <i class="fas fa-redo"></i> Task will run {% if task.run_now %}<strong>immediately</strong>{% else %}at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>{% endif %}
 | 
					          <i class="fas fa-redo"></i> Task will run {% if task.run_now %}<strong>immediately</strong>{% else %}at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>{% endif %}
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
      {% empty %}
 | 
					      {% empty %}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,10 @@ urlpatterns = [
 | 
				
			||||||
         ValidateSourceView.as_view(),
 | 
					         ValidateSourceView.as_view(),
 | 
				
			||||||
         name='validate-source'),
 | 
					         name='validate-source'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    path('source-sync-now/<uuid:pk>',
 | 
				
			||||||
 | 
					         SourcesView.as_view(),
 | 
				
			||||||
 | 
					         name='source-sync-now'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    path('source-add',
 | 
					    path('source-add',
 | 
				
			||||||
         AddSourceView.as_view(),
 | 
					         AddSourceView.as_view(),
 | 
				
			||||||
         name='add-source'),
 | 
					         name='add-source'),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@ from base64 import b64decode
 | 
				
			||||||
import pathlib
 | 
					import pathlib
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
from django.conf import settings
 | 
					from django.conf import settings
 | 
				
			||||||
from django.http import FileResponse, Http404, HttpResponseNotFound
 | 
					from django.http import FileResponse, Http404, HttpResponseNotFound, HttpResponseRedirect
 | 
				
			||||||
from django.views.generic import TemplateView, ListView, DetailView
 | 
					from django.views.generic import TemplateView, ListView, DetailView
 | 
				
			||||||
from django.views.generic.edit import (FormView, FormMixin, CreateView, UpdateView,
 | 
					from django.views.generic.edit import (FormView, FormMixin, CreateView, UpdateView,
 | 
				
			||||||
                                       DeleteView)
 | 
					                                       DeleteView)
 | 
				
			||||||
| 
						 | 
					@ -96,8 +96,27 @@ class SourcesView(ListView):
 | 
				
			||||||
    paginate_by = settings.SOURCES_PER_PAGE
 | 
					    paginate_by = settings.SOURCES_PER_PAGE
 | 
				
			||||||
    messages = {
 | 
					    messages = {
 | 
				
			||||||
        'source-deleted': _('Your selected source has been deleted.'),
 | 
					        'source-deleted': _('Your selected source has been deleted.'),
 | 
				
			||||||
 | 
					        'source-refreshed': _('The source has been scheduled to be synced now.')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get(self, *args, **kwargs):
 | 
				
			||||||
 | 
					        if args[0].path.startswith("/source-sync-now/"):
 | 
				
			||||||
 | 
					            sobj = Source.objects.get(pk=kwargs["pk"])
 | 
				
			||||||
 | 
					            if sobj is None:
 | 
				
			||||||
 | 
					                return HttpResponseNotFound()
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            verbose_name = _('Index media from source "{}" once')
 | 
				
			||||||
 | 
					            index_source_task(
 | 
				
			||||||
 | 
					                str(sobj.pk),
 | 
				
			||||||
 | 
					                queue=str(sobj.pk),
 | 
				
			||||||
 | 
					                repeat=0,
 | 
				
			||||||
 | 
					                verbose_name=verbose_name.format(sobj.name))
 | 
				
			||||||
 | 
					            url = reverse_lazy('sync:sources')
 | 
				
			||||||
 | 
					            url = append_uri_params(url, {'message': 'source-refreshed'})
 | 
				
			||||||
 | 
					            return HttpResponseRedirect(url)
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            return super().get(self, *args, **kwargs)    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, *args, **kwargs):
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
        self.message = None
 | 
					        self.message = None
 | 
				
			||||||
        super().__init__(*args, **kwargs)
 | 
					        super().__init__(*args, **kwargs)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue