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


Python Subscription.save方法代码示例

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


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

示例1: signup_verify

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def signup_verify(request):
    email = request.GET.get('email', '')
    skey = request.GET.get('skey', '')
    old = datetime.now() - timedelta(days=10)
    blists = []
    try:
        optin = Optin.objects.get(skey=skey, email=email, created__gte=old)
        for l in optin.bulk_lists.all():
            if Subscription.subscribed.filter(email__iexact=optin.email, bulk_list=l).count() == 0:
                s = Subscription(email=optin.email, signup_location=optin.signup_location, bulk_list=l)
                s.save()

            blists.append(l)

        optin.verify(request)
    except Optin.DoesNotExist:
        #they've already subscribed; let's show them that instead of a 404
        #this prevents emails like "my link isn't working" after they've already clicked it once
        subs = Subscription.objects.filter(email=email)
        if len(subs):
            for sub in subs:
                blists.append(sub.bulk_list)
        else:
            raise Http404

    c = {'lists': blists}
    return TemplateResponse(request, 'signup_verified.html', c)
开发者ID:EdgeCaseLabs,项目名称:django-ecl-tools,代码行数:29,代码来源:views.py

示例2: create

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def create(request):
    form = SubscriptionForm(request.POST)

    if not form.is_valid():
        context = RequestContext(request, {'form': form})
        return render_to_response('subscription/new.html',context)

    s = Subscription()
    s.name = form.cleaned_data['name']
    s.cpf = form.cleaned_data['cpf']
    s.email = form.cleaned_data['email']
    s.phone = form.cleaned_data['phone']
    s.save()

    #notifica o cadastro
    send_subscription_email(s)
    return HttpResponseRedirect(reverse ('subscription:success', args=[subsdcription.pk]))
开发者ID:gusnetto,项目名称:eventex,代码行数:19,代码来源:views.py

示例3: newSubs

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def newSubs(resid, clientid):
    
    try:
        parentRes = Resource.objects.get(resource_id=resid)
    except Resource.DoesNotExist:
        return HttpResponse(content="Resource not found", status=404)
    #TODO validate clientid
    duration = parentRes.sub_duration 
    if ( duration == None ):
        timestamp = -1
    else:      
        timestamp = time.time() + duration
    subs = Subscription(resource=parentRes, 
                        client_id = clientid, 
                        credits_count = parentRes.sub_max_credits_count, 
                        expires = timestamp )
    subs.save()
开发者ID:vivainio,项目名称:authorizr,代码行数:19,代码来源:views.py

示例4: email

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def email(request):
    if request.method == "POST":
        email = request.POST["email"]
        if isLegitEmail(email) and request.POST["lastname"] == "":
            o = Subscription(email=email)
            o.save()
            template = get_template("subscribe_email.html")
            text = template.render(Context({"email": email}))
            print "text!!!"
            msg = EmailMessage("Thanks for subscribing!", text, "[email protected]", [email])
            msg.content_subtype = "html"
            msg.send()
            emails = [e for (name, e) in settings.MANAGERS]
            msg2 = EmailMessage(email + " subscribed to benkuhn.net", "", "[email protected]", emails)
            msg2.send()
        return render(request, "sub.html", {"title": "thanks :)", "email": email})
    else:
        return render(request, "email.html", {"title": "subscribe via email"})
开发者ID:benkuhn,项目名称:benkuhn.net,代码行数:20,代码来源:views.py

