本文整理汇总了Python中zkpylons.model.Funding.find_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Funding.find_by_id方法的具体用法?Python Funding.find_by_id怎么用?Python Funding.find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zkpylons.model.Funding
的用法示例。
在下文中一共展示了Funding.find_by_id方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _review
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def _review(self, id):
"""Review a funding application.
"""
c.funding = Funding.find_by_id(id)
c.signed_in_person = h.signed_in_person()
c.next_review_id = Funding.find_next_proposal(c.funding.id, c.funding.type.id, c.signed_in_person.id)
person = c.signed_in_person
if person in [ review.reviewer for review in c.funding.reviews]:
h.flash('Already reviewed')
return redirect_to(action='review', id=c.next_review_id)
results = self.form_result['review']
if results['score'] == 'null':
results['score'] = None
review = FundingReview(**results)
meta.Session.add(review)
c.funding.reviews.append(review)
review.reviewer = person
meta.Session.commit()
if c.next_review_id:
return redirect_to(action='review', id=c.next_review_id)
h.flash("No more funding applications to review")
return redirect_to(action='review_index')
示例2: _edit
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def _edit(self, id):
# We need to recheck auth in here so we can pass in the id
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(id), h.auth.has_organiser_role)):
# Raise a no_auth error
h.auth.no_role()
if not h.auth.authorized(h.auth.has_organiser_role):
if c.funding_editing == 'closed':
return render("funding/editing_closed.mako")
elif c.funding_editing == 'not_open':
return render("funding/editing_not_open.mako")
if self.form_result['funding']['male'] == 1:
self.form_result['funding']['male'] = True
elif self.form_result['funding']['male'] == 0:
self.form_result['funding']['male'] = False
c.funding = Funding.find_by_id(id)
for key in self.form_result['funding']:
setattr(c.funding, key, self.form_result['funding'][key])
c.person = c.funding.person
meta.Session.commit()
h.flash("Funding for %s edited!"%c.person.firstname)
return redirect_to('/funding')
示例3: review
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def review(self, id):
c.funding = Funding.find_by_id(id)
c.signed_in_person = h.signed_in_person()
c.next_review_id = Funding.find_next_proposal(c.funding.id, c.funding.type.id, c.signed_in_person.id)
return render('/funding/review.mako')
示例4: withdraw
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def withdraw(self, id):
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(id), h.auth.has_organiser_role)):
# Raise a no_auth error
h.auth.no_role()
c.funding = Funding.find_by_id(id)
return render("/funding/withdraw.mako")
示例5: edit
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def edit(self, id):
# We need to recheck auth in here so we can pass in the id
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(id), h.auth.has_organiser_role)):
# Raise a no_auth error
h.auth.no_role()
if not h.auth.authorized(h.auth.has_organiser_role):
if c.funding_editing == 'closed':
return render("funding/editing_closed.mako")
elif c.funding_editing == 'not_open':
return render("funding/editing_not_open.mako")
c.funding = Funding.find_by_id(id)
defaults = {}
defaults.update(h.object_to_defaults(c.funding, 'funding'))
# This is horrible, don't know a better way to do it
if c.funding.type:
defaults['funding.type'] = defaults['funding.funding_type_id']
if c.funding.male:
defaults['funding.male'] = 1
else:
defaults['funding.male'] = 0
form = render('/funding/edit.mako')
return htmlfill.render(form, defaults)
示例6: check
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def check(self, app, environ, start_response):
if not environ.get('REMOTE_USER'):
raise NotAuthenticatedError('Not Authenticated')
person = Person.find_by_email(environ['REMOTE_USER'])
if person is None:
environ['auth_failure'] = 'NO_USER'
raise NotAuthorizedError(
'You are not one of the users allowed to access this resource.'
)
funding = Funding.find_by_id(self.funding_id)
if funding is None:
raise NotAuthorizedError(
"Funding Request doesn't exist"
)
if person != funding.person:
set_role("User doesn't have any of the specified roles")
raise NotAuthorizedError(
"User doesn't have any of the specified roles"
)
return app(environ, start_response)
示例7: delete
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def delete(self, id):
c.attachment = FundingAttachment.find_by_id(id)
c.funding = Funding.find_by_id(c.attachment.funding_id)
if not (h.auth.authorized(h.auth.has_organiser_role) or c.funding.person == h.signed_in_person()):
# Raise a no_auth error
h.auth.no_role()
return render('/funding_attachment/confirm_delete.mako')
示例8: view
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def view(self, id):
# We need to recheck auth in here so we can pass in the id
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(id), h.auth.has_organiser_role, h.auth.has_funding_reviewer_role)):
# Raise a no_auth error
h.auth.no_role()
c.funding = Funding.find_by_id(id)
return render('funding/view.mako')
示例9: _delete
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def _delete(self, id):
c.attachment = FundingAttachment.find_by_id(id)
funding = Funding.find_by_id(c.attachment.funding_id)
if not (h.auth.authorized(h.auth.has_organiser_role) or funding.person == h.signed_in_person()):
# Raise a no_auth error
h.auth.no_role()
meta.Session.delete(c.attachment)
meta.Session.commit()
h.flash("Attachment Deleted")
redirect_to(controller='funding', action='view', id=funding.id)
示例10: view
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def view(self, id):
attachment = FundingAttachment.find_by_id(id)
funding = Funding.find_by_id(attachment.funding_id)
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(funding.id), h.auth.has_organiser_role, h.auth.has_funding_reviewer_role)):
# 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
示例11: _withdraw
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def _withdraw(self, id):
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(id), h.auth.has_organiser_role)):
# Raise a no_auth error
h.auth.no_role()
c.funding = Funding.find_by_id(id)
status = FundingStatus.find_by_name('Withdrawn')
c.funding.status = status
meta.Session.commit()
c.person = h.signed_in_person()
# Make sure the organisers are notified of this
c.email_address = c.funding.type.notify_email
email(c.email_address, render('/funding/withdraw_email.mako'))
h.flash("Funding withdrawn. The organisers have been notified.")
return redirect_to(controller='funding', action="index", id=None)
示例12: _attach
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def _attach(self, id):
"""Attach a file to the funding.
"""
# We need to recheck auth in here so we can pass in the id
if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_funding_submitter(id), h.auth.has_organiser_role)):
# Raise a no_auth error
h.auth.no_role()
c.funding = Funding.find_by_id(id)
attachment_results = self.form_result['attachment']
attachment = FundingAttachment(**attachment_results)
c.funding.attachments.append(attachment)
meta.Session.commit()
h.flash("File was attached")
return redirect_to(action='view', id=id)
示例13: view
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def view(self, id):
attachment = FundingAttachment.find_by_id(id)
funding = Funding.find_by_id(attachment.funding_id)
if not h.auth.authorized(
h.auth.Or(
h.auth.is_same_zkpylons_funding_submitter(funding.id),
h.auth.has_organiser_role,
h.auth.has_funding_reviewer_role,
)
):
# Raise a no_auth error
h.auth.no_role()
response.headers["content-type"] = attachment.content_type
response.headers.add("content-transfer-encoding", "binary")
response.headers.add("content-length", len(attachment.content))
response.headers["content-disposition"] = 'attachment; filename="%s";' % attachment.filename
response.headers.add("Pragma", "cache")
response.headers.add("Cache-Control", "max-age=3600,public")
return attachment.content
示例14: _to_python
# 需要导入模块: from zkpylons.model import Funding [as 别名]
# 或者: from zkpylons.model.Funding import find_by_id [as 别名]
def _to_python(self, value, state):
return Funding.find_by_id(int(value))