player end of playlist, switch to live
This commit is contained in:
		@ -78,13 +78,13 @@ class Program(Page):
 | 
				
			|||||||
        """ Return absolute path to program's dir """
 | 
					        """ Return absolute path to program's dir """
 | 
				
			||||||
        return os.path.join(conf.MEDIA_ROOT, self.path)
 | 
					        return os.path.join(conf.MEDIA_ROOT, self.path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def archives_path(self, abs=False):
 | 
					    @property
 | 
				
			||||||
        return os.path.join(abs and self.abspath or self.path,
 | 
					    def archives_path(self):
 | 
				
			||||||
                            settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
					        return os.path.join(self.path, settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def excerpts_path(self, abs=False):
 | 
					    @property
 | 
				
			||||||
        return os.path.join(abs and self.abspath or self.path,
 | 
					    def excerpts_path(self):
 | 
				
			||||||
                            settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
					        return os.path.join(self.path, settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, *kargs, **kwargs):
 | 
					    def __init__(self, *kargs, **kwargs):
 | 
				
			||||||
        super().__init__(*kargs, **kwargs)
 | 
					        super().__init__(*kargs, **kwargs)
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@ from enum import IntEnum
 | 
				
			|||||||
import logging
 | 
					import logging
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.conf import settings as main_settings
 | 
					from django.conf import settings as conf
 | 
				
			||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
from django.db.models import Q, Value as V
 | 
					from django.db.models import Q, Value as V
 | 
				
			||||||
from django.db.models.functions import Concat
 | 
					from django.db.models.functions import Concat
 | 
				
			||||||
@ -48,20 +48,19 @@ class SoundQuerySet(models.QuerySet):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def paths(self, archive=True, order_by=True):
 | 
					    def paths(self, archive=True, order_by=True):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Return paths as a flat list (exclude sound without path).
 | 
					        Return files absolute paths as a flat list (exclude sound without path).
 | 
				
			||||||
        If `order_by` is True, order by path.
 | 
					        If `order_by` is True, order by path.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        if archive:
 | 
					        if archive:
 | 
				
			||||||
            self = self.archive()
 | 
					            self = self.archive()
 | 
				
			||||||
        if order_by:
 | 
					        if order_by:
 | 
				
			||||||
            self = self.order_by('path')
 | 
					            self = self.order_by('file')
 | 
				
			||||||
        return self.filter(file__isnull=False) \
 | 
					        return [os.path.join(conf.MEDIA_ROOT, file) for file in self.filter(file__isnull=False) \
 | 
				
			||||||
                   .annotate(file_path=Concat(V(conf.MEDIA_ROOT), 'file'))  \
 | 
					                   .values_list('file', flat=True)]
 | 
				
			||||||
                   .values_list('file_path', flat=True)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def search(self, query):
 | 
					    def search(self, query):
 | 
				
			||||||
        return self.filter(
 | 
					        return self.filter(
 | 
				
			||||||
            Q(name__icontains=query) | Q(path__icontains=query) |
 | 
					            Q(name__icontains=query) | Q(file__icontains=query) |
 | 
				
			||||||
            Q(program__title__icontains=query) |
 | 
					            Q(program__title__icontains=query) |
 | 
				
			||||||
            Q(episode__title__icontains=query)
 | 
					            Q(episode__title__icontains=query)
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
@ -179,7 +178,7 @@ class Sound(models.Model):
 | 
				
			|||||||
        if self.type == self.TYPE_REMOVED and self.program:
 | 
					        if self.type == self.TYPE_REMOVED and self.program:
 | 
				
			||||||
            changed = True
 | 
					            changed = True
 | 
				
			||||||
            self.type = self.TYPE_ARCHIVE \
 | 
					            self.type = self.TYPE_ARCHIVE \
 | 
				
			||||||
                if self.file.path.startswith(self.program.archives_path) else \
 | 
					                if self.file.name.startswith(self.program.archives_path) else \
 | 
				
			||||||
                self.TYPE_EXCERPT
 | 
					                self.TYPE_EXCERPT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # check mtime -> reset quality if changed (assume file changed)
 | 
					        # check mtime -> reset quality if changed (assume file changed)
 | 
				
			||||||
@ -195,7 +194,7 @@ class Sound(models.Model):
 | 
				
			|||||||
        return changed
 | 
					        return changed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __check_name(self):
 | 
					    def __check_name(self):
 | 
				
			||||||
        if not self.name and self.file and self.file.path:
 | 
					        if not self.name and self.file and self.file.name:
 | 
				
			||||||
            # FIXME: later, remove date?
 | 
					            # FIXME: later, remove date?
 | 
				
			||||||
            self.name = os.path.basename(self.file.name)
 | 
					            self.name = os.path.basename(self.file.name)
 | 
				
			||||||
            self.name = os.path.splitext(self.name)[0]
 | 
					            self.name = os.path.splitext(self.name)[0]
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -180,7 +180,7 @@ export default {
 | 
				
			|||||||
            let src = null;
 | 
					            let src = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // from playlist
 | 
					            // from playlist
 | 
				
			||||||
            if(playlist !== null) {
 | 
					            if(playlist !== null && index != -1) {
 | 
				
			||||||
                let item = this.$refs[playlist].get(index);
 | 
					                let item = this.$refs[playlist].get(index);
 | 
				
			||||||
                if(!item)
 | 
					                if(!item)
 | 
				
			||||||
                    throw `No sound at index ${index} for playlist ${playlist}`;
 | 
					                    throw `No sound at index ${index} for playlist ${playlist}`;
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user