def get_supplement_data(self, f):
     # додаткові дані для передачі в шаблон через XHR,
     # які простіше отримати в Python і використати в js
     # для зміни / створення нового рядка в таблиці
     if f:
         data = {}
         fileExt  = None
         fileType = None
         iconPath = None
         m = f._meta.model_name
         if m == 'folder':
             fileExt  = ""
             fileType = "folder"
             iconPath = STATIC_URL + get_iconPathForFolder()
         if m == 'report':
             (name, ext) = os.path.splitext(f.filename)
             fileExt  = ext
             fileType = "report"
             iconPath = STATIC_URL + get_iconPathByFileExt(ext)
         data['iconPath'] = iconPath
         data['fileExt' ] = fileExt
         data['fileType'] = fileType
     else:
         data = None
     return data
Example #2
0
 def get_supplement_data(self, f):
     # додаткові дані для передачі в шаблон через XHR,
     # які простіше отримати в Python і використати в js
     # для зміни / створення нового рядка в таблиці
     if f:
         data = {}
         fileExt  = None
         fileType = None
         iconPath = None
         m = f._meta.model_name
         if m == 'folder':
             fileExt  = ""
             fileType = "folder"
             iconPath = STATIC_URL + get_iconPathForFolder()
         if m == 'report':
             (name, ext) = os.path.splitext(f.filename)
             fileExt  = ext
             fileType = "report"
             iconPath = STATIC_URL + get_iconPathByFileExt(ext)
         data['iconPath'] = iconPath
         data['fileExt' ] = fileExt
         data['fileType'] = fileType
     else:
         data = None
     return data
def iconpath(f):
    m = f._meta.model_name
    if m == 'folder':
        p = get_iconPathForFolder()
    elif m == 'report' and f.file:
        try:    e = os.path.splitext(f.filename)[1]  # [0] returns path+filename
        except: e = ""
        p = get_iconPathByFileExt(e)
    else:
        p = ''
    return p
Example #4
0
def iconpath(f):
    m = f._meta.model_name
    if m == 'folder':
        p = get_iconPathForFolder()
    elif m == 'report' and f.file:
        try:
            e = os.path.splitext(f.filename)[1]  # [0] returns path+filename
        except:
            e = ""
        p = get_iconPathByFileExt(e)
    else:
        p = ''
    return p
 def test_get_iconPathByFileExt(self):
     self.assertEqual(get_iconPathByFileExt(""),
                      "img/file-icons/32px/_page.png")
     self.assertEqual(get_iconPathByFileExt(".doc"),
                      'img/file-icons/32px/doc.png')
Example #6
0
 def test_iconpath(self):
     r0 = DummyFolder().create_dummy_report(self.root)
     self.assertEqual(iconpath(self.root), get_iconPathForFolder())
     self.assertEqual(iconpath(self.report), get_iconPathByFileExt('.txt'))
     self.assertEqual(iconpath(r0), "")
     self.assertEqual(fileext(''), '')
Example #7
0
 def test_get_iconPathByFileExt(self):
     self.assertEqual(get_iconPathByFileExt(""), "img/file-icons/32px/_page.png")
     self.assertEqual(get_iconPathByFileExt(".doc"), 'img/file-icons/32px/doc.png')
 def test_iconpath(self):
     r0 = DummyFolder().create_dummy_report(self.root)
     self.assertEqual(iconpath(self.root), get_iconPathForFolder())
     self.assertEqual(iconpath(self.report), get_iconPathByFileExt('.txt'))
     self.assertEqual(iconpath(r0), "")
     self.assertEqual(fileext(''), '')