예제 #1
0
파일: file.py 프로젝트: 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
예제 #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
예제 #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
예제 #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
예제 #5
0
 def description(self):
     return get_field(self, 'description', '')
예제 #6
0
 def title(self):
     return get_field(self, 'title', '')
예제 #7
0
 def description(self):
     return get_field(self, 'description', '')
예제 #8
0
 def title(self):
     return get_field(self, 'title', '')