Hey Paolo!
Funny I was on this thread because a search in gmail and I am just workin
to improve your multiupload app.
I am creating the update form actually I have been able to insert the
values of the record for the f_trip table, but I struggle for the data from
the f_photo table that need to be formated correctly for the jquery
plugins...
I think I am doing a kind of monkey patch actually just to make it works
like this :
def trip_update():
# only SQLFORM.factory tested
form=SQLFORM.factory(db.t_trip, db.t_photos)
for row in db(db.t_trip.id == request.args(0)).select(db.t_trip.ALL):
for f in db.t_trip.fields:
form.vars[f]=row[f]
i = 0
for row in db(db.t_photos.f_trip_ref ==
request.args(0)).select(db.t_photos.ALL):
#for f in db.t_photos.fields:
#f_photo_0:CONTENT_OF_f_title
#form.vars['f_photo_'+str(i)+':'+row.f_title]=row # don't works
need data under this form :
#<li title="couleurs (1).png"><a class="mw_delItem"
href="javascript:void(0);" title="remove this file">x</a><i><b><em
class="mw_file-ext-png"></em></b></i><span>test1</span></li>
# So here trying to return to the view the jQuery code that will
append the multiple LI required
response.js="jQuery('ul.mw_list').append()"
#LI(_title='couleurs (1).png', A('x', _href='javascript:void(0);',
_class='mw_delItem', _title='remove this file'),
I(B(EM(_class='mw_file-ext-png'))), SPAN('test1'))
# I and B helpers don't exist I think.
#LI(A('x', _href='javascript:void(0);', _class='mw_delItem',
_title='remove this file'),
'<i><b>'+EM(_class='mw_file-ext-png')+'</b></i>', SPAN('test1'),
_title='couleurs (1).png') # Don't work...
if form.accepts(request, session, onvalidation=lambda
form:check(form)): # Is it possible to use onvalidation with form.process()
syntax ?
trip_id =
db.t_trip.update_record(**db.t_trip._filter_fields(form.vars))
nfiles = 0
for var in request.vars:
if var.startswith('f_photo') and request.vars[var] != '':
uploaded = request.vars[var]
if isinstance(uploaded,list):
# files uploaded through input with "multiple"
attribute set on true
counter=0
for element in uploaded:
counter += 1
nfiles += 1
file_title = element.name.split(":")[-1] # TODO:
could this be made better?
# I mean,
the title must be appended to element's name
# or is
there another way?
db.t_photos.insert(
f_trip_ref=trip_id,
f_title=file_title+" ("+str(counter)+")" if
file_title!="" else file_title,
f_photo=db.t_photos.f_photo.store(element.file,element.filename))
else:
# only one file uploaded
element = request.vars[var]
nfiles += 1
db.t_photos.insert(
f_trip_ref=trip_id,
f_title=element.name.split(":")[-1],
f_photo=db.t_photos.f_photo.store(element.file,element.filename))
session.flash = T('%s photo%s uploaded'%(nfiles, 's' if nfiles>1
else ''))
redirect(URL('trip_read'))
if isinstance(form,FORM):
# hide f_title form's row. Is there a better way to accomplish it?
del form[0][3]
return dict(form=form)
So almost realtime coding here... Do you have a better idea than returning
the f_photo entries under the format used by the javascript plugins ??
Richard
On Wed, May 30, 2012 at 4:05 PM, Paolo Caruccio
<[email protected]>wrote:
> Andrew,
>
> it's simple go back to old auth_navbar.
>
> In views/layout.html comment this jquery code:
>
> jQuery('.auth_navbar').each(function(){
> jQuery(this)
> .addClass('btn-group')
> .children('a').addClass('btn')
> });
>
> and change the <div id="navbar"> in this way (note separators):
>
> <div id="navbar">{{='auth' in globals() and auth.navbar(separators=(' ','
> | ',''))}}</div>
>
> At least add below 2 rows to bottom of static/css/bootswatch.css:
>
> #navbar{
> padding-top:9px;
> }
> #navbar .auth_navbar, #navbar .auth_navbar a{
> color:inherit;
> //color:expression(this.parentNode.currentStyle['color']); /* ie7
> doesn't support inherit */
> }
>
> Please, let me know if it works.
>
> Il giorno mercoledì 30 maggio 2012 07:42:07 UTC+2, Andrew ha scritto:
>
>> Thanks Paolo,
>> The layout is back to normal. However the Login set of links are looking
>> like buttons, rather than the background being the same as the navbar.
>> This is the same in the two browsers I'm looking at (IE7 and Firefox).
>>
>> I prefer the way it looked in firefox. Does it need to be a set
>> background to work ?
>>
>>
>>
>>
>> On Tuesday, May 29, 2012 7:33:50 AM UTC+12, Paolo Caruccio wrote:
>>>
>>> Andrew,
>>>
>>> I, just now, proposed a patch through issue tracker (
>>> http://code.google.com/p/**web2py/issues/detail?id=824<http://code.google.com/p/web2py/issues/detail?id=824>)
>>> that should resolve the problems with IE7 noted by you. Moreover the
>>> auth_navbar is more compliant with bootstrap (check the image). I tested
>>> the new welcome layout replacing the default web2py bootstrap.min.css with
>>> some from bootswatch and it seems work good now.
>>>
>>