• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python membership.Membership类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中membership.Membership的典型用法代码示例。如果您正苦于以下问题:Python Membership类的具体用法?Python Membership怎么用?Python Membership使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: BaseTest

class BaseTest(unittest.TestCase):
  def setUp(self):
    # Set up testing for application.
    self.test_app = webtest.TestApp(billing.app)

    # Set up datastore for testing.
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_user_stub()

    # Make some testing plans.
    self.test_plan = plans.Plan("test", 0, 150, "This is a test plan.")
    self.test_plan_legacy = plans.Plan("test_legacy", 1, 100,
                                       "This is a test plan.",
                                       legacy=self.test_plan)

    # Make a test user.
    self.user = Membership(email="[email protected]",
                           first_name="Testy", last_name="Testerson",
                           username="testy.testerson",
                           spreedly_token="notatoken", plan="test")
    self.user.put()

    # Simulate the user login.
    self.testbed.setup_env(user_email=self.user.email, user_is_admin="0",
                           overwrite=True)

  def tearDown(self):
    self.testbed.deactivate()
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:30,代码来源:test_billing.py


示例2: post

  def post(self):
    if Config().is_dev:
      # Only allow this if it's the dev server.
      entry = self.request.body
      logging.debug("Got new entry: " + entry)
      entry = json.loads(entry)
      # Change formatted date back into datetime.
      for key in entry.keys():
        if type(getattr(Membership, key)) == db.DateTimeProperty:
          if not entry[key]:
            # It could be None as well.
            continue
          entry[key] = pickle.loads(str(entry[key]))
      # entry should have everything nicely in a dict...
      member = Membership(**entry)

      # Is this an update or a new model?
      match = Membership.all().filter("email =", member.email).get()
      if match:
        # Replace the old one.
        logging.debug("Found entry with same username. Replacing...")
        db.delete(match)

      member.put()
      logging.debug("Put entry in datastore.")
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:25,代码来源:cron.py


示例3: MembershipTest

class MembershipTest(unittest.TestCase):

    def setUp(self):
        """Setup method to instance an object of Membership class """
        code = 9
        name = "Gold"
        discount = 10
        self.membership = Membership(code, name, discount)
        self.test_membership = Membership(5, "Platinum", 5)
        
    def test_create_membership(self):
        """Test if an instance is created with the required data"""
        self.assertIsInstance(self.test_membership, Membership)
        
    def test_set_code_of_membership(self):
        """Test to update the membership code"""
        other_code = 10
        self.test_membership.set_code(other_code)
        self.assertEqual(other_code, self.test_membership.get_code())
        
    def test_set_name_of_membership(self):
        """ Test to update the membership name"""
        other_name = "Platinum"
        self.test_membership.set_name(other_name)
        self.assertEqual(other_name, self.test_membership.get_name())
        
    def test_set_discont_of_membership(self):
        """ Test to update the membership discount"""
        other_discount = 11
        self.test_membership.set_discount(other_discount)
        self.assertEqual(other_discount, self.test_membership.get_discount())
开发者ID:grettarocha,项目名称:DEVFUNDA,代码行数:31,代码来源:membership_test.py


示例4: post

    def post(self):
        user = users.get_current_user()
        if not user:
            self.redirect(users.create_login_url("/key"))
            return
        account = Membership.all().filter("username =", user.nickname().split("@")[0]).get()
        if not account or not account.spreedly_token or account.status != "active":
            message = "Error #1982, which should never happen."
            internal = True
            self.response.out.write(self.render("templates/error.html", locals()))
            return
        is_park = self.request.get("ispark")
        if is_park == "True":  # checks if user input is a parking pass number or an rfid number
            pass_to_add = self.request.get("parking_pass")
            try:  # tests if there are only numbers in the parking pass
                float(pass_to_add)
            except ValueError:
                message = '<p>A Parking Pass may only contain numbers.</p><a href="/key">Try Again</a>'
                internal = False
                self.response.out.write(self.render("templates/error.html", locals()))
                return
            account.parking_pass = pass_to_add

            logging.debug("Setting parking pass for %s to %s." % (account.full_name(), account.parking_pass))

            db.put(account)
            self.response.out.write(self.render("templates/pass_ok.html", locals()))  # outputs the parking number
        else:
            rfid_tag = self.request.get("rfid_tag").strip()
            description = self.request.get("description").strip()
            if rfid_tag.isdigit():
                if Membership.all().filter("rfid_tag =", rfid_tag).get():
                    message = "<p>That RFID tag is in use by someone else.</p>"
                    internal = False
                    self.response.out.write(self.render("templates/error.html", locals()))
                    return
                if not description:
                    message = "<p>Please enter a reason why you are associating a replacement RFID key.  Please hit BACK and try again.</p>"
                    internal = False
                    self.response.out.write(self.render("templates/error.html", locals()))
                    return
                account.rfid_tag = rfid_tag

                logging.debug("Setting RFID for %s to %s." % (account.full_name(), account.rfid_tag))

                account.put()
                bc = BadgeChange(rfid_tag=rfid_tag, username=account.username, description=description)
                bc.put()
                self.response.out.write(self.render("templates/key_ok.html", locals()))
                return
            else:
                message = "<p>That RFID ID seemed invalid. Hit back and try again.</p>"
                internal = False
                self.response.out.write(self.render("templates/error.html", locals()))
                return
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:55,代码来源:main.py


