本文整理汇总了Python中membership.Membership.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Membership.get_by_id方法的具体用法?Python Membership.get_by_id怎么用?Python Membership.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membership.Membership
的用法示例。
在下文中一共展示了Membership.get_by_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def post(self):
subscriber_ids = self.request.get("subscriber_ids").split(",")
for id in subscriber_ids:
logging.debug("Updating subscriber with id %s." % id)
subscriber_api.update_subscriber(Membership.get_by_id(int(id)))
self.response.out.write("ok")
示例2: post
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def post(self):
user_id = int(self.request.get("user"))
logging.debug("Getting member with id: %d" % (user_id))
user = Membership.get_by_id(int(self.request.get("user")))
if not user:
logging.error("Bad ID for member.")
self.abort(422)
logging.info("Sending email to %s %s." % \
(user.first_name, user.last_name))
subject = "Hacker Dojo Membership: ACTION REQUIRED"
first_name = user.first_name
subscribe_url = user.subscribe_url()
unsubscribe_url = user.unsubscribe_url()
body = self.render("templates/areyoustillthere.txt", locals())
to = "%s <%s>" % (user.full_name(), user.email)
bcc = "%s <%s>" % ("Billing System", "[email protected]")
if user.username:
cc="%s <%[email protected]>" % (user.full_name(), user.username),
mail.send_mail(sender=Config().EMAIL_FROM_AYST, to=to,
subject=subject, body=body, bcc=bcc, cc=cc)
else:
mail.send_mail(sender=Config().EMAIL_FROM_AYST, to=to,
subject=subject, body=body, bcc=bcc)
示例3: post
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def post(self, ids=None):
subscriber_ids = self.request.get('subscriber_ids').split(',')
c = Config()
s = spreedly.Spreedly(c.SPREEDLY_ACCOUNT, token=c.SPREEDLY_APIKEY)
for id in subscriber_ids:
subscriber = s.subscriber_details(sub_id=int(id))
logging.debug("customer_id: "+ subscriber['customer-id'])
member = Membership.get_by_id(int(subscriber['customer-id']))
if member:
if member.status == 'paypal':
mail.send_mail(sender=EMAIL_FROM,
to=PAYPAL_EMAIL,
subject="Please cancel PayPal subscription for %s" % member.full_name(),
body=member.email)
member.status = 'active' if subscriber['active'] == 'true' else 'suspended'
if member.status == 'active' and not member.username:
taskqueue.add(url='/tasks/create_user', method='POST', params={'hash': member.hash}, countdown=3)
if member.status == 'active' and member.unsubscribe_reason:
member.unsubscribe_reason = None
member.spreedly_token = subscriber['token']
member.plan = subscriber['feature-level'] or member.plan
if not subscriber['email']:
subscriber['email'] = "[email protected]"
member.email = subscriber['email']
member.put()
# TODO: After a few months (now() = 06.13.2011), only suspend/restore if status CHANGED
# As of right now, we can't trust previous status, so lets take action on each call to /update
if member.status == 'active' and member.username:
logging.info("Restoring User: "+member.username)
self.restore(member.username)
if member.status == 'suspended' and member.username:
logging.info("Suspending User: "+member.username)
self.suspend(member.username)
self.response.out.write("ok")
示例4: test_cleanup
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def test_cleanup(self):
response = self.test_app.post("/tasks/clean_row", self.params)
self.assertEqual(200, response.status_int)
# Make sure the user is gone.
user = Membership.get_by_id(self.user_id)
self.assertEqual(None, user)
# Make sure our email got sent and looks correct.
messages = self.mail_stub.get_sent_messages(to=self.user.email)
self.assertEqual(1, len(messages))
body = str(messages[0].body)
self.assertIn(self.user.full_name(), body)
示例5: test_bad_user_id
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def test_bad_user_id(self):
params = {"user": "1337"}
response = self.test_app.post("/tasks/clean_row", params)
# The status should still be okay, because we don't want it to retry in this
# case.
self.assertEqual(200, response.status_int)
# The user should still be there.
user = Membership.get_by_id(self.user_id)
self.assertNotEqual(None, user)
# No email should have gotten sent.
messages = self.mail_stub.get_sent_messages(to=self.user.email)
self.assertEqual(0, len(messages))
示例6: post
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def post(self):
user_id = self.request.get("user")
user = Membership.get_by_id(int(user_id))
if not user:
logging.warning("No user with id %s." % (user_id))
# Don't change the status, because we don't want it to retry.
return
logging.info("Sending email to %s." % (user.email))
try:
mail.send_mail(sender=Config().EMAIL_FROM,
to=user.email,
subject="Hi again -- from Hacker Dojo!",
body="Hi %s,"
"\nOur fancy membership system noted that you started filling"
" out the Membership Signup form, but didn't complete it."
"\nWell -- We'd love to have you as a member!"
"\nHacker Dojo has grown by leaps and bounds in recent years."
" Give us a try?"
"\nIf you would like to become a member of Hacker Dojo, just"
" complete the signup process at http://signup.hackerdojo.com"
"\nIf you don't want to sign up -- please give us anonymous"
" feedback so we know how we can do better! URL:"
" http://bit.ly/jJAGYM"
"\nCheers!\nHacker Dojo"
"\n\nPS: Please ignore this e-mail if you already signed up --"
" you might have started signing up twice or something :)"
" PPS: This is an automated e-mail and we're now deleting your"
" e-mail address from the signup application." % (user.full_name())
)
except mail.BadRequestError:
# Apparently, sometimes people enter bad email addresses. In this case, we
# can just clear them silently.
logging.warning("Deleting user with invalid email address.")
user.delete()
示例7: get
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def get(self, key):
conf = Config()
sa = conf.SPREEDLY_ACCOUNT
u = Membership.get_by_id(int(key))
plan_ids = plans.Plan.get_all_plan_ids()
self.response.out.write(self.render("templates/genlink.html", locals()))
示例8: get
# 需要导入模块: from membership import Membership [as 别名]
# 或者: from membership.Membership import get_by_id [as 别名]
def get(self,key):
c = Config()
sa = c.SPREEDLY_ACCOUNT
u = Membership.get_by_id(int(key))
plans = c.PLAN_IDS
self.response.out.write(render('templates/genlink.html', locals()))