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


Python Subscription.all方法代码示例

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


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

示例1: unsub_command

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
    def unsub_command(self, message=None):
        """Unsubscribe the user from a service"""
        user = message.sender.split('/')[0]

        plist = message.body.split(' ' )
        service_name = plist[1]

	if len(plist)>2:
	    type = "sms"
            user = plist[2]
	else:
	    type = "xmpp"
		
        service = Service.all().filter('name = ', service_name).get()

        if service:
            subscription = Subscription.all().filter('address =', user).filter('service = ', service).filter('type =', type).get()
            if subscription:
                subscription.delete()
		if type == "xmpp":
	            	mobile = Mobile.all().filter('subscription = ', subscription).get()
			if mobile:
				mobile.delete()
                message.reply("Unsubscribed %s from service %s" % (user, service.name))
            else:
                message.reply("user %s is not subscribed to service %s" % (user, service.name))
        else:
            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:31,代码来源:xmpp.py

示例2: get

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
 def get(self):
   user = users.get_current_user()
   checklist_q = Checklist.all().filter("user ==", user).filter("deleted ==", False).order("title");
   cursor = self.request.get('cursor_cl')
   if cursor:
     checklist_q = checklist_q.with_cursor(cursor)
   checklists = checklist_q.fetch(10)
   
   checklist_q = checklist_q.with_cursor(checklist_q.cursor())
   
   subs_by_cl = []
   for cl in checklists:
     subs = []
     for sub in cl.subscription_set:
       subs.append(sub)
     subs_by_cl.append(subs)
       
   subs_q = Subscription.all().filter("user ==", user).filter("deleted ==", False);
   cursor = self.request.get('cursor_sub')
   if cursor:
     subs_q = subs_q.with_cursor(cursor)
   subs = subs_q.fetch(10)
   
   subs_q = subs_q.with_cursor(subs_q.cursor())
   
   helpers.createResponse(self, 'dashboard_cls.html',
       {'checklists': checklists,
        'cursor_cl': checklist_q.cursor(),
        'subs_by_cl': subs_by_cl,
        'subs': subs,
        'cursor_sub': subs_q.cursor(),
        'more_subs': subs_q.count(1) == 1,
        'more_cls': checklist_q.count(1) == 1,
        })
开发者ID:yoooyle,项目名称:checklist,代码行数:36,代码来源:index.py

示例3: sub_command

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
    def sub_command(self, message=None):
        """Subscribe the user to XMPP or SMS"""
        user = message.sender.split('/')[0]
	
        plist = message.body.split(' ' )
 	service_name = plist[1]

	if len(plist)>2:
	    type = "sms"
            user = plist[2]
	else:
	    type = "xmpp"
		
        service = Service.all().filter('name = ', service_name).get()

        if service:
            subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
            if subscription:
                message.reply("user %s is already subscribed to service %s" % (user, service.name))
            else:
                subscription = Subscription(key_name=hashlib.sha1(user).hexdigest(), type=type, address=user, service=service)
                subscription.put()
                message.reply("Subscribed %s to service %s" % (user, service.name))
        else:
            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:28,代码来源:xmpp.py

示例4: unsms_command

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
    def unsms_command(self, message=None):
        """Unsubscribe the user from a service"""
	plist = message.body.split(' ')
	if len(plist)==2:
	        user = message.sender.split('/')[0]
	
	        service_name = plist[1]
	
	        service = Service.all().filter('name = ', service_name).get()
	
	        if service:
		    subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
		
		    if subscription:
	            	mobile = Mobile.all().filter('subscription = ', subscription).get()
	            	if mobile:
		    	    message.reply("Unsubscribed user %s from backup mobile %s for service %s" % (user, mobile.number,service_name))
	            	    mobile.delete()
			else:
			    message.reply("No backup mobile for user %s on %s service" % (user,service_name))
	 	    else:
	            	message.reply("User %s is not subscribed to service %s" % (user, service.name))
	        else:
	            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
	else:
		 message.reply("Usege: unsms SERVICE +6112345678")
