def notify_favorited(self, question): if self.user != question.user: Notification( notification_type=Notification.FAVORITED, from_user=self.user, to_user=question.user, question=question ).save()
def notify_commented(self, feed): if self.user != feed.user: Notification( notification_type=Notification.COMMENTED, from_user=self.user, to_user=feed.user, feed=feed ).save()
def notifyRespondedIndirect(self, profile, feed): if self.user != profile.user: Notification( notification_type=Notification.RESPOND_INDIRECT, from_user=self.user, to_user=profile.user, profile=profile, feed=feed, ).save()
def notifyChallenged(self, profile, feed): if self.user != profile.user: Notification( notification_type=Notification.CHALLENGED, from_user=self.user, to_user=profile.user, profile=profile, feed=feed, ).save()
def notify_wrote_on_profile(self, profile, feed): if self.user != profile.user: Notification( notification_type=Notification.WROTE_ON_PROFILE, from_user=self.user, to_user=profile.user, profile=profile, feed=feed, ).save()
def notify_also_answered(self, question): answers = question.get_answers() users = [] for answer in answers: if answer.user != self.user and answer.user != question.user: users.append(answer.user.pk) users = list(set(users)) for user in users: Notification(notification_type=Notification.ALSO_ANSWERED, from_user=self.user, to_user=User(id=user), question=question).save()
def also_article_commented(self, article): comments = article.get_comments() users = [] for comment in comments: if comment.user != self.user and comment.user != article.create_user: users.append(article.create_user.pk) users = list(set(users)) for user in users: Notification(notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), article=article).save()
def notify_also_commented(self, feed): comments = feed.get_comments() users = [] for comment in comments: if comment.user != self.user and comment.user != feed.user: users.append(comment.user.pk) users = list(set(users)) for user in users: Notification(notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), feed=feed).save()
def comment(request, article_id): if request.method == 'POST': article = Article.objects.get(pk=int(article_id)) comment = request.POST.get('comment') comment = comment.strip() if len(comment) > 0: article_comment = ArticleComment(user=request.user, article=article, comment=comment) article_comment.save() comm = Notification(notification_type=Notification.COMMENTED, article=article, from_user=request.user, to_user=article.get_author()) comm.save() else: message = '你填入的信息错误' return HttpResponseRedirect('/article/%d' % int(article_id))
def view_note(request): med_det = request.user.profile.get_avail_med() for med in med_det: if(med['mcount']<10): Notification(notification_type=Notification.STOCK_LOW, from_user=request.user.profile, to_user=request.user.profile, medicine = Medicine.objects.get(pk=med['medicine'])).save() trans = Notification.objects.filter(to_user=request.user.profile) querystring = '' if 'q' in request.GET: querystring = request.GET.get('q').strip() trans = trans.filter(from_user__name__icontains=querystring) paginator = Paginator(trans, 10) page = request.GET.get('page') try: trans = paginator.page(page) except PageNotAnInteger: trans = paginator.page(1) except EmptyPage: trans = paginator.page(paginator.num_pages) return render(request, 'usershop/view_note.html', {'trans': trans, 'querystring': querystring})
def notify_liked_profile(self, profile): if self.user != profile.user: Notification(notification_type=Notification.LIKED_PROFILE, from_user=self.user, to_user=profile.user, profile=profile).save()
def notify_image_liked(self, image): if self.user != image.user: Notification(notification_type=Notification.IMAGE_LIKED, from_user=self.user, to_user=image.user, image=image).save()
def notify_liked(self, article):#创建通知 if self.user!=article.notes.user: Notification(notification_type=Notification.LIKED,from_user=self.user,to_user=article.notes.user,article=article).save()
def notify_review_liked(self, review): if self.user != review.user: Notification(notification_type=Notification.REVIEW_LIKED, from_user=self.user, to_user=review.user, review=review).save()
def notify_commented(self, post): if self.user != post.user: Notification(notification_type=Notification.COMMENTED, from_user=self.user, to_user=post.user, post=post).save()
def notify_article_commented(self, article): if self.user != article.create_user: Notification(notification_type=Notification.COMMENTED, from_user=self.user, to_user=article.create_user, article=article).save()
def notify_accepted(self, answer): if self.user != answer.user: Notification(notification_type=Notification.ACCEPTED_ANSWER, from_user=self.user, to_user=answer.user, answer=answer).save()
def notify_image_commented(self, image): if self.user != image.user: Notification(notification_type=Notification.IMAGE_COMMENTED, from_user=self.user, to_user=image.user, image=image).save()
def notify_liked(self, post): if self.user != post.user: Notification(notification_type=Notification.LIKED, from_user=self.user, to_user=post.user, post=post).save()
def notify_liked(self, feed): if self.user != feed.user: Notification(notification_type=Notification.LIKED, from_user=self.user, to_user=feed.user, feed=feed).save()
def notify_followed(self, user): if self.user != user: Notification(notification_type=Notification.FOLLOWED, from_user=self.user, to_user=user, user=user).save()
def notify_answered(self, question): if self.user != question.user: Notification(notification_type=Notification.ANSWERED, from_user=self.user, to_user=question.user, question=question).save()
def notify_booked(self, vehicle): if self.user != vehicle.user: Notification(notification_type=Notification.BOOKED, from_user=self.user, to_user=vehicle.user, vehicle=vehicle).save()