Пример #1
0
def object_removed(obj, event):
    """Grant permission to add a file type after removing it."""
    parent = event.oldParent
    if IAudio.providedBy(parent):
        if IMPEGAudioFile.providedBy(obj):
            permission = 'brasil.gov.portal: Add MPEG File'
        elif IOGGAudioFile.providedBy(obj):
            permission = 'brasil.gov.portal: Add OGG File'
        if permission:
            parent.manage_permission(permission, roles=[], acquire=1)
Пример #2
0
def object_added(obj, event):
    """Remove further permission to add a file type after adding it."""
    parent = event.newParent
    if IAudio.providedBy(parent):
        if IMPEGAudioFile.providedBy(obj):
            permission = 'brasil.gov.portal: Add MPEG File'
        elif IOGGAudioFile.providedBy(obj):
            permission = 'brasil.gov.portal: Add OGG File'
        if permission:
            parent.manage_permission(permission, roles=[], acquire=0)
Пример #3
0
def object_removed(event, obj=None):
    if not obj:
        obj = event.object
    parent = event.oldParent
    if IAudio.providedBy(parent):
        if IMPEGAudioFile.providedBy(obj):
            permission = 'brasil.gov.portal: Add MPEG File'
        elif IOGGAudioFile.providedBy(obj):
            permission = 'brasil.gov.portal: Add OGG File'
        if permission:
            parent.manage_permission(permission, roles=[], acquire=1)
Пример #4
0
 def downloads(self):
     downloads = []
     sources = self.sources()
     for obj in sources:
         format = 'MP3'
         if IOGGAudioFile.providedBy(obj):
             format = 'OGG'
         size = obj.file.size
         downloads.append(
             {'format': format,
              'size': sizeof_fmt(size),
              'path': '%s/download' % obj.absolute_url()})
     return downloads
Пример #5
0
 def downloads(self):
     downloads = []
     sources = self.sources()
     for obj in sources:
         format = 'MP3'
         if IOGGAudioFile.providedBy(obj):
             format = 'OGG'
         size = obj.file.size
         downloads.append({
             'format': format,
             'size': sizeof_fmt(size),
             'path': '%s/download' % obj.absolute_url()
         })
     return downloads
 def test_adding(self):
     self.assertTrue(IOGGAudioFile.providedBy(self.ogg_audio))
 def test_adding(self):
     self.assertTrue(IOGGAudioFile.providedBy(self.ogg_audio))
Пример #8
0
 def return_ogg(self):
     """Return the Vorbis version of the audio."""
     sources = self.objectValues()
     for source in sources:
         if IOGGAudioFile.providedBy(source):
             return source
Пример #9
0
 def test_adding(self):
     self._create_content()
     self.assertTrue(IOGGAudioFile.providedBy(self.ogg_audio))
Пример #10
0
 def return_ogg(self):
     sources = self.objectValues()
     for source in sources:
         if IOGGAudioFile.providedBy(source):
             return source