开发者ID:feczo,项目名称:splashmon,代码行数:29,代码来源:xmpp.py

示例5: sms_command

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
    def sms_command(self, message=None):
        """Subscribe the user to a offline SMS"""

        plist = message.body.split(' ')
	if len(plist)==3:
	        user = message.sender.split('/')[0]
	 	service_name = plist[1]
	 	number = plist[2]
	
	        service = Service.all().filter('name = ', service_name).get()
	
	        if service:
		 	subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
		
		        if subscription:
		            mobile = Mobile.all().filter('number =', number).get()
		            if mobile:
		                message.reply("user %s is already registered backup mobile %s for service %s" % (user, mobile.number,service_name))
		            else:
		                mobile = Mobile(number=number, subscription = subscription)
		                mobile.put()
		                message.reply("Subscribed user %s to backup mobile %s for service %s" % (user, number,service_name))
		        else:
		            message.reply("Sorry, I couldn't find a subscription on %s for %s" % (service_name,user))
	        else:
	            message.reply("Sorry, I couldn't find a service called "
	                          "%s" % service_name)
	else:
		message.reply("Usage: sms SERVICE +61412345678")
开发者ID:feczo,项目名称:splashmon,代码行数:31,代码来源:xmpp.py

示例6: get

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
  def get(self, **args):
    cl = Checklist.get(Key.from_path("Checklist", long(args['id'])))
    
    if not cl or cl.deleted: 
      helpers.createResponse(self, 'message_not_exist.html')
      return
    
    if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False): return
    
    item_q = cl.item_set.filter("deleted ==", False).order("creation_time")
    cursor = self.request.get('cursor')
    if cursor:
      item_q = item_q.with_cursor(cursor)
    items = item_q.fetch(20)

    user = users.get_current_user()
    subscribed = False
    for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False):
      if sub.source.key() == cl.key():
        subscribed = True
        break
   
    helpers.createResponse(self, 'dashboard_subscribe.html', 
        {'items': items,
        'cl': cl,
        'cursor_item': item_q.cursor(),
        'subscribed': subscribed,
        },
                           )   
开发者ID:yoooyle,项目名称:checklist,代码行数:31,代码来源:subscribe.py

示例7: post

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
  def post(self):
    cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id'))))
    if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False):
      return
    
    user = users.get_current_user()
    
    for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False):
      if sub.source.key() == cl.key():
        helpers.createResponse(self, 'message_already_subscribed.html', 
          {'old_checklist': cl})
        
    sub = Subscription(
        user=user,
        source=cl,
        deleted=False,                       
                       )        

    sub.put()

    for item in cl.item_set:
      subItem = SubscribedItem(
          subscription=sub,
          original=item,
          finished=False,
          deleted=False,                               
                               )
      subItem.put()
    
    helpers.createResponse(self, 'message_subscribed.html')
开发者ID:yoooyle,项目名称:checklist,代码行数:32,代码来源:create.py

示例8: post

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import all [as 别名]
  def post(self):
    cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id'))))
    subscribe = self.request.get('subscribe')
    if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False):
      return
    
    user = users.get_current_user()
    if subscribe == 'false':
      for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False):
        if sub.source.key() == cl.key():
          for subItem in sub.subscribeditem_set:
            subItem.delete()
          sub.delete()
      cl.subscribers = cl.subscribers - 1
      self.response.write("unsubscribed")
    else:
      sub = Subscription(
          user=user,
          source=cl,
          deleted=False,                       
                       )        

      sub.put()

      for item in cl.item_set.filter("deleted ==", False):
        subItem = SubscribedItem(
            subscription=sub,
            original=item,
            finished=False,
            deleted=False,                               
                               )
        subItem.put()

      cl.subscribers = cl.subscribers + 1
      self.response.write("subscribed")
      
    cl.put()
开发者ID:yoooyle,项目名称:checklist,代码行数:39,代码来源:subscribe.py


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