Exemplo n.º 1
0
Arquivo: file.py Projeto: garbas/unep
 def title(self):
     title = get_field(self, 'title', '')
     if self.code:
         title = '(' + self.code + ')' + title
     if not title:
         field = get_field(self, 'file', None)
         if field:
             title = splitext(field.filename)[0]
     return title
Exemplo n.º 2
0
 def title(self):
     title = get_field(self, 'title', '')
     if self.code:
         title = '(' + self.code + ')' + title
     if not title:
         field = get_field(self, 'file', None)
         if field:
             title = splitext(field.filename)[0]
     return title
Exemplo n.º 3
0
    def get_files(self, field_name):
        files = []
        
        for item in getattr(self.context, field_name):
            titles = {}
            if item.to_object:
                code = item.to_object.code
                title = get_field(item.to_object, 'title', '')
                description = get_field(item.to_object, 'description', '')
                languages = []

                if not title:
                    title = item.to_object.id

                _file = {
                    'code': code,
                    'title': title,
                    'description': description,
                    'uid': item.to_object.UID(),
                    'url': item.to_object.absolute_url(),
                    
                }

                if item.to_object.en_file:
                    languages.append('en')
                if item.to_object.es_file:
                    languages.append('es')
                if item.to_object.fr_file:
                    languages.append('fr')

                titles['en'] = titles['es'] = titles['fr'] = None    
                if item.to_object.en_title:
                    titles['en'] = item.to_object.en_title     
                if item.to_object.es_title:
                    titles['es'] = item.to_object.es_title
                if item.to_object.fr_title:
                    titles['fr'] = item.to_object.fr_title
                    
                _file['languages'] = languages
                _file['titles'] = titles
                
                files.append(_file)
        return files
Exemplo n.º 4
0
    def get_files(self, field_name):
        files = []

        for item in getattr(self.context, field_name):
            titles = {}
            if item.to_object:
                code = item.to_object.code
                title = get_field(item.to_object, 'title', '')
                description = get_field(item.to_object, 'description', '')
                languages = []

                if not title:
                    title = item.to_object.id

                _file = {
                    'code': code,
                    'title': title,
                    'description': description,
                    'uid': item.to_object.UID(),
                    'url': item.to_object.absolute_url(),
                }

                if item.to_object.en_file:
                    languages.append('en')
                if item.to_object.es_file:
                    languages.append('es')
                if item.to_object.fr_file:
                    languages.append('fr')

                titles['en'] = titles['es'] = titles['fr'] = None
                if item.to_object.en_title:
                    titles['en'] = item.to_object.en_title
                if item.to_object.es_title:
                    titles['es'] = item.to_object.es_title
                if item.to_object.fr_title:
                    titles['fr'] = item.to_object.fr_title

                _file['languages'] = languages
                _file['titles'] = titles

                files.append(_file)
        return files
Exemplo n.º 5
0
 def description(self):
     return get_field(self, 'description', '')
Exemplo n.º 6
0
 def title(self):
     return get_field(self, 'title', '')
Exemplo n.º 7
0
 def description(self):
     return get_field(self, 'description', '')
Exemplo n.º 8
0
 def title(self):
     return get_field(self, 'title', '')