forked from rc/aircox
		
	iss #6: sort diffusion by start in explorer + space between artist and title
This commit is contained in:
		@ -40,7 +40,7 @@ class Actions:
 | 
				
			|||||||
            items = schedule.diffusions_of_month(date, exclude_saved = True)
 | 
					            items = schedule.diffusions_of_month(date, exclude_saved = True)
 | 
				
			||||||
            count[0] += len(items)
 | 
					            count[0] += len(items)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # we can't bulk create because we ned signal processing
 | 
					            # we can't bulk create because we need signal processing
 | 
				
			||||||
            for item in items:
 | 
					            for item in items:
 | 
				
			||||||
                conflicts = item.get_conflicts()
 | 
					                conflicts = item.get_conflicts()
 | 
				
			||||||
                item.type = Diffusion.Type.unconfirmed \
 | 
					                item.type = Diffusion.Type.unconfirmed \
 | 
				
			||||||
 | 
				
			|||||||
@ -17,6 +17,7 @@ ensure('AIRCOX_DEFAULT_USER_GROUPS', {
 | 
				
			|||||||
        'change_sound',
 | 
					        'change_sound',
 | 
				
			||||||
        'add_track', 'change_track', 'delete_track',
 | 
					        'add_track', 'change_track', 'delete_track',
 | 
				
			||||||
        'add_tag', 'change_tag', 'delete_tag',
 | 
					        'add_tag', 'change_tag', 'delete_tag',
 | 
				
			||||||
 | 
					        'add_comment', 'edit_comment', 'delete_comment',
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    # ensure user can log in using Wagtail
 | 
					    # ensure user can log in using Wagtail
 | 
				
			||||||
    'Editors': None
 | 
					    'Editors': None
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,7 @@ from django.contrib.auth.models import User, Group, Permission
 | 
				
			|||||||
from django.contrib.contenttypes.models import ContentType
 | 
					from django.contrib.contenttypes.models import ContentType
 | 
				
			||||||
from django.db.models import F
 | 
					from django.db.models import F
 | 
				
			||||||
from django.db.models.signals import post_save, pre_save, pre_delete, m2m_changed
 | 
					from django.db.models.signals import post_save, pre_save, pre_delete, m2m_changed
 | 
				
			||||||
from django.dispatch import receiver
 | 
					from django.dispatch import receiver, Signal
 | 
				
			||||||
from django.utils import timezone as tz
 | 
					from django.utils import timezone as tz
 | 
				
			||||||
from django.utils.translation import ugettext as _, ugettext_lazy
 | 
					from django.utils.translation import ugettext as _, ugettext_lazy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -12,6 +12,8 @@ import aircox.models as models
 | 
				
			|||||||
import aircox.utils as utils
 | 
					import aircox.utils as utils
 | 
				
			||||||
import aircox.settings as settings
 | 
					import aircox.settings as settings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add a default group to a user when it is created. It also assigns a list
 | 
					# Add a default group to a user when it is created. It also assigns a list
 | 
				
			||||||
# of permissions to the group if it is created.
 | 
					# of permissions to the group if it is created.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
				
			|||||||
@ -519,8 +519,6 @@ class Track(aircox.models.Track,Orderable):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DiffusionPage(Publication):
 | 
					class DiffusionPage(Publication):
 | 
				
			||||||
    order_field = 'diffusion__start'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    diffusion = models.OneToOneField(
 | 
					    diffusion = models.OneToOneField(
 | 
				
			||||||
        aircox.models.Diffusion,
 | 
					        aircox.models.Diffusion,
 | 
				
			||||||
        verbose_name = _('diffusion'),
 | 
					        verbose_name = _('diffusion'),
 | 
				
			||||||
@ -641,6 +639,9 @@ class DiffusionPage(Publication):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def save(self, *args, **kwargs):
 | 
					    def save(self, *args, **kwargs):
 | 
				
			||||||
        if self.diffusion:
 | 
					        if self.diffusion:
 | 
				
			||||||
 | 
					            # force to sort by diffusion date in wagtail explorer
 | 
				
			||||||
 | 
					            self.latest_revision_created_at = self.diffusion.start
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # set publish_as
 | 
					            # set publish_as
 | 
				
			||||||
            if not self.pk:
 | 
					            if not self.pk:
 | 
				
			||||||
                self.publish_as = self.diffusion.program.page
 | 
					                self.publish_as = self.diffusion.program.page
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,11 @@
 | 
				
			|||||||
from django.db.models import Q
 | 
					from django.db.models import Q
 | 
				
			||||||
from django.db.models.signals import post_save, pre_delete
 | 
					from django.db.models.signals import post_save, pre_delete
 | 
				
			||||||
from django.dispatch import receiver
 | 
					from django.dispatch import receiver
 | 
				
			||||||
 | 
					from django.utils import timezone as tz
 | 
				
			||||||
from django.utils.translation import ugettext as _, ugettext_lazy
 | 
					from django.utils.translation import ugettext as _, ugettext_lazy
 | 
				
			||||||
from django.contrib.contenttypes.models import ContentType
 | 
					from django.contrib.contenttypes.models import ContentType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from wagtail.wagtailcore.models import Page, Site
 | 
					from wagtail.wagtailcore.models import Page, Site, PageRevision
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import aircox.models as aircox
 | 
					import aircox.models as aircox
 | 
				
			||||||
import aircox_cms.models as models
 | 
					import aircox_cms.models as models
 | 
				
			||||||
@ -185,10 +186,16 @@ def diffusion_post_saved(sender, instance, created, *args, **kwargs):
 | 
				
			|||||||
    page = models.DiffusionPage.from_diffusion(
 | 
					    page = models.DiffusionPage.from_diffusion(
 | 
				
			||||||
        instance, live = False
 | 
					        instance, live = False
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    instance.program.page.add_child(
 | 
					    page = instance.program.page.add_child(
 | 
				
			||||||
        instance = page
 | 
					        instance = page
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # because wagtail don't have custom order field in explorer
 | 
				
			||||||
 | 
					    rev = PageRevision(page = page,
 | 
				
			||||||
 | 
					                       created_at = page.date - tz.timedelta(days = 365*5),
 | 
				
			||||||
 | 
					                       content_json = '{}')
 | 
				
			||||||
 | 
					    rev.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@receiver(pre_delete, sender=aircox.Diffusion)
 | 
					@receiver(pre_delete, sender=aircox.Diffusion)
 | 
				
			||||||
def diffusion_pre_deleted(sender, instance, *args, **kwargs):
 | 
					def diffusion_pre_deleted(sender, instance, *args, **kwargs):
 | 
				
			||||||
    clean_page_of(instance)
 | 
					    clean_page_of(instance)
 | 
				
			||||||
 | 
				
			|||||||
@ -222,3 +222,12 @@ main.detail {
 | 
				
			|||||||
    color: #616161;
 | 
					    color: #616161;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					section.playlist .artist {
 | 
				
			||||||
 | 
					    display: inline-block;
 | 
				
			||||||
 | 
					    margin-right: 0.4em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					section.playlist .artist:after {
 | 
				
			||||||
 | 
					    padding-left: 0.2em;
 | 
				
			||||||
 | 
					    content: ':'
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user