def delete_comment(request, comment_id): comment = get_object_or_404(comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID) if request.user == comment.user: perform_delete(request, comment) comment.content_object.after_del_comments() messages.success(request, _("Comment deleted success")) else: messages.error(request, _("You can't delete this comment")) # Flag the comment as deleted instead of actually deleting it. return redirect(get_redir_url(request))
def change_username(request, template_name="manage/admin_change_username.html"): """change user name once""" form = ChangeUsernameForm() now = datetime.datetime.now() #last_time = now + datetime.timedelta(seconds = -CHANGE_USERNAME_TIMEDELTA) #change_list = ChangeUsername.objects.filter(user=request.user.id, #edittime__gt=last_time,edittime__lte=now).order_by('-edittime') if has_change(request.user): messages.success(request, _(" 只能修改一次")) else: if request.method == "POST": form = ChangeUsernameForm(request.POST) if form.is_valid(): form.save(request.user) messages.success(request, _(" Username was changed successfuly")) return redirect(get_redir_url(request)) #else: #form = ChangeUsernameForm() return render(request, template_name, {'form': form})