示例5: new

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def new(request):
    if request.method != 'POST':
        return HttpResponse(status=405)
    else:
        form = SubscribeForm(request.POST)

        if form.is_valid():
            email = form.cleaned_data['email']
            url = form.cleaned_data['feed_link']
            try:
                rss_url = Rss.objects.get(link=url)
            except Rss.DoesNotExist:
                rss_url = Rss(link=url)
                rss_url.save()
                
            token = random_string(24)
                
            subscribe = Subscription(rss=rss_url,
                                  email=email,
                                  active=False,
                                  token=token)

            try:
                subscribe.save()
            except IntegrityError:
                return response_json({'status': 1, 'message': 'subscribe already exists'})

            #письмо активации подписчику
            params = {'email': email.encode('utf8'),
                      'rss': url.encode('utf8'),
                      'activate_link': '%s%s' % (re.sub(r'/$', '', settings.SERVICE_EXTERNAL_ROOT_URL),
                                                 reverse(manage, args=['activate', subscribe.id, subscribe.token]))}

            m_task = MailTask(subscribe=subscribe,
                              rss=rss_url,
                              title=settings.MAIL_ACTIVATE_TITLE,
                              message=settings.MAIL_ACTIVATE_TEMPLATE % params)
            m_task.save()

            return response_json({'status': 0, 'message': 'subscribe added'})
        
        else:
            return response_json({'status': 1, 'message': 'form is invalid', 'form_errors': form.errors})
开发者ID:zedxter,项目名称:subscriberss,代码行数:45,代码来源:views.py

示例6: subscribe

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def subscribe(request):
    options = ""
    text = ""
    for catg in Categories.objects.all():                       #fetch all the categories from DB
        options += "<option value=\""+catg.category+"\">" + catg.category + "</option>"
    if options == "" :
        text = "No Categories in the list..Come back later"

    if request.method == 'POST':
        name = request.POST['name']
        email = request.POST['email']
        phnNo = request.POST['phnNo']
        category = request.POST['category']
        user = User(name=name, email=email, phnno=phnNo)
        user.save()                                             #save user details in the DB
        subscription = Subscription(user=User.objects.get(email=email), category=Categories.objects.get(category=category))
        subscription.save()                                      #save users subscription details in the DB
        mailgun.send_mail(email,category+" News","Congratulations You have been subscribed to"+category+"news\n\nThank you for subscribing to our news service")                #Send subscription mail to the client
        text = "Subscribed successfully"
    return render(request, "CRM/subscribe.html", {'options': options, 'message':text})
开发者ID:viveksharma9413,项目名称:newscrm,代码行数:22,代码来源:views.py

示例7: subscribe

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
def subscribe(request):
	classNumber = request.REQUEST['classNumber']
	theclass = Class.objects.get(number=classNumber)
	try:
		# Subscribe email
		email = request.user.username + "@princeton.edu"
		log.log("subscribeEmail %s %s" % (classNumber, email))
		subscription = Subscription(address = email, theclass = theclass, type = "EMAIL")
		subscription.save()
		subscription.sendConfirmation()
		
		# Subscribe text, if appropriate
		if 'phoneNumber' in request.REQUEST:
			phoneNumber = request.REQUEST['phoneNumber']
			log.log("subscribeText %s %s" % (classNumber, phoneNumber))
			theclass = Class.objects.get(number=classNumber)
			subscription = Subscription(address = phoneNumber, theclass = theclass, type = "TEXT")
			subscription.save()
			subscription.sendConfirmation()
		return HttpResponse("+<b>Success!</b> You will soon receive an email and/or text verifying your subscription for <strong>%s</strong>." % str(theclass))
	except:
		log.log("subscribe ERROR")
		return HttpResponse(traceback.format_exc())
		return HttpResponse("-<b>Something went wrong.</b> You are not subscribed for <strong>%s</strong>. If this problem persists, please <a href='mailto:[email protected]'>contact the developers</a>." % str(theclass))
开发者ID:PrincetonUSG,项目名称:USG-srv-dev,代码行数:26,代码来源:views.py

示例8: makeCred

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
    cred.hash = base64.b64encode(crypto.pbkdf2(password, cred.salt, iterations=cred.iterations))
    cred.account = account
    return cred

makeCred(whitelynx, "pass").save()
makeCred(morgul, "pass").save()
makeCred(burst, "pass").save()
makeCred(lordnull, "pass").save()

