本文整理汇总了Python中models.Notification类的典型用法代码示例。如果您正苦于以下问题:Python Notification类的具体用法?Python Notification怎么用?Python Notification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notification类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: NotificationTestCase
class NotificationTestCase(CoreTestCase):
def setUp(self):
super(NotificationTestCase, self).setUp()
self._create()
def _create(self):
self.subject = random_string(25)
self.message = random_string(35)
self.notification = Notification(
user=self.user,
subject=self.subject,
message=self.message
)
self.notification.save()
def test_can_list(self):
response = self.client.get(reverse_lazy('notification.list'))
self.assertEqual(response.status_code, 200)
count = Notification.objects.filter(user=self.user).count()
self.assertEqual(len(response.context['object_list']), count)
def test_can_show_detail(self):
self._create()
url = reverse_lazy('notification.detail', args=[self.notification.id])
response = self.client.get(url)
self.assertEqual(response.context['object'].subject, self.notification.subject)
self.assertEqual(response.context['object'].read, True)
开发者ID:CYJ,项目名称:mazu,代码行数:29,代码来源:tests.py
示例2: setUpTestData
def setUpTestData(cls):
admin = User.objects.get(pk=1)
group_foo = User.objects.filter(groups__name='group_foo')
staff = User.objects.get_by_natural_key('staff')
cls.admin_user = admin
cls.n2_admin = Notification.send(
[admin],
'test notification to admin',
'fa-info',
Notification.COLOR_DANGER,
url='http://www.google.com/'
)
cls.n2_staff = Notification.send(
[staff],
'test notifications to staff',
'fa-bell',
Notification.COLOR_DANGER,
)
cls.n2_group_foo = Notification.send(
group_foo,
'test notifications to client',
'fa-bell',
Notification.COLOR_WARNING,
''
)
开发者ID:alireza-molaee,项目名称:django-webline-notifications,代码行数:25,代码来源:tests.py
示例3: post
def post(self, post_id):
session = get_current_session()
if session.has_key('user'):
message = helper.sanitizeHtml(self.request.get('message'))
user = session['user']
key = self.request.get('comment_key')
if len(message) > 0 and key == keys.comment_key:
try:
post = Post.all().filter('nice_url =', helper.parse_post_id( post_id ) ).get()
if post == None: #If for some reason the post doesn't have a nice url, we try the id. This is also the case of all old stories
post = db.get( helper.parse_post_id( post_id ) )
post.remove_from_memcache()
comment = Comment(message=message,user=user,post=post)
comment.put()
helper.killmetrics("Comment","Root", "posted", session, "",self)
vote = Vote(user=user, comment=comment, target_user=user)
vote.put()
Notification.create_notification_for_comment_and_user(comment,post.user)
self.redirect('/noticia/' + post_id)
except db.BadKeyError:
self.redirect('/')
else:
self.redirect('/noticia/' + post_id)
else:
self.redirect('/login')
开发者ID:grillermo,项目名称:Noticias-HAcker,代码行数:26,代码来源:PostHandler.py
示例4: push_user_notification
def push_user_notification(self, event_uuid, team_id, user_id):
''' Push to one user '''
if team_id in self.notify_connections and user_id in self.notify_connections[team_id]:
json = Notification.by_event_uuid(event_uuid).to_json()
for wsocket in self.notify_connections[team_id][user_id]:
wsocket.write_message(json)
Notification.delivered(wsocket.user_id, event_uuid)
开发者ID:mach327,项目名称:RootTheBox,代码行数:7,代码来源:EventManager.py
示例5: notify_user
def notify_user( notification_type, user=None, follower=None, photo=None):
notification = Notification(notification_type=notification_type, user=follower, photo=photo)
notification.save()
user_notification = UserNotifications.objects.get(user=user)
user_notification.notifications.add(notification)
user_notification.save()
return
开发者ID:exeperience,项目名称:photowalkrs,代码行数:7,代码来源:functions.py
示例6: post
def post(self, request):
data = request.POST
timestamp = timezone.now()
if 'oid' in data and data['oid'] and validate_oid(data['oid']):
OID = data['oid']
else:
return HttpResponseBadRequest('Error: No valid OID provided')
if 'iped' in data and data['iped'] and get_school(data['iped']):
school = get_school(data['iped'])
if not school.contact:
errmsg = "Error: School has no contact."
return HttpResponseBadRequest(errmsg)
if Notification.objects.filter(institution=school, oid=OID):
errmsg = "Error: OfferID has already generated a notification."
return HttpResponseBadRequest(errmsg)
notification = Notification(institution=school,
oid=OID,
timestamp=timestamp,
errors=data['errors'][:255])
notification.save()
msg = notification.notify_school()
callback = json.dumps({'result':
'Verification recorded; {0}'.format(msg)})
response = HttpResponse(callback)
return response
else:
errmsg = ("Error: No school found")
return HttpResponseBadRequest(errmsg)
开发者ID:cfpb,项目名称:college-costs,代码行数:28,代码来源:views.py
示例7: post
def post(self, request, *args, **kwargs):
user_id = kwargs['user_id']
sender = request.user.customuser
user = CustomUser.objects.get(pk=user_id)
if user == sender:
raise HttpResponseForbidden("Can't add itself.")
user_friends = user.friends.all()
sender_notifications = sender.notification.all()
if sender not in user_friends:
# make notification only when adding first
n = Notification(user=user, source=sender)
n.save()
else:
# delete already generated notification for sender
m = ""
for notif in sender_notifications:
if notif.source == user:
m = notif
if not m == "":
m.delete()
sender.friends.add(user)
sender.save()
c = user_context(user, sender)
return render(request, self.template_name, c)
开发者ID:darxsys,项目名称:PUS,代码行数:27,代码来源:views.py
示例8: push_team_notification
def push_team_notification(self, event_uuid, team_id):
''' Push to one team '''
json = Notification.by_event_uuid(event_uuid).to_json()
if team_id in self.notify_connections:
for user_id in self.notify_connections[team_id].keys():
for wsocket in self.notify_connections[team_id][user_id]:
wsocket.write_message(json)
Notification.delivered(wsocket.user_id, event_uuid)
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:8,代码来源:EventManager.py
示例9: send_notification
def send_notification():
form = SendNotificationForm()
if form.validate_on_submit():
noti = Notification()
noti.content = form.notification.data
db.session.add(noti)
db.session.commit()
return redirect(url_for('notify.send_notification'))
开发者ID:berc-web,项目名称:berc_web,代码行数:9,代码来源:__init__.py
示例10: create_notification
def create_notification(text, entity, acting_user=None, recipient = None):
try:
notification = Notification(text = text, entity = entity, acting_user = acting_user, recipient=recipient)
notification.save()
return HttpResponse(_('Notification create successfully'))
except:
resp = HttpResponse(str(sys.exc_info()[1]))
resp.status_code = 500
return resp
开发者ID:dibaunaumh,项目名称:Ecclesia,代码行数:9,代码来源:services.py
示例11: post
def post(self):
notification = Notification(
item_cl = Model.get(Key(self.request.get('key'))),
message = self.request.get('message'),
user = users.User(self.request.get('email')),
is_cl = ("True" == self.request.get('is_cl')),
time = datetime.now(),
read = False)
notification.put()
开发者ID:yoooyle,项目名称:checklist,代码行数:9,代码来源:notify.py
示例12: notification
def notification(request):
"""
View responsible for receiving a notification from PagSeguro and make a
query to update the Payment.
"""
incoming_notification = Notification(code=request.POST["notificationCode"])
incoming_notification.save()
start_new_thread(incoming_notification.check, tuple())
return HttpResponse("OK", mimetype="text/plain")
开发者ID:tulioncds,项目名称:med-alliance,代码行数:9,代码来源:views.py
示例13: push_broadcast_notification
def push_broadcast_notification(self, event_uuid):
''' Push to everyone '''
json = Notification.by_event_uuid(event_uuid).to_json()
for team_id in self.notify_connections.keys():
for user_id in self.notify_connections[team_id].keys():
for wsocket in self.notify_connections[team_id][user_id]:
wsocket.write_message(json)
if wsocket.user_id != '$public_user':
Notification.delivered(user_id, event_uuid)
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:9,代码来源:EventManager.py
示例14: test_send_notification_to_group
def test_send_notification_to_group(self):
"""
Tests that notification is sent to group.
"""
group=Group.objects.get(name="test_group")
notification = Notification(text="There is a new story in discussion", \
group=group)
notification.save()
# Test that one message has been sent.
self.assertEquals(len(mail.outbox), len([user for user in User.objects.all() if group in user.groups.all()]))
开发者ID:dibaunaumh,项目名称:Ecclesia,代码行数:10,代码来源:tests.py
示例15: push_broadcast_notification
def push_broadcast_notification(self, event_uuid):
""" Push to everyone """
json = Notification.by_event_uuid(event_uuid).to_json()
for team_id in self.notify_connections:
for user_id in self.notify_connections[team_id]:
for wsocket in self.notify_connections[team_id][user_id]:
wsocket.write_message(json)
# Only mark delivered for non-public users
if wsocket.user_id != "$public_user":
Notification.delivered(user_id, event_uuid)
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:10,代码来源:EventManager.py
示例16: test_send_notification_to_user
def test_send_notification_to_user(self):
"""
Tests that notification is sent to user.
"""
notification = Notification(text="There is a new story in discussion", \
recipient = User.objects.get(username="test_user"), \
group = Group.objects.get(name="test_group"))
notification.save()
# Test that one message has been sent.
self.assertEquals(len(mail.outbox), 1)
开发者ID:dibaunaumh,项目名称:Ecclesia,代码行数:10,代码来源:tests.py
示例17: alert
def alert(users, notify_type, subject, url):
'''Assesses whether or not a user's settings allow a notification, and creates a "smart link"
notification if allowed
'''
users_permitting = (user for user in users if notify_type in user.notify_permissions)
for user in users_permitting:
n = Notification(recip=user, subject=subject, _url=url)
n.save()
开发者ID:abshkd,项目名称:benzene,代码行数:10,代码来源:signals.py
示例18: notificate_registry
def notificate_registry(new_user):
users = User.objects.filter(is_superuser=True)
for user in users:
notification = Notification(
user=user,
message="El cliente "+new_user.first_name+" "+new_user.last_name+" se ha registrado en la plataforma.",
short="Nuevo registro",
icon="fa fa-user"
)
notification.save()
开发者ID:HanabiDev,项目名称:Ursus,代码行数:11,代码来源:views.py
示例19: newNotification
def newNotification(values):
try:
print values
auxNotification = Notification(to=values["to"], _from=values["from"], send_date=values["send_date"], \
activity=values["activity"], message=values["message"], title=values["title"])
auxNotification.save()
return True
except DatabaseError as e:
return False
except IntegrityError as e:
return False
开发者ID:zykorwx,项目名称:filper_notifications,代码行数:11,代码来源:notificationsHelper.py
示例20: get_approval_notice
def get_approval_notice(self):
notice = Notification(
channel=self,
target=self.target,
text="%s wants to send you notifications. Click here to approve/deny this request."
% self.source.source_name,
)
notice.title = "New Notification Source"
notice.link = "http://%s/sources" % WWW_HOST
notice.icon = self.source.source_icon
notice.sticky = "true"
return notice
开发者ID:Mondego,项目名称:pyreco,代码行数:12,代码来源:allPythonContent.py
注:本文中的models.Notification类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论