Re: [web2py] Suggestions for multiple files upload in form

2015-06-28 Thread Chaitu P
can anyone help.
I have copied all the files. But still not working.
When i clicked on the + button it is not showing popup window to choose
files.

On Fri, Jun 26, 2015 at 11:43 AM, Chaitu P 
wrote:

> Hi Paolo,
>
> I have installed your application and it is working perfectly.
> I want have same multiimage upload functionality in my application. So I
> changed one of the table names.
> But unfortunately it is not working. Iam not sure what Iam missing I have
> copied the css and js files as well.  Is there a way that you can help me.
>
> my controller:
> def new():
> # only SQLFORM.factory tested
> form=SQLFORM.factory(db.submission,db.t_photos)
>
> if form.accepts(request, session, onvalidation=lambda form:check(form)): #
> Is it possible to use onvalidation with form.process() syntax ?
> submission_id =
> db.submission.insert(**db.submission._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('teacher'))
>
> 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)
>
> view:
>
> {{response.files.extend([URL('static','css/multiupload.css'),URL('static','js/jquery.multiupload.js')])}}
> {{left_sidebar_enabled=right_sidebar_enabled=False}}
> {{extend 'layout.html'}}
> 
> {{=form}}
> 
> //
> 
> 
>
> model:
>
> db.define_table('submission',
> Field('name', requires=[IS_NOT_EMPTY(), IS_ALPHANUMERIC()]),
> Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL()]),
> #Field('file','upload', requires=IS_NOT_EMPTY()),
> Field('status', readable=False,writable=False),
> Field('posted_on', 'date', default=request.now, readable=False,
> writable=False),
> Field('problem_id','reference problem',readable=False, writable=False))
>
> db.define_table('t_photos',
> Field('f_trip_ref', type='reference submission', notnull=True,
> writable=False, readable=False),
> Field('f_title', type='string', label=T('Title'), notnull=False), #
> notnull=False is required
> Field('f_photo', type='upload',
> uploadfolder=request.folder+'static/pictures', notnull=False, #
> notnull=False is required
> label=T('Photos'),
> represent=lambda x, row:x and A('%s'%(db.t_photos.f_photo.retrieve(x)[0]),
> _href=URL('default','viewer.html',args=x),
> _target="_blank",
> _title=T("open photo"),
> _class='file-reference')
> or ''
> ),
> )
>
>
>
>
> On Friday, June 22, 2012 at 1:46:51 PM UTC-5, Paolo Caruccio wrote:
>>
>> Richard,
>>
>> I'm sorry for late answer. I spent a bit of time playing with bootstrap
>> 2.0.4 and rewriting the code to follow frequent web2py changes.
>>
>> In attached app, you'll find a rewieved version of multiuploads control
>> and some bootstrap features (carousel, web2py flash messages replaced with
>> bootstrap alert, form and form errors).
>>
>> I don't know if the approach  - that you'll see in app - is enough to
>> satisfy your request, but It represents the way I would use.
>>
>> The app is a toy. I mean, you could find many bugs, not optimized code,
>> and so on. Its scope is only to demonstrate multiuploads control  usage in
>> an web2py application.
>>
>>
>>
>> Il giorno venerdì 1 giugno 2012 22:08:06 UTC+2, Richard ha scritto:
>>>
>>> No problem, I don't have time neither maybe for a couples of days too :)
>>>
>>> Richard
>>>
>>> On Fri, Jun 1, 2012 at 3:24 PM, Paolo Caruccio 
>>> wrote:
>>>
 Richard,

 I made some reflections on what you want to do and it's not easy, since
 the use of control for simultaneous upload of multiple files was aimed to
 replace the standard control. As an example of use, you can see
>>>

Re: [web2py] Suggestions for multiple files upload in form

2015-06-26 Thread Chaitu P
Hi Paolo,

I have installed your application and it is working perfectly.
I want have same multiimage upload functionality in my application. So I 
changed one of the table names.
But unfortunately it is not working. Iam not sure what Iam missing I have 
copied the css and js files as well.  Is there a way that you can help me.

my controller:
def new():
# only SQLFORM.factory tested
form=SQLFORM.factory(db.submission,db.t_photos)

if form.accepts(request, session, onvalidation=lambda form:check(form)): # 
Is it possible to use onvalidation with form.process() syntax ?
submission_id = 
db.submission.insert(**db.submission._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('teacher'))

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)

