本文整理汇总了Python中subscription.models.Subscription类的典型用法代码示例。如果您正苦于以下问题:Python Subscription类的具体用法?Python Subscription怎么用?Python Subscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Subscription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: subscriptions
def subscriptions(request):
group = get_last_used_group(request.user)
context = base_context(request, group.id)
try:
subscription = Subscription.objects.get(user=request.user)
except Subscription.DoesNotExist:
Subscription.subscribe_for_the_first_time(request.user, request.user)
subscription = Subscription.objects.get(user=request.user)
waiting_payment_subscriptions = Payment.objects.filter(created_by=request.user, status=WAITING).order_by(
"datetime_created"
)
subscriptions = Subscriptions.objects.filter(subscription=subscription).order_by("-datetime_created")
my_payments = Payment.objects.filter(
Q(status=PAID) | Q(status=NOT_ENOUGH_MONEY_ARRIVED) | Q(status=CANCELED), created_by=request.user
).order_by("-datetime_created")
previous = None
for wps in waiting_payment_subscriptions:
wps.other_users_included_in_payment = wps.other_users_included_in_payment(request.user)
wps.me_included = wps.me_included_in_payment(request.user)
if wps.me_included:
if not previous:
wps.start_date = subscription.expiration_date
wps.end_date = wps.start_date + datetime.timedelta(days=wps.subscription_duration * 31)
else:
wps.start_date = previous.end_date
wps.end_date = wps.start_date + datetime.timedelta(days=wps.subscription_duration * 31)
previous = wps
context["sepa_address"] = settings.PAYMENT["sepa"]
context["subscription"] = subscription
context["waiting_payment_subscriptions"] = waiting_payment_subscriptions
context["subscriptions"] = subscriptions
context["my_payments"] = my_payments
context["show_hide_canceled_button"] = False
context["user"] = request.user
context["subscription"] = Subscription.objects.get(user=request.user)
# 'others_included': None,
# 'past_subscriptions': past_subscriptions,
context["title"] = _("My subscriptions")
context["site_title"] = g.SITE_TITLE
context["section"] = "settings"
context["NOT_ENOUGH_MONEY_ARRIVED_STATUS"] = NOT_ENOUGH_MONEY_ARRIVED
context["NO_MONEY_ARRIVED_STATUS"] = NO_MONEY_ARRIVED
context["WAITING_STATUS"] = WAITING
context["CANCELED_STATUS"] = CANCELED
context["ALMOST_PAID_STATUS"] = ALMOST_PAID
context["PAID_STATUS"] = PAID
context["RUNNING_STATUS"] = RUNNING
return render(request, "subscription/subscriptions.html", context)
开发者ID:rokj,项目名称:sellout,代码行数:60,代码来源:views.py
示例2: webhook_task
def webhook_task(request):
"""BadFilterError: invalid filter: Only one property per query may have inequality filters (<=, >=, <, >).."""
subscriptions = Subscription.all().filter("webhook !=", None)
counter = 0
for obj in subscriptions:
Subscription.add_webhook_task(obj.key())
counter += 1
return HttpResponse("Done: added %d" % counter)
开发者ID:AnaCm,项目名称:seriesly,代码行数:8,代码来源:views.py
示例3: xmpp_task
def xmpp_task(request):
subscription_keys = Subscription.all(keys_only=True).filter("activated_xmpp =", True)
# .filter("next_airtime <", datetime.datetime.now().date())
counter = 0
for key in subscription_keys:
Subscription.add_xmpp_task(key)
counter += 1
return HttpResponse("Done: added %d" % counter)
开发者ID:AnaCm,项目名称:seriesly,代码行数:8,代码来源:views.py
示例4: email_task
def email_task(request):
filter_date = datetime.datetime.now().date() + datetime.timedelta(days=1)
subscription_keys = Subscription.all(keys_only=True).filter("activated_mail =", True)\
.filter("next_airtime <=", filter_date)
counter = 0
for key in subscription_keys:
Subscription.add_email_task(key)
counter += 1
return HttpResponse("Done: added %d" % counter)
开发者ID:AnaCm,项目名称:seriesly,代码行数:9,代码来源:views.py
示例5: setUp
def setUp(self):
subscriber = Subscription(
name='Joao Paulo Dubas',
cpf='12345678901',
email='[email protected]',
phone='11-12345678'
)
subscriber.save()
开发者ID:joaodubas,项目名称:wttd4,代码行数:9,代码来源:tests_models.py
示例6: base_context
def base_context(request, company_id):
Subscription.is_subscription_almost_over(request.user)
Subscription.is_subscription_over(request.user)
actions = Action.objects.filter(status=g.WAITING, _for=request.user.email)
for a in actions:
if a.what == "invitation":
a.data = json.loads(a.data)
#if get_language() == "sl-si":
# accept_url = "sprejmi-povabilo-v-skupino/kljuc=%s" % (a.reference)
# decline_url = "zavrni-povabilo-v-skupino/kljuc=%s" % (a.reference)
# a.accept_url = settings.SITE_URL + settings.URL_PREFIX + accept_url
# a.decline_url = settings.SITE_URL + settings.URL_PREFIX + decline_url
#else:
accept_url = "accept-group-invitation/key=%s" % (a.reference)
decline_url = "decline-group-invitation/key=%s" % (a.reference)
a.accept_url = settings.SITE_URL + settings.URL_PREFIX + accept_url
a.decline_url = settings.SITE_URL + settings.URL_PREFIX + decline_url
# user_groups = request.user.get_user_groups()
"""
try:
user_profile = UserProfile.objects.get(user=request.user)
except UserProfile.DoesNotExist:
user_profile = None
"""""
context = {
'bluser': request.user,
# 'user_profile': user_profile,
'GOOGLE_API': settings.GOOGLE_API,
'actions': actions,
'subscription_link': reverse('subscription:new'),
# json values
# settings, config
'title': "", # will be overwritten by javascript
'language': get_user_value(request.user, "language"),
'clock_range': get_user_value(request.user, "clock_range"),
'site_title': g.SITE_TITLE,
'group_notes_keepalive': g.GROUP_NOTES_KEEPALIVE,
'date_format': g.DATE_FORMATS[get_user_value(request.user, 'date_format')]['jquery'] if request.user.is_authenticated() else g.DATE_FORMATS[g.DEFAULT_DATE_FORMAT]['jquery'],
'field_lengths': {
'max_notes_size': g.MAX_NOTES_SIZE,
}
}
return context
开发者ID:rokj,项目名称:sellout,代码行数:55,代码来源:views.py
示例7: test_send_email_after_save_form
def test_send_email_after_save_form(self):
self.assertEqual(len(mail.outbox), 0)
subscriber = Subscription(
name='Joao Paulo Dubas',
cpf='12345678901',
email='[email protected]',
phone='11-12345678'
)
subscriber.save()
self.assertEqual(len(mail.outbox), 1)
开发者ID:joaodubas,项目名称:wttd4,代码行数:12,代码来源:tests_models.py
示例8: test_save_subscription
def test_save_subscription(self):
subscriber = Subscription(
name='Joao Paulo Dubas',
cpf='12345678901',
email='[email protected]',
phone='11-12345678'
)
subscriber.save()
self.assertEqual(subscriber.pk, 1)
self.assertEqual(subscriber.created_at.date(), date.today())
self.assertFalse(subscriber.paid)
开发者ID:joaodubas,项目名称:wttd4,代码行数:13,代码来源:tests_models.py
示例9: get
def get(self, request):
partnerId=request.GET.get("partnerId")
ipAddress=request.GET.get("ipAddress")
userIdentifier=request.GET.get("userIdentifier")
expDate = ""
subscribed = False
sub = Subscription.getActiveByIp(ipAddress, partnerId)
if len(sub)==0:
if Credential.objects.filter(userIdentifier=userIdentifier).filter(partnerId=partnerId).exists():
partyId = Credential.objects.filter(userIdentifier=userIdentifier)[0].partyId.partyId
sub = Subscription.getActiveById(partyId, partnerId)
if len(sub)>0:
expDate = SubscriptionSerializer(sub[0]).data['endDate']
subscribed = True
return HttpResponse(json.dumps({'expDate':expDate, 'subscribed':subscribed}), content_type="application/json")
开发者ID:ahlfors,项目名称:api-python,代码行数:15,代码来源:views.py
示例10: create
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)
subscription = Subscription()
subscription.name = form.cleaned_data['name']
subscription.cpf = form.cleaned_data['cpf']
subscription.email = form.cleaned_data['email']
subscription.phone = form.cleaned_data['phone']
subscription.save()
send_subscription_email(subscription)
return HttpResponseRedirect(reverse('subscription:success', args=[subscription.pk]))
开发者ID:rafaeljneves,项目名称:Eventex,代码行数:15,代码来源:views.py
示例11: show
def show(request, subkey, extra_context=None):
subscription = Subscription.all().filter("subkey =", subkey).get()
if subscription is None:
raise Http404
if extra_context is None:
extra_context = {}
if "mail_form" in extra_context:
subscription.mail_form = extra_context["mail_form"]
else:
subscription.mail_form = MailSubscriptionForm({"email": subscription.email, "subkey": subkey})
if "xmpp_form" in extra_context:
subscription.xmpp_form = extra_context["xmpp_form"]
else:
subscription.xmpp_form = XMPPSubscriptionForm({"xmpp": subscription.xmpp, "subkey": subkey})
if "webhook_form" in extra_context:
subscription.webhook_form = extra_context["webhook_form"]
else:
subscription.webhook_form = WebHookSubscriptionForm({"webhook": subscription.webhook, "subkey": subkey})
if "public_id_form" in extra_context:
subscription.public_id_form = extra_context["public_id_form"]
else:
subscription.public_id_form = SubscriptionKeyForm({"subkey": subkey})
subscription.sub_settings = subscription.get_settings()
response = render_to_response("subscription.html", RequestContext(request,
{"shows": subscription.get_shows(), "subscription":subscription}))
response.set_cookie("subkey", subkey, max_age=31536000)
return response
开发者ID:AnaCm,项目名称:seriesly,代码行数:27,代码来源:views.py
示例12: get
def get(self, request, format=None):
if 'ip' not in request.GET:
return Response({'error': 'ip is required'},status=status.HTTP_400_BAD_REQUEST)
if 'partnerId' not in request.GET:
return Response({'error': 'partnerId is required'}, status=status.HTTP_400_BAD_REQUEST)
ip = request.GET.get('ip')
partnerId = request.GET.get('partnerId')
ipranges = IpRange.getByIp(ip)
if len(ipranges) <1:
return HttpResponse("")
partyId = ipranges[0].partyId.partyId
party = Party.objects.get(partyId=partyId)
subscription = Subscription.getActiveById(partyId, partnerId)
status = None
if len(subscription) > 0:
status = 'subscribed'
else:
status = 'not subscribed'
ret = {
'name': party.name,
'status': status,
}
return HttpResponse(json.dumps(ret), content_type="application/json")
开发者ID:tair,项目名称:api-python,代码行数:27,代码来源:views.py
示例13: clean_subkey
def clean_subkey(self):
subkey = self.cleaned_data["subkey"]
sub = Subscription.all().filter("subkey =", subkey).get()
if sub is None:
raise forms.ValidationError("You don't have a valid Seriesly Subscription Key")
self._subscription = sub
return subkey
开发者ID:AnaCm,项目名称:seriesly,代码行数:7,代码来源:forms.py
示例14: get_subscribed
def get_subscribed(self):
from subscription.models import Subscription
Subscription.subscribe_for_the_first_time(self, self)
Subscription.move_from_email_to_user(self)
try:
subscription = Subscription.objects.get(user=self)
except Subscription.DoesNotExist:
return False
if subscription.days_left > 0:
return True
return False
开发者ID:rokj,项目名称:sellout,代码行数:16,代码来源:models.py
示例15: subscriptions
def subscriptions(request):
now = datetime.datetime.now()
threshold = now - datetime.timedelta(days=30*3)
subcount = 0
for subscription in Subscription.all():
if subscription.last_visited is not None and subscription.last_visited > threshold:
subcount += 1
return HttpResponse("Done: \n%d" % subcount)
开发者ID:AnaCm,项目名称:seriesly,代码行数:8,代码来源:views.py
示例16: clean
def clean(self):
cleaned_data = self.cleaned_data
if cleaned_data["xmpp"] != "":
sub = Subscription.all().filter("xmpp =", cleaned_data["xmpp"]).filter("subkey !=", self._subscription.subkey).get()
if sub is not None:
self._errors["xmpp"] = forms.util.ErrorList(["This XMPP address already belongs to a subscription."])
del cleaned_data["xmpp"]
return cleaned_data
开发者ID:AnaCm,项目名称:seriesly,代码行数:8,代码来源:forms.py
示例17: json_public
def json_public(request, public_id):
subscription = Subscription.all().filter("public_id =", public_id).get()
if subscription is None:
raise Http404
response = _guide(request, subscription, template="widget.json",
public=True, extra_context=get_extra_json_context(request))
response["Content-Type"] = 'application/json'
return response
开发者ID:AnaCm,项目名称:seriesly,代码行数:8,代码来源:views.py
示例18: inscricao
def inscricao(request):
if request.method == 'POST':
form = SubscriptionForm(request.POST)
if form.is_valid():
subscription = Subscription()
subscription.nome = form.cleaned_data['nome']
subscription.cpf = form.cleaned_data['cpf']
subscription.email = form.cleaned_data['email']
subscription.fone = form.cleaned_data['fone']
subscription.save()
try:
send_mail(
subject = u'Inscrição no EventeX',
message = u'Obrigado por se inscrever no EventeX!',
from_email = '[email protected]',
recipient_list = [request.POST['email']],
)
except:
pass
return sucesso(request, subscription.pk)
# messages = (u'Inscrição realizada com sucesso;', u'Aguarde até que sua solicitação de cadastro seja aprovada')
# return render_to_response('index.html',{'messages':messages, 'subscription': subscription.pk}, context_instance=RequestContext(request))
else:
form = SubscriptionForm(initial={
'nome':'Entre com o seu nome',
'cpf':'Digite o seu CPF sem pontos',
'email': 'Informe o seu email',
'fone' : 'Qual seu telefone de contato?',
})
return render_to_response('subscription/subscription_form.html',{'form': form, 'title' : u'Preencha Sua Inscrição'}, context_instance=RequestContext(request))
开发者ID:iorgama,项目名称:eventex,代码行数:30,代码来源:views.py
示例19: feed
def feed(request, subkey, template):
subscription = Subscription.all().filter("subkey =", subkey).get()
if subscription is None:
raise Http404
body = _feed(request, subscription, template)
mimetype = "application/atom+xml"
if "rss" in template:
mimetype = "application/rss+xml"
return HttpResponse(body, mimetype=mimetype)
开发者ID:AnaCm,项目名称:seriesly,代码行数:9,代码来源:views.py
示例20: set_next_airtime
def set_next_airtime(request):
key = None
key = request.POST.get("key", None)
if key is None:
raise Http404
subscription = Subscription.get(key)
subscription.next_airtime = datetime.date(2010,1,1)
subscription.put()
return HttpResponse("Done: %s" % key)
开发者ID:AnaCm,项目名称:seriesly,代码行数:9,代码来源:views.py
注:本文中的subscription.models.Subscription类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论