Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată

In my "Library" on my website I can navigate to a particular slide but when I hit the download button it prompts me to login. The line in the code looks like this:

@http.route('''/slides/slide/<model("slide.slide", "[('channel_id.can_see', '=', True), ('download_security', '=', 'public')]"):slide>/download''', type='http', auth="public", website=True)
def slide_download(self, slide):
if slide.download_security == 'public' or (slide.download_security == 'user' and request.session.uid):
filecontent = base64.b64decode(slide.datas)
disposition = 'attachment; filename=%s.pdf' % werkzeug.urls.url_quote(slide.name)
return request.make_response(
filecontent,
[('Content-Type', 'application/pdf'),
('Content-Length', len(filecontent)),
('Content-Disposition', disposition)])
elif not request.session.uid and slide.download_security == 'user':
return werkzeug.utils.redirect('/web?redirect=/slides/slide/%s' % (slide.id))
return request.website.render("website.403")

I put in a pdb and found that whether I'm logged in or not the slide.download_security is always equal to 'user'. I've tried all combinations of removing things but usually just that results in the loss of my download button. However, if I navigate directly to the /slides/slide/#/download url it downloads. So I guess I know that is works.

How can I allow the public to download these documents without having to be logged in and still maintain my download button?

Thanks for your help!

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
oct. 24
7028
2
mai 17
3551
1
apr. 17
3145
1
sept. 21
5146
4
aug. 25
20120