Exemple #1
0
 def add(request, post_id):
     if request.method == 'POST':
         post = Post.objects.get(id=post_id)
         account = Account.get_by_user(request.user)
         post.add_link(account)
         Notification.add(post.publisher, account, NotificationType.ADD, post)
     redirect_path = request.GET['next']
     return redirect(redirect_path)
Exemple #2
0
 def follow(request, username):
     if request.method == 'POST':
         relationship = Relationship()
         relationship.owner = Account.get_by_user(request.user)
         relationship.follow = Account.get_by_username(username)
         if not relationship.owner.is_following(relationship.follow):
             relationship.save()
             Notification.add(relationship.follow, relationship.owner,
                              NotificationType.FOLLOW)
         return redirect('profile', username)
Exemple #3
0
 def react(request, post_id):
     if request.method == 'POST':
         reaction = Reaction()
         reaction.post = Post.objects.get(id=post_id)
         reaction.owner = Account.get_by_user(request.user)
         reaction.save()
         Notification.add(reaction.post.owner, reaction.owner,
                          NotificationType.REACT, reaction.post)
     redirect_path = request.GET['next']
     return redirect(redirect_path)
Exemple #4
0
 def comment(request, post_id):
     if request.method == 'POST':
         form = CommentForm(request.POST)
         if form.is_valid():
             comment = form.save(commit=False)
             comment.post = Post.objects.get(id=post_id)
             comment.owner = Account.get_by_user(request.user)
             comment.save()
             Notification.add(comment.post.owner, comment.owner,
                              NotificationType.COMMENT, comment.post)
     redirect_path = request.GET['next']
     return redirect(redirect_path)