Merge branch 'tr4ck3ur/various_fixes_2017' of JM2L/jm2l into master
This commit is contained in:
+1
-3
@@ -123,9 +123,7 @@ class JM2L_Year(Base):
|
|||||||
@property
|
@property
|
||||||
def DocLinks(self):
|
def DocLinks(self):
|
||||||
from .upload import MediaPath
|
from .upload import MediaPath
|
||||||
return zip( sorted(MediaPath().get_list('presse', self.year_uid, 'Other')),
|
return sorted(MediaPath().get_all('presse', self.year_uid))
|
||||||
sorted(MediaPath().get_thumb('presse', self.year_uid, 'Other'))
|
|
||||||
)
|
|
||||||
|
|
||||||
class User(Base):
|
class User(Base):
|
||||||
__tablename__ = 'users'
|
__tablename__ = 'users'
|
||||||
|
|||||||
+25
-1
@@ -46,7 +46,31 @@ DELETEMETHOD="DELETE"
|
|||||||
mimetypes.init()
|
mimetypes.init()
|
||||||
|
|
||||||
class MediaPath():
|
class MediaPath():
|
||||||
|
|
||||||
|
def get_all(self, media_table, linked_id, MediaType=None):
|
||||||
|
filelist = list()
|
||||||
|
curpath = self.get_mediapath(media_table, linked_id, None)
|
||||||
|
thumbpath = os.path.join( curpath, 'thumbnails')
|
||||||
|
if not os.path.isdir(curpath) or not os.path.isdir(thumbpath):
|
||||||
|
return list()
|
||||||
|
for f in os.listdir(curpath):
|
||||||
|
filename, ext = os.path.splitext( f )
|
||||||
|
if os.path.isdir(os.path.join(curpath,f)):
|
||||||
|
continue
|
||||||
|
if f.endswith('.type'):
|
||||||
|
continue
|
||||||
|
if f:
|
||||||
|
ress_url = '/image/%s/%d/%s' % (media_table, linked_id, f.replace(" ", "%20"))
|
||||||
|
thumb_url = '/image/%s/%d/thumbnails/%s' % (media_table, linked_id, f.replace(" ","%20"))
|
||||||
|
if MediaType is None:
|
||||||
|
filelist.append((ress_url, thumb_url))
|
||||||
|
elif MediaType=='Image' and len( os.path.splitext(filename)[1] )==0:
|
||||||
|
filelist.append((ress_url, thumb_url))
|
||||||
|
elif MediaType=='Other' and len( os.path.splitext(filename)[1] ):
|
||||||
|
filelist.append((ress_url, thumb_url))
|
||||||
|
return filelist
|
||||||
|
|
||||||
|
|
||||||
def get_list(self, media_table, linked_id, MediaType=None):
|
def get_list(self, media_table, linked_id, MediaType=None):
|
||||||
filelist = list()
|
filelist = list()
|
||||||
curpath = self.get_mediapath(media_table, linked_id, None)
|
curpath = self.get_mediapath(media_table, linked_id, None)
|
||||||
|
|||||||
Reference in New Issue
Block a user