当前位置: 首页>>代码示例>>Python>>正文


Python Email.get_by_key_name方法代码示例

本文整理汇总了Python中models.Email.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Email.get_by_key_name方法的具体用法?Python Email.get_by_key_name怎么用?Python Email.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Email的用法示例。


在下文中一共展示了Email.get_by_key_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import get_by_key_name [as 别名]
 def get(self, club_id, email_id):
     # check credentials
     if not(check_admin(club_id)):
         add_notify("Error", "You do not have the appropriate permissions")
         self.redirect("/")
         return
     user = users.get_current_user()
     club = Club.get_by_key_name(club_id)
     
     # get the email to be admin-ified
     email = Email.get_by_key_name(email_id)
     if not(email):
         add_notify("Error", "No email to be promoted!")
         self.redirect("/club/%s" % club.slug)
         return
     # find the link to promote it
     query = EmailToClub.all()
     query.filter("email =", email)
     query.filter("club =", club)
     link = query.get()
     if not(link):
         add_notify("Error", "No email to be promoted!")
         self.redirect("/club/%s" % club.slug)
         return
     if not link.enable:
         add_notify("Error", "Can't promote a disabled email")
         self.redirect("/club/%s" % club.slug)
         return
     # flip the admin bit
     link.admin = not(link.admin)
     link.put()
     # make sure we have at least one admin
     query = EmailToClub.all()
     query.filter("club =", club)
     query.filter("admin =", True)
     admin_check = query.get()
     if not(admin_check):
         # reverse the admin
         link.admin = True
         link.put()
     # send an email if you've just been promoted
     if link.admin:
         domain = "http://%s.appspot.com" % get_application_id()
         msg = mail.EmailMessage()
         fromaddr = "[email protected]%s.appspotmail.com" % get_application_id()
         msg.sender  = "Flyer Guy <%s>" % fromaddr
         msg.to      = email.email
         msg.subject = "[Flyer] You've an admin of %s!" % club.name
         msg.html    = template.render("templates/email_admin.html",
                                       {"domain":domain,
                                        "club":club.name,
                                        "email":email.id})
         try:
             msg.send()
         except apiproxy_errors.OverQuotaError, (message,):
             # Log the error
             add_notify("Error", "Could not send email")
             logging.error("Could not send email")
             logging.error(message)
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:61,代码来源:flyer.py


注:本文中的models.Email.get_by_key_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。