本文整理汇总了Python中models.Subscription.put方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.put方法的具体用法?Python Subscription.put怎么用?Python Subscription.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Subscription
的用法示例。
在下文中一共展示了Subscription.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sub_command
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [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)
示例2: post
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [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')
示例3: get
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
def get(self):
public = Subscription(name='public',
level=0)
public.put()
subscription = Subscription(name='standard',
level=1)
subscription.put()
User(name='test',
password='test',
subscription=subscription.level).put()
Page(title='Home',
slug ='home',
text ='Lorem ipsum...',
allowed = subscription.level,
author = users.User('[email protected]')).put()
self.redirect('/')
示例4: subscribe_command
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
def subscribe_command(self, message=None):
subscriber_mail = self.user_mail(message.sender)
logging.info('subscribing user: %s' % subscriber_mail)
im_from = db.IM('xmpp', message.sender)
domain = RequestUtils.getDomain(message.arg)
if message.arg == 'all':
domain = 'all'
if not domain:
message.reply('You must provide valide domain for subscription. \'%s\' is not valid domain. Make sure that domain starts with http://' %message.arg)
return
existingSubscription = Subscription.gql('WHERE subscriber_mail = :1 and domain = :2 and active = True', subscriber_mail, domain).get()
if existingSubscription is not None:
message.reply('You have already subscribed for this domain %s. Remember?' % domain)
return
subscription = Subscription(subscriber = im_from, subscriber_mail = subscriber_mail, domain = domain, activationDate = datetime.datetime.now(), active = True, mute = False)
invite = IMInvite.gql('WHERE jid = :1 ', subscriber_mail)
subscription.put()
if invite:
invite.subscribed = True
invite.put()
message.reply('Subscription added.')
示例5: view_subscribe
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
def view_subscribe(request):
# login is required here
# if not ( request.user and request.user.is_authenticated() ):
# return HttpResponseRedirect()
if request.user.subscription_set.count() >= Subscription._MAX_SUBSCRIPTIONS_PER_USER:
Message(
user=request.user,
message=ugettext("You've reached maximum number of subscriptions. Delete some and try again."),
).put()
elif request.method == "GET":
search_form = AdvancedEventFilterForm(request.GET)
if search_form.is_valid():
country = Country.get_by_key_name(search_form.cleaned_data["country"])
region = Region.get_by_key_name(search_form.cleaned_data["region"])
free = search_form.cleaned_data["forfree"]
if search_form.cleaned_data["forwho"] == "custom":
event_types = 0
for t in search_form.cleaned_data["typelist"]:
event_types += 1 << int(t)
elif search_form.cleaned_data["forwho"] == "everyone":
event_types = Event.OPEN_EVENTS_MASK
else:
# assert(search_form.cleaned_data['forwho'] == 'members')
event_types = Event.MEMBERS_EVENTS_MASK
s = Subscription(user=request.user, country=country, region=region, event_types=event_types, free=free)
s.put()
Message(user=request.user, message=ugettext("Subscription created")).put()
return HttpResponseRedirect(
reverse("events.views.view_event_list", kwargs={"subscription_id": s.key().id()})
)
return HttpResponseRedirect(reverse("events.views.view_event_list"))
示例6: post
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [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()