Explorar el Código

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

master
JM2L hace 7 años
committed by Gogs
padre
commit
84d39c4733
Se han modificado 2 ficheros con 27 adiciones y 10 borrados
  1. +10
    -9
      jm2l/upload.py
  2. +17
    -1
      jm2l/views.py

+ 10
- 9
jm2l/upload.py Ver fichero

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

if self.validate(result, fieldStorage.file):
local_filename = slugify( result['name'] )
# 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'])
# Store uploaded file
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)

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

@@ -531,11 +532,11 @@ class MediaUpload(MediaPath):
sep='',
name='',
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',
media_table=self.media_table,
uid=self.linked_id,
name=result['name'])
name=local_filename)
if DELETEMETHOD != 'DELETE':
result['deleteUrl'] += '&_method=DELETE'
results.append(result)


+ 17
- 1
jm2l/views.py Ver fichero

@@ -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('url', "http://www.linux-azur.org/event/%s/%s" % (ev.for_year, ev.slug) )
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)
request.response.content_type = "text/calendar"
return cal.to_ical()
@@ -500,6 +510,9 @@ def expenses(request):
dic_out = {}
for name in glob.glob('jm2l/upload/images/users/*/RIB/*'):
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'):
continue
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/*'):
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'):
continue
if dic_out.get(tab_path[4]) is None:
@@ -774,7 +790,7 @@ def handle_salle_phy(request):
try:
mp = MediaPath().move_mediapath('salle', orig_slug, dest_slug)
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}
Salle.slug = slugify(Salle.name)



Cargando…
Cancelar
Guardar