本文整理汇总了Python中subscription.models.Subscription.getActiveById方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.getActiveById方法的具体用法?Python Subscription.getActiveById怎么用?Python Subscription.getActiveById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscription.models.Subscription
的用法示例。
在下文中一共展示了Subscription.getActiveById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import getActiveById [as 别名]
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")
示例2: get
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import getActiveById [as 别名]
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")
示例3: hasActiveSubscription
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import getActiveById [as 别名]
def hasActiveSubscription(ip, partyId, partnerId):
if partyId and partyId.isdigit() and len(Subscription.getActiveById(partyId, partnerId)) > 0:
return True
if ip and len(Subscription.getActiveByIp(ip, partnerId)) > 0:
return True
return False