示例5: test_discount

  def test_discount(self):
    # A unique number on all the giftcards.
    serial = "1678"
    # A "correct" hash, based on what the actual code does.
    correct_hash = hashlib.sha1(serial + self.code).hexdigest()
    correct_hash = re.sub("[a-f]", "", correct_hash)[:8]
    gift_code = "1337" + serial + correct_hash
    print "Using test gift code: %s" % (gift_code)

    # Now try using this code.
    user = Membership.get_by_hash(self.user_hash)
    user.referrer = gift_code
    user.put()

    response = self.test_app.post("/account/" + self.user_hash,
                                  self._TEST_PARAMS)
    self.assertEqual(302, response.status_int)

    # We should have a record of the used code.
    codes = main.UsedCode.all().run()
    for code in codes:
      # We should only have one code in there.
      self.assertEqual(gift_code, code.code)
      self.assertEqual("[email protected]", code.email)
      self.assertEqual("OK", code.extra)

    user = Membership.get_by_hash(self.user_hash)
    user.username = None
    user.put()

    # Try to use the same code again.
    response = self.test_app.post("/account/" + self.user_hash,
                                  self._TEST_PARAMS, expect_errors=True)
    self.assertEqual(422, response.status_int)
    self.assertIn("already been used", response.body)

    # Now we should have individual records of the same code being used twice.
    codes = main.UsedCode.all().run()
    # Turn the iterator into a list.
    codes = [code for code in codes]

    self.assertEqual(gift_code, codes[0].code)
    self.assertEqual(gift_code, codes[1].code)
    self.assertEqual("[email protected]", codes[0].email)
    self.assertEqual("[email protected]", codes[1].email)
    if codes[0].extra == "OK":
      # The other one should be the duplicate.
      self.assertEqual("2nd+ attempt", codes[1].extra)
    elif codes[0].extra == "2nd+ attempt":
      # The other one should be the good one.
      self.assertEqual("OK", codes[1].extra)
    else:
      fail("Got unexpected extra '%s'." % (codes[0].extra))
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:53,代码来源:test_main.py


示例6: test_failure_if_account

  def test_failure_if_account(self):
    existing_user = Membership(first_name=self._TEST_PARAMS["first_name"],
                               last_name=self._TEST_PARAMS["last_name"],
                               email=self._TEST_PARAMS["email"],
                               spreedly_token=None,
                               username="testy.testerson",
                               password="notasecret")
    existing_user.put()

    response = self.test_app.post("/", self._TEST_PARAMS, expect_errors=True)
    self.assertEqual(422, response.status_int)

    self.assertIn("payment", response.body)
开发者ID:itstehkman,项目名称:hd-signup,代码行数:13,代码来源:test_main.py


示例7: setUp

  def setUp(self):
    super(CreateUserTaskTest, self).setUp()

    # Add a user to the datastore.
    user = Membership(first_name="Testy", last_name="Testerson",
                      email="[email protected]", hash="notahash",
                      spreedly_token="notatoken", username="testy.testerson",
                      password="notasecret")
    user.put()

    self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME)
    self.user_hash = user.hash
    self.params = {"hash": self.user_hash, "username": "testy.testerson",
                   "password": "notasecret"}
开发者ID:itstehkman,项目名称:hd-signup,代码行数:14,代码来源:test_main.py


示例8: post

    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")
开发者ID:martinlschumann,项目名称:hd-signup,代码行数:35,代码来源:main.py


示例9: post

 def post(self):
     user = Membership.get_by_id(int(self.request.get("user")))
     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:
       noop = True
     user.delete()
开发者ID:itstehkman,项目名称:hd-signup,代码行数:26,代码来源:main.py


示例10: setUp

 def setUp(self):
     """Setup method to instance an object of Membership class """
     code = 9
     name = "Gold"
     discount = 10
     self.membership = Membership(code, name, discount)
     self.test_membership = Membership(5, "Platinum", 5)
开发者ID:grettarocha,项目名称:DEVFUNDA,代码行数:7,代码来源:membership_test.py


示例11: test_user_suspending

  def test_user_suspending(self):
    user = Membership.get_by_email("[email protected]")
    # The next one should suspend us.
    user.signins = Config().LITE_VISITS - 1
    user.put()

    params = {"email": "[email protected]"}
    response = self.test_app.post("/api/v1/signin", params)
    result = json.loads(response.body)

    self.assertEqual(200, response.status_int)
    self.assertEqual(0, result["visits_remaining"])

    user = Membership.get_by_email("[email protected]m")
    self.assertEqual(Config().LITE_VISITS, user.signins)
    self.assertEqual("no_visits", user.status)
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:16,代码来源:test_user_api.py


