예제 #1
0
파일: attachment.py 프로젝트: Ivoz/zookeepr
    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')
예제 #2
0
    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')
예제 #3
0
    def delete(self, id):
        attachment = Attachment.find_by_id(id)
        if(attachment == None): abort(400)

        authorized = h.auth.authorized(h.auth.has_organiser_role)
        for person in attachment.proposal.people:
            if h.auth.authorized(h.auth.is_same_zkpylons_user(person.id)):
                authorized = True
        if not authorized:
            # Raise a no_auth error
            h.auth.no_role()

        c.attachment = attachment
        c.proposal = attachment.proposal
        
        return render('/attachment/confirm_delete.mako')
예제 #4
0
    def _delete(self, id):
        attachment = Attachment.find_by_id(id)
        if(attachment == None): abort(400)

        authorized = h.auth.authorized(h.auth.has_organiser_role)
        for person in attachment.proposal.people:
            if h.auth.authorized(h.auth.is_same_zkpylons_user(person.id)):
                authorized = True
        if not authorized:
            # Raise a no_auth error
            h.auth.no_role()

        meta.Session.delete(attachment)
        meta.Session.commit()

        h.flash("Attachment Deleted")
        redirect_to(controller='proposal', action='view', id=attachment.proposal.id)
예제 #5
0
    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)
예제 #6
0
    def view(self, id):
        attachment = Attachment.find_by_id(id)
        if(attachment == None): abort(400)

        authorized = h.auth.authorized(h.auth.has_organiser_role)
        for person in attachment.proposal.people:
            if h.auth.authorized(h.auth.is_same_zkpylons_user(person.id)):
                authorized = True
        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
예제 #7
0
파일: attachment.py 프로젝트: Ivoz/zookeepr
    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)
예제 #8
0
    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_zkpylons_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