Browse Source

Merge branch 'tr4ck3ur/various_fixes_2017' of JM2L/jm2l into master

master
JM2L 6 years ago
committed by Gogs
parent
commit
84d39c4733
2 changed files with 27 additions and 10 deletions
  1. +10
    -9
      jm2l/upload.py
  2. +17
    -1
      jm2l/views.py

+ 10
- 9
jm2l/upload.py View File

@@ -504,25 +504,26 @@ class MediaUpload(MediaPath):
result['size'] = self.get_file_size(fieldStorage.file) result['size'] = self.get_file_size(fieldStorage.file)


if self.validate(result, fieldStorage.file): if self.validate(result, fieldStorage.file):
local_filename = slugify( result['name'] )
# Keep mime-type in .type file # Keep mime-type in .type file
with open( self.mediapath( result['name'] ) + '.type', 'w') as f:
with open( self.mediapath( local_filename ) + '.type', 'w') as f:
f.write(result['type']) f.write(result['type'])
# Store uploaded file # Store uploaded file
fieldStorage.file.seek(0) fieldStorage.file.seek(0)
with open( self.mediapath(result['name'] ), 'wb') as f:
with open( self.mediapath( local_filename ), 'wb') as f:
shutil.copyfileobj( fieldStorage.file , f) shutil.copyfileobj( fieldStorage.file , f)


if re.match(IMAGE_TYPES, result['type']): if re.match(IMAGE_TYPES, result['type']):
result['thumbnailUrl'] = self.createthumbnail(result['name'])
result['thumbnailUrl'] = self.createthumbnail(local_filename)
elif result['type']=='application/pdf': elif result['type']=='application/pdf':
result['thumbnailUrl'] = self.pdfthumbnail(result['name'])
result['thumbnailUrl'] = self.pdfthumbnail(local_filename)
elif result['type']=='image/svg+xml': elif result['type']=='image/svg+xml':
result['thumbnailUrl'] = self.svgthumbnail(result['name'])
result['thumbnailUrl'] = self.svgthumbnail(local_filename)
elif result['type'].startswith('application/vnd'): elif result['type'].startswith('application/vnd'):
result['thumbnailUrl'] = self.docthumbnail(result['name'])
result['thumbnailUrl'] = self.docthumbnail(local_filename)
elif result['type']=='application/x-blender': elif result['type']=='application/x-blender':
result['thumbnailUrl'] = self.blendthumbnail(result['name'])
result['thumbnailUrl'] = self.blendthumbnail(local_filename)
else: else:
result['thumbnailUrl'] = self.ExtMimeIcon(result['type']) result['thumbnailUrl'] = self.ExtMimeIcon(result['type'])


@@ -531,11 +532,11 @@ class MediaUpload(MediaPath):
sep='', sep='',
name='', name='',
media_table=self.media_table, media_table=self.media_table,
uid=self.linked_id) + '/' + result['name']
uid=self.linked_id) + '/' + local_filename
result['url'] = self.request.route_url('media_view', result['url'] = self.request.route_url('media_view',
media_table=self.media_table, media_table=self.media_table,
uid=self.linked_id, uid=self.linked_id,
name=result['name'])
name=local_filename)
if DELETEMETHOD != 'DELETE': if DELETEMETHOD != 'DELETE':
result['deleteUrl'] += '&_method=DELETE' result['deleteUrl'] += '&_method=DELETE'
results.append(result) results.append(result)


+ 17
- 1
jm2l/views.py View File

@@ -88,6 +88,16 @@ def ICal_Progamme_Request(request):
event.add('description', "http://www.linux-azur.org/event/%s/%s" % (ev.for_year, ev.slug) ) event.add('description', "http://www.linux-azur.org/event/%s/%s" % (ev.for_year, ev.slug) )
event.add('url', "http://www.linux-azur.org/event/%s/%s" % (ev.for_year, ev.slug) ) event.add('url', "http://www.linux-azur.org/event/%s/%s" % (ev.for_year, ev.slug) )
event.add('priority', 5) event.add('priority', 5)
for interv in ev.intervenants:
event.add('organizer',
interv.slug,
parameters={
"CN": "%s %s" % (interv.prenom, interv.nom),
"DIR": "https://jm2l.linux-azur.org/user/%s" % interv.slug
}
)
event.add('location', ev.Salle.name)
event.add('categories', ev.event_type)
cal.add_component(event) cal.add_component(event)
request.response.content_type = "text/calendar" request.response.content_type = "text/calendar"
return cal.to_ical() return cal.to_ical()
@@ -500,6 +510,9 @@ def expenses(request):
dic_out = {} dic_out = {}
for name in glob.glob('jm2l/upload/images/users/*/RIB/*'): for name in glob.glob('jm2l/upload/images/users/*/RIB/*'):
tab_path = name.split('/') tab_path = name.split('/')
u = User.by_slug(tab_path[4])
if u is None:
continue
if tab_path[6]=='thumbnails' or tab_path[6].endswith('.type'): if tab_path[6]=='thumbnails' or tab_path[6].endswith('.type'):
continue continue
if dic_out.get(tab_path[4]) is None: if dic_out.get(tab_path[4]) is None:
@@ -526,6 +539,9 @@ def expenses(request):


for name in glob.glob('jm2l/upload/images/users/*/Justif/*'): for name in glob.glob('jm2l/upload/images/users/*/Justif/*'):
tab_path = name.split('/') tab_path = name.split('/')
u = User.by_slug(tab_path[4])
if u is None:
continue
if tab_path[6]=='thumbnails' or tab_path[6].endswith('.type'): if tab_path[6]=='thumbnails' or tab_path[6].endswith('.type'):
continue continue
if dic_out.get(tab_path[4]) is None: if dic_out.get(tab_path[4]) is None:
@@ -774,7 +790,7 @@ def handle_salle_phy(request):
try: try:
mp = MediaPath().move_mediapath('salle', orig_slug, dest_slug) mp = MediaPath().move_mediapath('salle', orig_slug, dest_slug)
except RuntimeError, err: except RuntimeError, err:
request.session.flash(('error', "Le nom de cette salle est déjà utilisé : " + err.message))
request.session.flash(('error', u"Le nom de cette salle est déjà utilisé : " + err.message))
return {'form': form} return {'form': form}
Salle.slug = slugify(Salle.name) Salle.slug = slugify(Salle.name)




Loading…
Cancel
Save