view:
{{response.files.extend([URL('static','css/multiupload.css'),URL('static','js/jquery.multiupload.js')])}}
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

{{=form}}

//



model:

db.define_table('submission', 
Field('name', requires=[IS_NOT_EMPTY(), IS_ALPHANUMERIC()]), 
Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL()]),
#Field('file','upload', requires=IS_NOT_EMPTY()),
Field('status', readable=False,writable=False),
Field('posted_on', 'date', default=request.now, readable=False, 
writable=False),
Field('problem_id','reference problem',readable=False, writable=False))

db.define_table('t_photos',
Field('f_trip_ref', type='reference submission', notnull=True, 
writable=False, readable=False),
Field('f_title', type='string', label=T('Title'), notnull=False), # 
notnull=False is required
Field('f_photo', type='upload', 
uploadfolder=request.folder+'static/pictures', notnull=False, # 
notnull=False is required
label=T('Photos'),
represent=lambda x, row:x and A('%s'%(db.t_photos.f_photo.retrieve(x)[0]),
_href=URL('default','viewer.html',args=x),
_target="_blank",
_title=T("open photo"),
_class='file-reference')
or ''
),
)




On Friday, June 22, 2012 at 1:46:51 PM UTC-5, Paolo Caruccio wrote:
>
> Richard,
>
> I'm sorry for late answer. I spent a bit of time playing with bootstrap 
> 2.0.4 and rewriting the code to follow frequent web2py changes. 
>
> In attached app, you'll find a rewieved version of multiuploads control 
> and some bootstrap features (carousel, web2py flash messages replaced with 
> bootstrap alert, form and form errors).
>
> I don't know if the approach  - that you'll see in app - is enough to 
> satisfy your request, but It represents the way I would use.
>
> The app is a toy. I mean, you could find many bugs, not optimized code, 
> and so on. Its scope is only to demonstrate multiuploads control  usage in 
> an web2py application.
>
>
>
> Il giorno venerdì 1 giugno 2012 22:08:06 UTC+2, Richard ha scritto:
>>
>> No problem, I don't have time neither maybe for a couples of days too :)
>>
>> Richard
>>
>> On Fri, Jun 1, 2012 at 3:24 PM, Paolo Caruccio > > wrote:
>>
>>> Richard,
>>>
>>> I made some reflections on what you want to do and it's not easy, since 
>>> the use of control for simultaneous upload of multiple files was aimed to 
>>> replace the standard control. As an example of use, you can see 
>>> http://ochiba77.blogspot.it/2012/01/web2py-slices-sending-email-from-form.html
>>>  However, we can use a different approach to getting what you want 
>>> through the use of a smartgrid. I'll post soon a demo application (in this 
>>> days I'm very busy in personal matters). 
>>>
>>> Il giorno giovedì 31 maggio 2012 19:35:02 UTC+2, Richard ha scritto:
>>>
 Here where I get as now :

 Controler :
 de

Re: [web2py] Suggestions for multiple files upload in form

2012-06-01 Thread Richard Vézina
No problem, I don't have time neither maybe for a couples of days too :)

Richard

On Fri, Jun 1, 2012 at 3:24 PM, Paolo Caruccio
wrote:

