def delete(self, id): c.attachment = Attachment.find_by_id(id) c.proposal = Proposal.find_by_id(c.attachment.proposal_id) if not h.auth.authorized(h.auth.has_organiser_role): authorized = False for person in c.proposal.people: if person.id == h.signed_in_person().id: authorized = True break if not authorized: # Raise a no_auth error h.auth.no_role() return render('/attachment/confirm_delete.mako')
def delete(self, id): c.attachment = Attachment.find_by_id(id) c.proposal = Proposal.find_by_id(c.attachment.proposal_id) if not h.auth.authorized(h.auth.has_organiser_role): authorized = False for person in c.proposal.people: if person.id == h.signed_in_person().id: authorized = True break if not authorized: # Raise a no_auth error h.auth.no_role() return render("/attachment/confirm_delete.mako")
def _delete(self, id): c.attachment = Attachment.find_by_id(id) proposal = Proposal.find_by_id(c.attachment.proposal_id) if not h.auth.authorized(h.auth.has_organiser_role): authorized = False for person in proposal.people: if person.id == h.signed_in_person().id: authorized = True break if not authorized: # Raise a no_auth error h.auth.no_role() meta.Session.delete(c.attachment) meta.Session.commit() h.flash("Attachment Deleted") redirect_to(controller='proposal', action='view', id=proposal.id)
def _delete(self, id): c.attachment = Attachment.find_by_id(id) proposal = Proposal.find_by_id(c.attachment.proposal_id) if not h.auth.authorized(h.auth.has_organiser_role): authorized = False for person in proposal.people: if person.id == h.signed_in_person().id: authorized = True break if not authorized: # Raise a no_auth error h.auth.no_role() meta.Session.delete(c.attachment) meta.Session.commit() h.flash("Attachment Deleted") redirect_to(controller="proposal", action="view", id=proposal.id)
def view(self, id): attachment = Attachment.find_by_id(id) proposal = Proposal.find_by_id(attachment.proposal_id) if not h.auth.authorized(h.auth.has_organiser_role): authorized = False for person in proposal.people: if h.auth.is_same_zookeepr_user(person.id): authorized = True break if not authorized: # Raise a no_auth error h.auth.no_role() response.headers["content-type"] = attachment.content_type.encode("ascii", "ignore") response.headers.add("content-transfer-encoding", "binary") response.headers.add("content-length", len(attachment.content)) response.headers["content-disposition"] = 'attachment; filename="%s";' % attachment.filename.encode( "ascii", "ignore" ) response.headers.add("Pragma", "cache") response.headers.add("Cache-Control", "max-age=3600,public") return attachment.content
def view(self, id): attachment = Attachment.find_by_id(id) proposal = Proposal.find_by_id(attachment.proposal_id) if not h.auth.authorized(h.auth.has_organiser_role): authorized = False for person in proposal.people: if h.auth.is_same_zookeepr_user(person.id): authorized = True break if not authorized: # Raise a no_auth error h.auth.no_role() response.headers['content-type'] = attachment.content_type.encode( 'ascii', 'ignore') response.headers.add('content-transfer-encoding', 'binary') response.headers.add('content-length', len(attachment.content)) response.headers[ 'content-disposition'] = 'attachment; filename="%s";' % attachment.filename.encode( 'ascii', 'ignore') response.headers.add('Pragma', 'cache') response.headers.add('Cache-Control', 'max-age=3600,public') return attachment.content