Пример #1
0
def follow(request, user_pk):
	user = get_object_or_404(User, pk=user_pk)

	if Follow.objects.filter(user=request.user, target=user).count() != 0:
		return json_view(error=(1, "You are following this user."))

	Follow(user=request.user, target=user).save()
	url = reverse("kiqlist.users.views.friends") + "#followers"
	send_notification(user, "%s %s is now following you." % (request.user.first_name, request.user.last_name), url)
	return json_view()
Пример #2
0
	def success(form):
		goalcomment = form.save(commit=False)
		goalcomment.goal = goal
		goalcomment.user = request.user
		goalcomment.save()

		if goalcomment.user != goal.user:
			send_notification(
				goal.user,
				"%s %s commented on your goal \"%s\"." % (request.user.first_name, request.user.last_name, goal.title),
				"#goal/" + str(goal.pk) + "/view")

		return goalcomment
Пример #3
0
def add_private_message(request):
	if request.method == "POST":
		form = PrivateMessageForm(request.POST)
		if form.is_valid():
			private_message = form.save(commit=False)
			private_message.from_user = request.user
			private_message.save()

			send_notification(private_message.to_user,
							  "%s %s sent you a message \"%s\"." % (request.user.first_name,
																  request.user.last_name,
																  truncatechars(private_message.content, 50)),
							  "#pm/conversation/" + str(request.user.pk))

			return redirect("kiqlist.private_messages.views.conversation", private_message.to_user.pk)

	return redirect("private_messages.views.index")