> Richard,
>
> I made some reflections on what you want to do and it's not easy, since
> the use of control for simultaneous upload of multiple files was aimed to
> replace the standard control. As an example of use, you can 
> seehttp://ochiba77.blogspot.it/2012/01/web2py-slices-sending-email-from-form.html
> However, we can use a different approach to getting what you want through
> the use of a smartgrid. I'll post soon a demo application (in this days I'm
> very busy in personal matters).
>
> Il giorno giovedì 31 maggio 2012 19:35:02 UTC+2, Richard ha scritto:
>
>> Here where I get as now :
>>
>> Controler :
>> 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]
>> photos_files = []
>> 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
>> #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'))
>> photos_files.append(XML(LI(A('**x', _href='javascript:void(0);',
>> _class='mw_delItem', _title='remove this file'),
>> EM(_class='mw_file-ext-png'), SPAN(row.f_title), _title=row.f_photo)).xml())
>> #response.js="""var photos_files_list = "{{=photos_files}}"
>> #$(document).ready( function () {
>> #if(photos_files_list != 'None') {
>> #$.each(photos_files_list, function(i, val) {
>> #$('ul.mw_list').append(**photos_files_list[i]);
>> #});
>> #};
>> #});"""
>> #response.js="""var photos_files_list = "{{=photos_files}}"
>> $(document).ready( function () {if(photos_files_list != 'None')
>> {$.each(photos_files_list, function(i, val) {$('ul.mw_list').append(**
>> photos_files_list[i]);});};});**"""
>> #A(T('Access'),_href=URL(r=**request,f='read',args=(**
>> request.args(0),str(id
>>
>> #> href="javascript:void(0);" title="remove this file">x> class="mw_file-ext-png"><**/b>test1
>> if form.accepts(request, session, onvalidation=lambda
>> form:check(form)): # Is it possible to use onvalidation with form.process()
>> syntax ?
>> trip_id = request.args(0)
>> db(db.t_trip.id == trip_id).update(**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, photos_files=photos_files)
>>
>> View :
>>
>> {{response.files.extend([URL('**static','css/multiupload.css')**
>> ,URL('static','js/jquery.**multiupload.js')])}}
>> {{left_sidebar_enabled=right_**sidebar_enabled=False}}
>> {{extend 'layout.html'}}
>> 
>> {{=form}}
>> {{=photos_files[0]}}
>> 
>> //




var photos_files_list = {{=photos_files}}
$(document).ready( function () {
if(photos_files_list != 'None') {
$.each(photos_files_list, function(i, val) {
$('ul.mw_list').append(val); //photos_files_list[i]
});
};
});


{{if request.is_local:}}
{{=response.toolbar()}}
{{pass}}


Problem : the items are not showing up in the UL box, because a conversion
between python and javascript text format I think (I know the get into the
box as plain text), Second thing, the destruction of the items is not
working not sure why. Also there is code refactoring to do since the rest
of the function only manage adding stuff I change a bit for updating stuff,
for the first table (maybe for nothing), but it needs to destruct records
in the referen

Re: [web2py] Suggestions for multiple files upload in form

2012-05-31 Thread Richard Vézina
response.js will not works, it only works on response and for component as
says the book.

Putting the js code into the view seems to work if I pass the photos_files
var to the view...

Now I think I just have to find the way to expose the HTML, XML() not seems
to work.

Richard

On Thu, May 31, 2012 at 12:09 PM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> Hello Paolo,
>
> Here some fresher code :
>
> 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]
> photos_files = []
> 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
> #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'))
> photos_files.append(XML(LI(A('x', _href='javascript:void(0);',
> _class='mw_delItem', _title='remove this file'),
> EM(_class='mw_file-ext-png'), SPAN(row.f_title), _title=row.f_photo)))
> response.js="""var photos_files_list = "{{=photos_files}}"
> $(document).ready( function () {
> if(photos_files_list != 'None') {
> $.each(photos_files_list, function(i, val) {
> $('ul.mw_list').append(photos_files_list[i]);
> });
> };
> });"""
>
> #A(T('Access'),_href=URL(r=request,f='read',args=(request.args(0),str(id
>
> # href="javascript:void(0);" title="remove this file">x class="mw_file-ext-png">test1
> 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)
>
> On Wed, May 30, 2012 at 6:23 PM, Paolo Caruccio <
> paolo.carucci...@gmail.com> wrote:
>
>> Richard,
>>
>> I saw your email in the discussion regarding bootswatch, but I want to
>> answer here for competence.
>>
>> Multiupload is a my old project. The object of the toy app was
>> demonstrate the usage of multiupload control. It wasn't a complete
>> application.
>>
>> Your intentions, however, are interesting. I will take a look at your
>> code and I will try to find a solution.
>>
>>
>> Il giorno mercoledì 30 maggio 2012 16:15:09 UTC+2, Richard ha scritto:
>>
>>> Hello Paolo,
>>>
>>> Pretty nice!
>>>
>>> Did you implement the update of the records also?
>>>
>>> Is it a straight and easy task or it becomes trickier to implement than
>>> the rest of the app??
>>>
>>> Richard
>>>
>>> On Sat, Oct 29, 2011 at 6:21 PM, Paolo Caruccio <
>>> paolo.carucci...@gmail.com> wrote:
>>>
 Bruno,

 thanks.

 What do you think about the upload mechanism? Can it be translate in a
 web2py widget? or is it better to use a different javascript/jquery 
 library?

 Regards.

 Paolo

>>>
>>>
>


Re: [web2py] Suggestions for multiple files upload in form

2012-05-31 Thread Richard Vézina
Hello Paolo,

Here some fresher code :

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]
photos_files = []
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
#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'))
photos_files.append(XML(LI(A('x', _href='javascript:void(0);',
_class='mw_delItem', _title='remove this file'),
EM(_class='mw_file-ext-png'), SPAN(row.f_title), _title=row.f_photo)))
response.js="""var photos_files_list = "{{=photos_files}}"
$(document).ready( function () {
if(photos_files_list != 'None') {
$.each(photos_files_list, function(i, val) {
$('ul.mw_list').append(photos_files_list[i]);
});
};
});"""

#A(T('Access'),_href=URL(r=request,f='read',args=(request.args(0),str(id

#xtest1
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)

On Wed, May 30, 2012 at 6:23 PM, Paolo Caruccio
wrote:

> Richard,
>
> I saw your email in the discussion regarding bootswatch, but I want to
> answer here for competence.
>
> Multiupload is a my old project. The object of the toy app was demonstrate
> the usage of multiupload control. It wasn't a complete application.
>
> Your intentions, however, are interesting. I will take a look at your code
> and I will try to find a solution.
>
>
> Il giorno mercoledì 30 maggio 2012 16:15:09 UTC+2, Richard ha scritto:
>
>> Hello Paolo,
>>
>> Pretty nice!
>>
>> Did you implement the update of the records also?
>>
>> Is it a straight and easy task or it becomes trickier to implement than
>> the rest of the app??
>>
>> Richard
>>
>> On Sat, Oct 29, 2011 at 6:21 PM, Paolo Caruccio <
>> paolo.carucci...@gmail.com> wrote:
>>
>>> Bruno,
>>>
>>> thanks.
>>>
>>> What do you think about the upload mechanism? Can it be translate in a
>>> web2py widget? or is it better to use a different javascript/jquery library?
>>>
>>> Regards.
>>>
>>> Paolo
>>>
>>
>>


Re: [web2py] Suggestions for multiple files upload in form

2012-05-30 Thread Paolo Caruccio
Richard,

I saw your email in the discussion regarding bootswatch, but I want to 
answer here for competence.

Multiupload is a my old project. The object of the toy app was demonstrate 
the usage of multiupload control. It wasn't a complete application.

Your intentions, however, are interesting. I will take a look at your code 
and I will try to find a solution.


Il giorno mercoledì 30 maggio 2012 16:15:09 UTC+2, Richard ha scritto:
>
> Hello Paolo,
>
> Pretty nice!
>
> Did you implement the update of the records also?
>
> Is it a straight and easy task or it becomes trickier to implement than 
> the rest of the app??
>
> Richard
>
> On Sat, Oct 29, 2011 at 6:21 PM, Paolo Caruccio <
> paolo.carucci...@gmail.com> wrote:
>
>> Bruno,
>>
>> thanks.
>>
>> What do you think about the upload mechanism? Can it be translate in a 
>> web2py widget? or is it better to use a different javascript/jquery library?
>>
>> Regards.
>>
>> Paolo
>>
>
>

Re: [web2py] Suggestions for multiple files upload in form

2012-05-30 Thread Richard Vézina
Hello Paolo,

Pretty nice!

Did you implement the update of the records also?

Is it a straight and easy task or it becomes trickier to implement than the
rest of the app??

Richard

On Sat, Oct 29, 2011 at 6:21 PM, Paolo Caruccio
wrote:

> Bruno,
>
> thanks.
>
> What do you think about the upload mechanism? Can it be translate in a
> web2py widget? or is it better to use a different javascript/jquery library?
>
> Regards.
>
> Paolo
>


Re: [web2py] Suggestions for multiple files upload in form

2011-10-29 Thread Paolo Caruccio
Bruno,

thanks.

What do you think about the upload mechanism? Can it be translate in a 
web2py widget? or is it better to use a different javascript/jquery library?

Regards.

Paolo


Re: [web2py] Suggestions for multiple files upload in form

2011-10-29 Thread Bruno Rocha
Thank you Paolo, very nice app.


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Suggestions for multiple files upload in form

2011-10-28 Thread Paolo Caruccio
Ovidio thank you for your consideration.

In fact, I have not given much attention to the results grid because the 
goal of my work was to create a control for uploading multiple files.
In addition, the visual aspect is only demonstration. The essential css 
rules are on the top of multiuploads.css (before /* CUSTOMIZATION */ 
comment).
However, I am preparing a packed .w2p web2py small application as required 
by Bruno.
Maybe, there you will see something nicer.

Ciao.

Paolo


Re: [web2py] Suggestions for multiple files upload in form

2011-10-27 Thread Ovidio Marinho
  I got was this, it seems not to be carrying it. js

http://www.diigo.com/item/image/1iw09/9pki


   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil



2011/10/27 Bruno Rocha 

>
>
> Thanks for this, I am using another jquery library for upload and I am
> going o test this.
>
> Can you provide a packed .w2p web2py application?
>
> On Thu, Oct 27, 2011 at 10:40 PM, Paolo Caruccio <
> paolo.carucci...@gmail.com> wrote:
>
>> I wasn't able to find in the web, even in this group, a multiple files
>> upload system with the followings requirements:
>>
>> - upload the files together with form submit
>> - no frame, no flash, no ajax form submit but only jquery and python
>> - give a title to the uploading files
>> - simple to integrate and control in web2py
>>
>> so, inspired by
>> http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/,
>> I wrote one by my self.
>> It's minimalist and the code isn't optimized (I'm not a programmer), but
>> it works for my purposes.
>>
>> If you would like to test it in default welcome web2py app:
>>  - put jquery.multiuploads.js in static/js folder
>>  - put multiuploads.css in static/css folder
>>  - append the functions to default.py in controllers folder
>>  - append the table definition to db.py in models folder
>>  - put upload_documents.html in views folder
>>
>> You'll find some comments in the code and also many errors.
>>
>> I look forward to your suggestions and opinions.
>>
>> Ciao.
>>
>> Paolo
>>
>
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


Re: [web2py] Suggestions for multiple files upload in form

2011-10-27 Thread Bruno Rocha
Thanks for this, I am using another jquery library for upload and I am going
o test this.

Can you provide a packed .w2p web2py application?

On Thu, Oct 27, 2011 at 10:40 PM, Paolo Caruccio  wrote:

> I wasn't able to find in the web, even in this group, a multiple files
> upload system with the followings requirements:
>
> - upload the files together with form submit
> - no frame, no flash, no ajax form submit but only jquery and python
> - give a title to the uploading files
> - simple to integrate and control in web2py
>
> so, inspired by
> http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/,
> I wrote one by my self.
> It's minimalist and the code isn't optimized (I'm not a programmer), but it
> works for my purposes.
>
> If you would like to test it in default welcome web2py app:
>  - put jquery.multiuploads.js in static/js folder
>  - put multiuploads.css in static/css folder
>  - append the functions to default.py in controllers folder
>  - append the table definition to db.py in models folder
>  - put upload_documents.html in views folder
>
> You'll find some comments in the code and also many errors.
>
> I look forward to your suggestions and opinions.
>
> Ciao.
>
> Paolo
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Suggestions for multiple files upload in form

2011-10-27 Thread Paolo Caruccio
I wasn't able to find in the web, even in this group, a multiple files 
upload system with the followings requirements:

- upload the files together with form submit
- no frame, no flash, no ajax form submit but only jquery and python
- give a title to the uploading files
- simple to integrate and control in web2py 

so, inspired by 
http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/,
 
I wrote one by my self.
It's minimalist and the code isn't optimized (I'm not a programmer), but it 
works for my purposes.

If you would like to test it in default welcome web2py app:
 - put jquery.multiuploads.js in static/js folder
 - put multiuploads.css in static/css folder
 - append the functions to default.py in controllers folder
 - append the table definition to db.py in models folder
 - put upload_documents.html in views folder

You'll find some comments in the code and also many errors.

I look forward to your suggestions and opinions.

Ciao.

Paolo
{{response.files.extend([URL('static','css/multiuploads.css'),URL('static','js/jquery.multiuploads.js')])}}
{{extend 'layout.html'}}

{{=form}}




jquery.multiuploads.js
Description: JavaScript source
/* CAUTION: essential rules don't remove */
div.multiupload_widget 
{
	display:inline-block; /* fix the div.error issue */
}

ul.mw_list
{
	display:block;
}

input.mw_fileTitle
{
	float:left;
}

div.mw_fileBrowserWrapper
{
	float:left;
}

a.mw_addBtn
{
	display:block;
	position:relative;
	overflow:hidden;
	max-width:70px;
	min-height:22px;
	text-align:center;
	margin-right:2px;
}

a.mw_clearBtn
{
	float:left;
	max-width:70px;
	min-height:22px;
	text-align:center;
	margin-left:2px;
}

a.mw_delItem
{
	display:block;
	float:right;
}

ul.mw_list ul
{
	width:90%; /* to avoid elastic when we slide it */
}
li.mw_group
{
	cursor:pointer;
}

/* CUSTOMIZATION */

div.multiupload_widget
{
width:280px;
margin: 2px 15px 2px 5px;
padding:0 1px;
}

ul.mw_list
{
margin:0 0 4px 0;
padding:0;
min-height:32px;
border:1px solid #e1e1e1;
border-radius:2px;
overflow:auto;
list-style:none;
}

ul.mw_list>li
{
font-weight:bold;
display:block;
margin:2px 0;
}

ul.mw_list li:hover
{
background-color:lightyellow;
}

ul.mw_list ul
{
list-style:none;
margin-top:2px;
margin-left:22px;
width:256px; /*div.multiupload_widget - (margin-left + 2*(border width)) => 280-(22+2) */
}

ul.mw_list ul li
{
font-weight:normal;
}

ul.mw_list span
{
word-wrap:break-word;
display:inline-block;
width:80%;
margin:0 0 0 10px;
}

li.mw_group
{

}

li.mw_group span
{

}

div.mw_bar{}

input[type="text"].mw_fileTitle
{
width:69%;
padding-left:3px;
}

div.mw_fileBrowserWrapper{}

a.mw_addBtn, a.mw_clearBtn
{
width:24px;
height:22px;
background:#EAEAEA;
border:1px solid #DEDEDE;
border-radius:2px;
margin:0 2px 0 2px;
font-size:16px;
font-weight:bold;
line-height:22px;
}

a.mw_addBtn
{
line-height:24px;
}

a.mw_addBtn:hover, a.mw_clearBtn:hover
{
text-decoration:none;
}

a.mw_addBtn > span {}
a.mw_clearBtn > span {}

a.mw_delItem
{
width:16px;
height:16px;
background-color:silver;
color:white;
font-weight:bold;
border-radius:10px;
text-align:center;
font-size:13px;
line-height:13px;
text-decoration:none;
margin:2px 4px 0 0;
}

a.mw_delItem:hover
{
text-decoration:none;
color:#275B90;
background-color:#aaa;
}

/*--*/
/* FILE ICON - based on http://nicolasgallagher.com/pure-css-gui-icons/
/*--*/

ul.mw_list i
{
display: block;
float: left;
width: 12px;
height: 17px;
background: #eee;
margin-left: 4px;
margin-top: 2px;
position: relative;
}

ul.mw_list b
{
	z-index:1;
	overflow:hidden;
	padding:0;
}

ul.mw_list b em
{
	border-bottom: 1px solid #275B90;
	color: #275B90;
	display: block;
}

ul.mw_list b em::before, ul.mw_list b em::after
{
margin: -8px 0 0;
background: #275B90;
}

ul.mw_list b em::before
{
left: 5px;
width: 8px;
height: 12px;
border: 2px solid #275B90;
background: transparent;
}

ul.mw_list b em::after
{
left: 4px;
border-width: 3px;
border-style: solid;
border-color: white #275B90 #275B90 white;
margin-top: -9px;
background: transparent;
}

ul.mw_list b::before, ul.mw_list b::after, ul.mw_list b em::before, ul.mw_list b em::after 
{
	content:"";
	position:absolute;
	top:50%;
	left:0;
}

/*--*/def check(form):
# check if file list is empty. We, indeed, set notnull=False for f_document Field 
for var in request.vars:
if var.startswith('f_document') and request.vars[var] != '': return
form.errors.f_document = T("file list is empty")


def upload_documents():
# only SQLFORM.factory tested
form=SQLFORM.factory(db.t_documents)

if form.accepts(request, session, onvalidation=lambda form:check(form)): # Is it possible to use onvalidation with form.process() syntax ?
nfiles = 0
for var in