示例12: test_create_user

  def test_create_user(self):
    response = self.test_app.post("/tasks/create_user", self.params)
    self.assertEqual(200, response.status_int)

    # Check that it's sending the right parameters to the domain app.
    self.assertIn("username=testy.testerson", response.body)
    self.assertIn("password=notasecret", response.body)
    self.assertIn("first_name=Testy", response.body)
    self.assertIn("last_name=Testerson", response.body)

    user = Membership.get_by_hash(self.user_hash)
    # Check that the user ended up with a username.
    self.assertEqual("testy.testerson", user.username)
    # Check that domain_user got set.
    self.assertTrue(user.domain_user)
    # Check that the password got cleared.
    self.assertEqual(None, user.password)

    # Check that it sent the right email.
    messages = self.mail_stub.get_sent_messages(to="[email protected]")
    self.assertEqual(1, len(messages))

    # It should give the user this data.
    body = str(messages[0].body)
    self.assertIn(user.username, body)
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:25,代码来源:test_tasks.py


示例13: get

  def get(self):
    user = users.get_current_user()
    if not user:
      self.redirect(users.create_login_url(self.request.uri))
      return

    member = Membership.get_by_email(user.email())
    if not member:
      # User is not (yet) a member.
      self.redirect("/")
      return
    else:
      # Open billing information.
      url = member.spreedly_url()
      plan = Plan.get_by_name(member.plan)
      if plan.legacy:
        # Show the legacy plan warning.
        current = plan.get_legacy_pair()
        self.response.out.write(self.render(
            "templates/billing_popup.html",
            url=url, legacy=plan, current=current))
        return
      else:
        self.redirect(url)
        return
开发者ID:nasebanal,项目名称:hd-signup,代码行数:25,代码来源:billing.py


示例14: get

 def get(self):
   countdown = 0
   for membership in Membership.all().filter("status =", None):
     if (datetime.datetime.now().date() - membership.created.date()).days > 1:
       countdown += 90
       self.response.out.write("bye %s " % (membership.email))
       taskqueue.add(url="/tasks/clean_row", params={"user": membership.key().id()}, countdown=countdown)
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:7,代码来源:cron.py


示例15: get

 def get(self, hash):
     member = Membership.get_by_hash(hash)
     conf = Config()
     if member:
         success_html = urlfetch.fetch(conf.SUCCESS_HTML_URL).content
         success_html = success_html.replace("joining!", "joining, %s!" % member.first_name)
         is_prod = conf.is_prod
         self.response.out.write(self.render("templates/success.html", locals()))
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:8,代码来源:main.py


示例16: get

 def get(self, hash):
     member = Membership.get_by_hash(hash)
     c = Config()
     if member:
       success_html = urlfetch.fetch(SUCCESS_HTML_URL).content
       success_html = success_html.replace('joining!', 'joining, %s!' % member.first_name)
       is_prod = c.is_prod
       self.response.out.write(render('templates/success.html', locals()))
开发者ID:martinlschumann,项目名称:hd-signup,代码行数:8,代码来源:main.py


示例17: get

 def get(self):
   user = users.get_current_user()
   if not user:
     self.redirect(users.create_login_url("/joinreasonlist"))
   if users.is_current_user_admin():
     all_users = Membership.all().order("created").fetch(10000)
     self.response.out.write(self.render("templates/joinreasonlist.html", locals()))
   else:
     self.response.out.write("Need admin access")
开发者ID:itstehkman,项目名称:hd-signup,代码行数:9,代码来源:main.py


示例18: test_retry_no_token

  def test_retry_no_token(self):
    # Make a user with no token.
    user = Membership.get_by_hash(self.user_hash)
    user.spreedly_token=None
    user.put()

    # Try to create an account for this user.
    response = self.test_app.post("/tasks/create_user", self.params)
    self.assertEqual(200, response.status_int)

    # We should have a new task now.
    taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
    tasks = taskqueue_stub.GetTasks("default")
    self.assertEqual(1, len(tasks))

    # The user shouldn't have a domain account yet.
    user = Membership.get_by_hash(self.user_hash)
    self.assertFalse(user.domain_user)
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:18,代码来源:test_tasks.py


示例19: setUp

  def setUp(self):
    super(ReactivatePlanHandlerTest, self).setUp()

    # Add a user to test with.
    self.user = Membership(first_name="Testy", last_name="Testerson",
                           email="[email protected]", plan="plan1",
                           spreedly_token="notatoken", hash="notahash",
                           username="testy.testerson")
    self.user.put()
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:9,代码来源:test_main.py


示例20: test_get

  def test_get(self):
    query = urllib.urlencode({"plan": "newhive"})
    response = self.test_app.get("/account/%s?%s" % (self.user_hash, query))
    self.assertEqual(200, response.status_int)
    # Our username should be templated in.
    self.assertIn("testy.testerson", response.body)

    user = Membership.get_by_hash(self.user_hash)
    self.assertEqual("newhive", user.plan)
开发者ID:hackerdojo,项目名称:hd-signup,代码行数:9,代码来源:test_main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python memcache._Host函数代码示例发布时间:2022-05-27
下一篇:
Python models.Member类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap