예제 #1
0
            'pk': self.pk
        }) + ''


    def get_root(self):

        if not self.parent:
            return None

        if self.parent == self:
            return None

        parent = self.parent
        last_parent = None
        i = 0
        while parent and i < 10:
            i += 1
            parent = parent.parent
            if parent:
                last_parent = parent

        return last_parent

    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)
        super(Label, self).save(*args, **kwargs)


tagging_register(Label)
arating.enable_voting_on(Label)
예제 #2
0
                ad_d = 1
            
            rd = datetime.strptime('%s/%s/%s' % (ad_y, ad_m, ad_d), '%Y/%m/%d')
            self.releasedate = rd
        except:
            self.releasedate = None
        
        super(Release, self).save(*args, **kwargs)

try:
    tagging.register(Release)
except:
    pass


arating.enable_voting_on(Release)
post_save.connect(library_post_save, sender=Release)  


""""""
from actstream import action
def action_handler(sender, instance, created, **kwargs):
    try:
        verb = _('updated')
        if created:
            verb = _('created')
        action.send(instance.get_last_editor(), verb=verb, target=instance)
    except Exception, e:
        print e

post_save.connect(action_handler, sender=Release)
예제 #3
0
        """

        if self.name == 'Various Artists' and self.pk is None:
            log.warning('attempt to create "Various Artists"')
            original_name = self.name
            i = 1
            while Artist.objects.filter(name=self.name).count() > 0:
                self.name = u'%s %s' % (original_name, i)
                i += 1

        super(Artist, self).save(*args, **kwargs)



tagging_register(Artist)
arating.enable_voting_on(Artist)

# @receiver(post_save, sender=Artist)
# def action_handler(sender, instance, created, **kwargs):
#     try:
#         action_handler_task.delay(instance, created)
#     except:
#         pass
#
# @task
# def action_handler_task(instance, created):
#     if created and instance.creator:
#         action.send(instance.creator, verb=_('created'), target=instance)
#
#     elif instance.last_editor:
#         action.send(instance.last_editor, verb=_('updated'), target=instance)
예제 #4
0
    obj = kwargs['instance']

    # delete associated master file
    if obj.master and os.path.isfile(obj.master.path):
        os.unlink(obj.master.path)

    # delete fingerprint
    delete_fprint_for_media.apply_async((obj.uuid,))


pre_delete.connect(media_pre_delete, sender=Media)



arating.enable_voting_on(Media)

try:
    tagging_register(Media)
except Exception as e:
    pass


class MediaExtraartists(models.Model):

    artist = models.ForeignKey(
        'alibrary.Artist',
        related_name='extraartist_artist',
        blank=True, null=True, on_delete=models.CASCADE
    )
    media = models.ForeignKey(
예제 #5
0
    @models.permalink
    def get_absolute_url(self):
        return ('abcast-station-detail', [self.slug])

    """
    @models.permalink
    def get_edit_url(self):
        return ('alibrary-artist-edit', [self.pk])
    """

    def get_admin_url(self):
        from lib.util.get_admin_url import change_url
        return change_url(self)


arating.enable_voting_on(Station)



class Role(BaseModel):

    name = models.CharField(max_length=200)

    # meta
    class Meta:
        app_label = 'abcast'
        verbose_name = _('Role')
        verbose_name_plural = _('Roles')
        ordering = ('name', )

    def __unicode__(self):
예제 #6
0
        #     'pk': self.pk
        # })

    def get_groups(self):
        return self.user.groups

    def save(self, *args, **kwargs):
        super(Profile, self).save(*args, **kwargs)


try:
    tagging_register(Profile)
except:
    pass

arating.enable_voting_on(Profile)


class Community(UUIDModelMixin, MigrationMixin):

    name = models.CharField(max_length=200, db_index=True)
    slug = AutoSlugField(populate_from='name',
                         editable=True,
                         blank=True,
                         overwrite=True)

    group = models.OneToOneField(Group, unique=True, null=True, blank=True)
    members = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True)

    # auto-update
    created = models.DateTimeField(auto_now_add=True, editable=False)
예제 #7
0
        t_tags = ''
        """
        for tag in self.tags:
            t_tags += '%s, ' % tag    
        
        self.tags = t_tags;
        self.d_tags = t_tags;
        """
        super(Profile, self).save(*args, **kwargs)

try:
    tagging.register(Profile)
except:
    pass

arating.enable_voting_on(Profile)


def create_profile(sender, instance, created, **kwargs):
    
    if created:  
       profile, created = Profile.objects.get_or_create(user=instance)
       
       default_group, created = Group.objects.get_or_create(name=DEFAULT_GROUP)
       instance.groups.add(default_group)
       instance.save()
       
post_save.connect(create_profile, sender=User) 


def add_to_group(sender, instance, **kwargs):
예제 #8
0
            if parent:
                last_parent = parent

        return last_parent



    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)
        super(Label, self).save(*args, **kwargs)




tagging_register(Label)
arating.enable_voting_on(Label)


# @receiver(post_save, sender=Label, dispatch_uid="label_post_save")
# def action_handler_task(sender, instance, created, **kwargs):
#
#     if created and instance.creator:
#         action.send(instance.creator, verb=_('created'), target=instance)
#
#     elif instance.last_editor:
#         action.send(instance.last_editor, verb=_('updated'), target=instance)


# def action_handler(sender, instance, created, **kwargs):
#     action_handler_task.delay(instance, created)
#
예제 #9
0
        t_tags = ''
        """"""
        for tag in self.tags:
            t_tags += '%s, ' % tag    
        
        self.tags = t_tags;
        self.d_tags = t_tags[:1000];
        
        super(Profile, self).save(*args, **kwargs)

try:
    tagging.register(Profile)
except:
    pass

arating.enable_voting_on(Profile)


class Community(MigrationMixin):
    
    uuid = UUIDField(primary_key=False)
    name = models.CharField(max_length=200, db_index=True)
    slug = AutoSlugField(populate_from='name', editable=True, blank=True, overwrite=True)
    
    group = models.OneToOneField(Group, unique=True, null=True, blank=True)
    members = models.ManyToManyField(User, null=True, blank=True)
    
    # auto-update
    created = models.DateTimeField(auto_now_add=True, editable=False)
    updated = models.DateTimeField(auto_now=True, editable=False)
예제 #10
0
        # map to object status (not extremly dry - we know...)
        if self.broadcast_status == 1:
            self.status = 1  # 'ready'
        else:
            self.status = 99  # 'error'

        # self.user = request.user
        super(Playlist, self).save(*args, **kwargs)


try:
    tagging_register(Playlist)
except Exception as e:
    pass

arating.enable_voting_on(Playlist)


@receiver(post_save, sender=Playlist)
def playlist_post_save(sender, instance, **kwargs):

    if not instance.type == 'broadcast':
        return

    if instance.mixdown_file:
        return

    if instance.mixdown:
        return

    log.debug('no mixdown yet for {} - request to generate'.format(instance.name))
예제 #11
0
                ad_d = 1

            rd = datetime.strptime('%s/%s/%s' % (ad_y, ad_m, ad_d), '%Y/%m/%d')
            self.releasedate = rd
        except:
            self.releasedate = None

        super(Release, self).save(*args, **kwargs)


try:
    tagging.register(Release)
except:
    pass

arating.enable_voting_on(Release)
post_save.connect(library_post_save, sender=Release)
""""""
from actstream import action


def action_handler(sender, instance, created, **kwargs):
    try:
        verb = _('updated')
        if created:
            verb = _('created')
        action.send(instance.get_last_editor(), verb=verb, target=instance)
    except Exception, e:
        print e

예제 #12
0
        for tag in self.tags:
            t_tags += '%s, ' % tag

        self.tags = t_tags
        self.d_tags = t_tags

        super(Artist, self).save(*args, **kwargs)


try:
    tagging.register(Artist)
except:
    pass

# register
arating.enable_voting_on(Artist)
post_save.connect(library_post_save, sender=Artist)

from actstream import action


def action_handler(sender, instance, created, **kwargs):
    try:
        action.send(instance.get_last_editor(),
                    verb=_('updated'),
                    target=instance)
    except Exception, e:
        print e


post_save.connect(action_handler, sender=Artist)
예제 #13
0
def media_pre_delete(sender, **kwargs):

    obj = kwargs['instance']

    # delete associated master file
    if obj.master and os.path.isfile(obj.master.path):
        os.unlink(obj.master.path)

    # delete fingerprint
    delete_fprint_for_media.apply_async((obj, ))


pre_delete.connect(media_pre_delete, sender=Media)

arating.enable_voting_on(Media)

try:
    tagging_register(Media)
except Exception as e:
    pass


class MediaExtraartists(models.Model):

    artist = models.ForeignKey('alibrary.Artist',
                               related_name='extraartist_artist',
                               blank=True,
                               null=True,
                               on_delete=models.CASCADE)
    media = models.ForeignKey('Media',
예제 #14
0
        self.broadcast_status, self.broadcast_status_messages = self.self_check(
        )
        if self.broadcast_status == 1:
            self.status = 1  # 'ready'
        else:
            self.status = 99  # 'error'

        super(Playlist, self).save(*args, **kwargs)


try:
    tagging_register(Playlist)
except Exception as e:
    pass

arating.enable_voting_on(Playlist)


@receiver(post_save, sender=Playlist)
def playlist_post_save(sender, instance, **kwargs):

    if not instance.type == 'broadcast':
        return

    if instance.mixdown_file:
        return

    if instance.mixdown:
        return

    log.debug('no mixdown yet for {} - request to generate'.format(
예제 #15
0
        verbose_name = _('Station')
        verbose_name_plural = _('Stations')
        ordering = ('name', )

    def __unicode__(self):
        return "%s" % self.name

    @models.permalink
    def get_absolute_url(self):
        return 'abcast-station-detail', [self.slug]

    def get_admin_url(self):
        return reverse("admin:abcast_station_change", args=(self.pk,))


arating.enable_voting_on(Station)



class Role(BaseModel):

    name = models.CharField(max_length=200)

    class Meta:
        app_label = 'abcast'
        verbose_name = _('Role')
        verbose_name_plural = _('Roles')
        ordering = ('name', )

    def __unicode__(self):
        return self.name