print "Finished Credentials."


sub = Subscription()
sub.game = precursors
sub.account = whitelynx
sub.save()

sub = Subscription()
sub.game = precursors
sub.account = morgul
sub.save()

sub = Subscription()
sub.game = precursors
sub.account = burst
sub.save()

sub = Subscription()
sub.game = precursors
sub.account = lordnull
sub.save()
开发者ID:SkewedAspect,项目名称:precursors-server,代码行数:33,代码来源:load_initial_db.py

示例9: SalesViewsTest

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import save [as 别名]
class SalesViewsTest(TestCase):
    username = "test"
    password = "password"

    def setUp(self):
        self.group, created = Group.objects.get_or_create(name="test")
        self.user, created = DjangoUser.objects.get_or_create(username=self.username)
        self.user.set_password(self.password)
        self.user.save()
        perspective, created = Perspective.objects.get_or_create(name="default")
        perspective.set_default_user()
        perspective.save()
        ModuleSetting.set("default_perspective", perspective.id)

        self.contact_type = ContactType()
        self.contact_type.slug = "machine"
        self.contact_type.name = "machine"
        self.contact_type.save()

        self.contact = Contact()
        self.contact.contact_type = self.contact_type
        self.contact.set_default_user()
        self.contact.save()
        self.assertNotEquals(self.contact.id, None)

        self.status = SaleStatus()
        self.status.set_default_user()
        self.status.save()
        self.assertNotEquals(self.status.id, None)

        self.currency = Currency(code="GBP", name="Pounds", symbol="L", is_default=True)
        self.currency.save()

        self.source = SaleSource()
        self.source.set_default_user()
        self.source.save()
        self.assertNotEquals(self.source.id, None)

        self.product = Product(name="Test")
        self.product.product_type = "service"
        self.product.active = True
        self.product.sell_price = 10
        self.product.buy_price = 100
        self.product.set_default_user()
        self.product.save()
        self.assertNotEquals(self.product.id, None)

        self.subscription = Subscription()
        self.subscription.client = self.contact
        self.subscription.set_default_user()
        self.subscription.save()
        self.assertNotEquals(self.subscription.id, None)

        self.lead = Lead()
        self.lead.contact_method = "email"
        self.lead.status = self.status
        self.lead.contact = self.contact
        self.lead.set_default_user()
        self.lead.save()
        self.assertNotEquals(self.lead.id, None)

        self.opportunity = Opportunity()
        self.opportunity.lead = self.lead
        self.opportunity.contact = self.contact
        self.opportunity.status = self.status
        self.opportunity.amount = 100
        self.opportunity.amount_currency = self.currency
        self.opportunity.amount_display = 120
        self.opportunity.set_default_user()
        self.opportunity.save()
        self.assertNotEquals(self.opportunity.id, None)

        self.order = SaleOrder(reference="Test")
        self.order.opportunity = self.opportunity
        self.order.status = self.status
        self.order.source = self.source
        self.order.currency = self.currency
        self.order.total = 0
        self.order.total_display = 0
        self.order.set_default_user()
        self.order.save()
        self.assertNotEquals(self.order.id, None)

        self.ordered_product = OrderedProduct()
        self.ordered_product.product = self.product
        self.ordered_product.order = self.order
        self.ordered_product.rate = 0
        self.ordered_product.subscription = self.subscription
        self.ordered_product.set_default_user()
        self.ordered_product.save()

        self.assertNotEquals(self.ordered_product.id, None)

    ######################################
    # Testing views when user is logged in
    ######################################
    def test_index(self):
        "Test page with login at /sales/index"
        response = self.client.post("/accounts/login", {"username": self.username, "password": self.password})
        self.assertRedirects(response, "/")
#.........这里部分代码省略.........
开发者ID:tovmeod,项目名称:anaf,代码行数:103,代码来源:tests.py


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