[web2py] Re: response.download
This works, thank you Massimo El viernes, 26 de abril de 2013, 18:07:06 (UTC+2), Massimo Di Pierro escribió: > > Please open a ticket about this. The problem is that the roles of > downloading is delegated to the field which stores the upload name. In this > case it was uploaded using a SQLFORM.factory ("no_table") and this is a > problem. web2py does not know how to check if the user is allowed to > download the file. It does not know who is responsible for the check. > > For now you can make your own downloads function: > > A(T("Download attachment"), _href=URL("default", "nt_download", args= > asset_value.upload_value), _target="blank") > > def nt_download(): > if not str(request.args(0)).startwith('no_table.'): raise HTTP(404) > return response.stream( > open(os.path.join(request.folder,'uploads',request.args(0))) > > On Tuesday, 23 April 2013 03:25:43 UTC-5, Domagoj Kovač wrote: >> >> Hi, >> >> I have a download function. >> >> def download(): >> return response.download(request, db) >> >> in my controller i have a line of code: >> >> elif field_type == "UPLOAD": >> field_value = A(T("Download attachment"), _href=URL("default", >> "download", args=asset_value.upload_value), _target="blank") >> >> Generated link is: >> http: >> //127.0.0.1:8000/init/default/download/no_table.attachment.8c9b795c20c58264.4173736573736d656e7454797065732e786c7378.xlsx >> >> When i try to download this file i get 404 error, although file is >> uploaded where it should be. >> >> What am i doing wrong, is it because of xlsx extension? >> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Select filled with years
def getyears(anyo): from datetime import datetime, date option = [] option.append(OPTION(T('Año'), _value='')) year = datetime.today().year ryear = range(2015, int(year+1)) for r in ryear: if anyo == r: selected = True else: selected = None option.append(OPTION(r, _value=r, _selected=selected)) return SELECT(*option, _name='anyo', _id='anyo', _class="form-control input-md") El domingo, 16 de abril de 2017, 23:07:08 (UTC+2), Winter Kryz escribió: > > Hello everybody, > > I have a table like this > > db.define_table('Report', > Field('person', 'reference Person'), > Field('year', 'integer'), > Field('letter', 'string'), >) > > and I use SQLFORM to create a form with that table > > form=SQLFORM(db.Report) > > I want to know if instead a 'year' field where I have to write the year, I > can fill a select with years from 1989 to 2017 so the user can pick one > from that list. I don't know how to do that because I'm using a sqlform. > > Any ideas would be appreciate. > > Thanks! > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] [Contribution] Generate Map using google maps sql and web2py
function initMap() { var myLatLng = {lat: 40.4636670001, lng: -3.74922366}; var map = new google.maps.Map(document.getElementById('map'), { zoom: 5, center: myLatLng }); var markers = []; {{ associa = db.associacions.with_alias("a") poblacio = db.poblaciones.with_alias("p") rows= db(associa).select(associa.nom,poblacio.poblacion,poblacio.latitud,poblacio.longitud,left=[poblacio.on(poblacio.poblacion == associa.poblacio)]) i=1 for r in rows: }} var marker{{=i}} = new google.maps.Marker({ position: new google.maps.LatLng(parseFloat({{=r.p.latitud}}), parseFloat({{=r.p.longitud}})), map: map, title: "{{=r.a.nom.replace("\n","")}}", }); markers.push(marker{{=i}}); {{ i+=1 pass }} var markerCluster = new MarkerClusterer(map, markers); } https://maps.googleapis.com/maps/api/js?key=YOUR_KEY"> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.