We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Отображение моих комментариев в личном кабинете
Хочу иметь возможность видеть всё, что я написал под своими и чужими постами, сейчас невозможно понять, что и где я писал, это не очень удобно.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `users/views.py`
Content:
```
1 from django.http import Http404
2 from django.shortcuts import render, redirect, get_object_or_404
3 from django_q.tasks import async_task
4 
5 from auth.helpers import auth_required, moderator_role_required
6 from common.pagination import paginate
7 from common.request import ajax_request
8 from notifications.telegram.users import notify_profile_needs_review
9 from posts.models import Post
10 from search.models import SearchIndex
11 from users.admin import do_user_admin_actions
12 from users.forms.admin import UserAdminForm
13 from users.forms.intro import UserIntroForm
14 from users.forms.profile import UserEditForm, ExpertiseForm
15 from users.models import User, UserBadge, UserExpertise, UserTag, Tag
16 
17 
18 @auth_required
19 def intro(request):
20     if request.me.is_profile_complete \
21             and request.me.is_profile_reviewed \
22             and not request.me.is_profile_rejected:
23         return redirect("profile", request.me.slug)
24 
25     if request.method == "POST":
26         form = UserIntroForm(request.POST, request.FILES, instance=request.me)
27         if form.is_valid():
28             user = form.save(commit=False)
29 
30             # send to moderation
31             user.is_profile_complete = True
32             user.is_profile_reviewed = False
33             user.is_profile_rejected = False
34             user.save()
35 
36             # create intro post
37             intro_post = Post.upsert_user_intro(user, form.cleaned_data["intro"], is_visible=False)
38 
39             # notify moderators to review profile
40             async_task(notify_profile_needs_review, user, intro_post)
41 
42             return redirect("on_review")
43     else:
44         existing_intro = Post.get_user_intro(request.me)
45         form = UserIntroForm(
46             instance=request.me,
47             initial={"intro": existing_intro.text if existing_intro else ""},
48         )
49 
50     return render(request, "users/intro.html", {"form": form})
51 
52 
53 @auth_required
54 def profile(request, user_slug):
55     user = get_object_or_404(User, slug=user_slug)
56 
57     if not request.me.is_moderator:
58         # hide unverified users
59         if not user.is_profile_complete or not user.is_profile_complete or user.is_profile_rejected:
60             raise Http404()
61 
62     if user.id == request.me.id:
63         goto = request.GET.get("goto")
64         if goto:
65             return redirect(goto)
66 
67     tags = Tag.objects.filter(is_visible=True).all()
68 
69     intro = Post.get_user_intro(user)
70     projects = Post.objects.filter(author=user, type=Post.TYPE_PROJECT).all()
71     active_tags = {t.tag_id for t in UserTag.objects.filter(user=user).all()}
72     achievements = UserBadge.objects.filter(user=user)[:8]
73     expertises = UserExpertise.objects.filter(user=user).all()
74     posts = Post.objects_for_user(request.me)\
75         .filter(author=user, is_visible=True)\
76         .exclude(type__in=[Post.TYPE_INTRO, Post.TYPE_PROJECT])
77 
78     return render(request, "users/profile.html", {
79         "user": user,
80         "intro": intro,
81         "projects": projects,
82         "tags": tags,
83         "active_tags": active_tags,
84         "achievements": achievements,
85         "expertises": expertises,
86         "posts": paginate(request, posts),
87     })
88 
89 
90 @auth_required
91 def edit_profile(request, user_slug):
92     user = get_object_or_404(User, slug=user_slug)
93     if user.id != request.me.id and not request.me.is_moderator:
94         raise Http404()
95 
96     if request.method == "POST":
97         form = UserEditForm(request.POST, request.FILES, instance=user)
98         if form.is_valid():
99             user = form.save(commit=False)
100             user.save()
101 
102             SearchIndex.update_user_index(user)
103 
104             return redirect("profile", user.slug)
105     else:
106         form = UserEditForm(instance=user)
107 
108     return render(request, "users/edit.html", {"form": form})
109 
110 
111 @auth_required
112 @moderator_role_required
113 def admin_profile(request, user_slug):
114     user = get_object_or_404(User, slug=user_slug)
115 
116     if request.method == "POST":
117         form = UserAdminForm(request.POST, request.FILES)
118         if form.is_valid():
119             return do_user_admin_actions(request, user, form.cleaned_data)
120     else:
121         form = UserAdminForm()
122 
123     return render(request, "users/admin.html", {"user": user, "form": form})
124 
125 
126 @auth_required
127 @ajax_request
128 def toggle_tag(request, tag_code):
129     if request.method != "POST":
130         raise Http404()
131 
132     tag = get_object_or_404(Tag, code=tag_code)
133 
134     user_tag, is_created = UserTag.objects.get_or_create(
135         user=request.me,
136         tag=tag,
137         defaults=dict(
138             name=tag.name
139         )
140     )
141 
142     if not is_created:
143         user_tag.delete()
144 
145     return {
146         "status": "created" if is_created else "deleted",
147         "tag": {"code": tag.code, "name": tag.name, "color": tag.color},
148     }
149 
150 
151 @auth_required
152 @ajax_request
153 def add_expertise(request):
154     if request.method == "POST":
155         form = ExpertiseForm(request.POST)
156         if form.is_valid():
157             user_expertise = form.save(commit=False)
158             user_expertise.user = request.me
159             UserExpertise.objects.filter(user=request.me, expertise=user_expertise.expertise).delete()
160             user_expertise.save()
161             return {
162                 "status": "created",
163                 "expertise": {
164                     "name": user_expertise.name,
165                     "expertise": user_expertise.expertise,
166                     "value": user_expertise.value,
167                 },
168             }
169 
170     return {"status": "tipidor"}
171 
172 
173 @auth_required
174 @ajax_request
175 def delete_expertise(request, expertise):
176     if request.method == "POST":
177         UserExpertise.objects.filter(user=request.me, expertise=expertise).delete()
178         return {
179             "status": "deleted",
180             "expertise": {
181                 "expertise": expertise,
182             },
183         }
184 
185     return {"status": "tipidor"}
186 
187 
188 @auth_required
189 def on_review(request):
190     if request.me.is_profile_reviewed:
191         return redirect("profile", request.me.slug)
192     return render(request, "users/messages/on_review.html")
193 
194 
195 @auth_required
196 def rejected(request):
197     return render(request, "users/messages/rejected.html")
198 
199 
200 @auth_required
201 def banned(request):
202     return render(request, "users/messages/banned.html")
203
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/users/views.py b/users/views.py
--- a/users/views.py
+++ b/users/views.py
@@ -7,6 +7,7 @@
 from common.request import ajax_request
 from notifications.telegram.users import notify_profile_needs_review
 from posts.models import Post
+from comments.models import Comment
 from search.models import SearchIndex
 from users.admin import do_user_admin_actions
 from users.forms.admin import UserAdminForm
@@ -17,9 +18,11 @@
 
 @auth_required
 def intro(request):
-    if request.me.is_profile_complete \
-            and request.me.is_profile_reviewed \
-            and not request.me.is_profile_rejected:
+    if (
+        request.me.is_profile_complete
+        and request.me.is_profile_reviewed
+        and not request.me.is_profile_rejected
+    ):
         return redirect("profile", request.me.slug)
 
     if request.method == "POST":
@@ -34,7 +37,9 @@
             user.save()
 
             # create intro post
-            intro_post = Post.upsert_user_intro(user, form.cleaned_data["intro"], is_visible=False)
+            intro_post = Post.upsert_user_intro(
+                user, form.cleaned_data["intro"], is_visible=False
+            )
 
             # notify moderators to review profile
             async_task(notify_profile_needs_review, user, intro_post)
@@ -71,6 +76,7 @@
     active_tags = {t.tag_id for t in UserTag.objects.filter(user=user).all()}
     achievements = UserBadge.objects.filter(user=user)[:8]
     expertises = UserExpertise.objects.filter(user=user).all()
+    comments = Comment.visible_objects().filter(author=user).order_by("-created_at")[:5]
     posts = Post.objects_for_user(request.me)\
         .filter(author=user, is_visible=True)\
         .exclude(type__in=[Post.TYPE_INTRO, Post.TYPE_PROJECT])
@@ -83,6 +89,7 @@
         "active_tags": active_tags,
         "achievements": achievements,
         "expertises": expertises,
+        "comments": comments,
         "posts": paginate(request, posts),
     })
 
@@ -132,11 +139,7 @@
     tag = get_object_or_404(Tag, code=tag_code)
 
     user_tag, is_created = UserTag.objects.get_or_create(
-        user=request.me,
-        tag=tag,
-        defaults=dict(
-            name=tag.name
-        )
+        user=request.me, tag=tag, defaults=dict(name=tag.name)
     )
 
     if not is_created:
@@ -156,7 +159,9 @@
         if form.is_valid():
             user_expertise = form.save(commit=False)
             user_expertise.user = request.me
-            UserExpertise.objects.filter(user=request.me, expertise=user_expertise.expertise).delete()
+            UserExpertise.objects.filter(
+                user=request.me, expertise=user_expertise.expertise
+            ).delete()
             user_expertise.save()
             return {
                 "status": "created",
@@ -177,9 +182,7 @@
         UserExpertise.objects.filter(user=request.me, expertise=expertise).delete()
         return {
             "status": "deleted",
-            "expertise": {
-                "expertise": expertise,
-            },
+            "expertise": {"expertise": expertise,},
         }
 
     return {"status": "tipidor"}

{"golden_diff": "diff --git a/users/views.py b/users/views.py\n--- a/users/views.py\n+++ b/users/views.py\n@@ -7,6 +7,7 @@\n from common.request import ajax_request\n from notifications.telegram.users import notify_profile_needs_review\n from posts.models import Post\n+from comments.models import Comment\n from search.models import SearchIndex\n from users.admin import do_user_admin_actions\n from users.forms.admin import UserAdminForm\n@@ -17,9 +18,11 @@\n \n @auth_required\n def intro(request):\n-    if request.me.is_profile_complete \\\n-            and request.me.is_profile_reviewed \\\n-            and not request.me.is_profile_rejected:\n+    if (\n+        request.me.is_profile_complete\n+        and request.me.is_profile_reviewed\n+        and not request.me.is_profile_rejected\n+    ):\n         return redirect(\"profile\", request.me.slug)\n \n     if request.method == \"POST\":\n@@ -34,7 +37,9 @@\n             user.save()\n \n             # create intro post\n-            intro_post = Post.upsert_user_intro(user, form.cleaned_data[\"intro\"], is_visible=False)\n+            intro_post = Post.upsert_user_intro(\n+                user, form.cleaned_data[\"intro\"], is_visible=False\n+            )\n \n             # notify moderators to review profile\n             async_task(notify_profile_needs_review, user, intro_post)\n@@ -71,6 +76,7 @@\n     active_tags = {t.tag_id for t in UserTag.objects.filter(user=user).all()}\n     achievements = UserBadge.objects.filter(user=user)[:8]\n     expertises = UserExpertise.objects.filter(user=user).all()\n+    comments = Comment.visible_objects().filter(author=user).order_by(\"-created_at\")[:5]\n     posts = Post.objects_for_user(request.me)\\\n         .filter(author=user, is_visible=True)\\\n         .exclude(type__in=[Post.TYPE_INTRO, Post.TYPE_PROJECT])\n@@ -83,6 +89,7 @@\n         \"active_tags\": active_tags,\n         \"achievements\": achievements,\n         \"expertises\": expertises,\n+        \"comments\": comments,\n         \"posts\": paginate(request, posts),\n     })\n \n@@ -132,11 +139,7 @@\n     tag = get_object_or_404(Tag, code=tag_code)\n \n     user_tag, is_created = UserTag.objects.get_or_create(\n-        user=request.me,\n-        tag=tag,\n-        defaults=dict(\n-            name=tag.name\n-        )\n+        user=request.me, tag=tag, defaults=dict(name=tag.name)\n     )\n \n     if not is_created:\n@@ -156,7 +159,9 @@\n         if form.is_valid():\n             user_expertise = form.save(commit=False)\n             user_expertise.user = request.me\n-            UserExpertise.objects.filter(user=request.me, expertise=user_expertise.expertise).delete()\n+            UserExpertise.objects.filter(\n+                user=request.me, expertise=user_expertise.expertise\n+            ).delete()\n             user_expertise.save()\n             return {\n                 \"status\": \"created\",\n@@ -177,9 +182,7 @@\n         UserExpertise.objects.filter(user=request.me, expertise=expertise).delete()\n         return {\n             \"status\": \"deleted\",\n-            \"expertise\": {\n-                \"expertise\": expertise,\n-            },\n+            \"expertise\": {\"expertise\": expertise,},\n         }\n \n     return {\"status\": \"tipidor\"}\n", "issue": "\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0438\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435\n\u0425\u043e\u0447\u0443 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u043e\u0434 \u0441\u0432\u043e\u0438\u043c\u0438 \u0438 \u0447\u0443\u0436\u0438\u043c\u0438 \u043f\u043e\u0441\u0442\u0430\u043c\u0438, \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438 \u0433\u0434\u0435 \u044f \u043f\u0438\u0441\u0430\u043b, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e.\n", "before_files": [{"content": "from django.http import Http404\nfrom django.shortcuts import render, redirect, get_object_or_404\nfrom django_q.tasks import async_task\n\nfrom auth.helpers import auth_required, moderator_role_required\nfrom common.pagination import paginate\nfrom common.request import ajax_request\nfrom notifications.telegram.users import notify_profile_needs_review\nfrom posts.models import Post\nfrom search.models import SearchIndex\nfrom users.admin import do_user_admin_actions\nfrom users.forms.admin import UserAdminForm\nfrom users.forms.intro import UserIntroForm\nfrom users.forms.profile import UserEditForm, ExpertiseForm\nfrom users.models import User, UserBadge, UserExpertise, UserTag, Tag\n\n\n@auth_required\ndef intro(request):\n    if request.me.is_profile_complete \\\n            and request.me.is_profile_reviewed \\\n            and not request.me.is_profile_rejected:\n        return redirect(\"profile\", request.me.slug)\n\n    if request.method == \"POST\":\n        form = UserIntroForm(request.POST, request.FILES, instance=request.me)\n        if form.is_valid():\n            user = form.save(commit=False)\n\n            # send to moderation\n            user.is_profile_complete = True\n            user.is_profile_reviewed = False\n            user.is_profile_rejected = False\n            user.save()\n\n            # create intro post\n            intro_post = Post.upsert_user_intro(user, form.cleaned_data[\"intro\"], is_visible=False)\n\n            # notify moderators to review profile\n            async_task(notify_profile_needs_review, user, intro_post)\n\n            return redirect(\"on_review\")\n    else:\n        existing_intro = Post.get_user_intro(request.me)\n        form = UserIntroForm(\n            instance=request.me,\n            initial={\"intro\": existing_intro.text if existing_intro else \"\"},\n        )\n\n    return render(request, \"users/intro.html\", {\"form\": form})\n\n\n@auth_required\ndef profile(request, user_slug):\n    user = get_object_or_404(User, slug=user_slug)\n\n    if not request.me.is_moderator:\n        # hide unverified users\n        if not user.is_profile_complete or not user.is_profile_complete or user.is_profile_rejected:\n            raise Http404()\n\n    if user.id == request.me.id:\n        goto = request.GET.get(\"goto\")\n        if goto:\n            return redirect(goto)\n\n    tags = Tag.objects.filter(is_visible=True).all()\n\n    intro = Post.get_user_intro(user)\n    projects = Post.objects.filter(author=user, type=Post.TYPE_PROJECT).all()\n    active_tags = {t.tag_id for t in UserTag.objects.filter(user=user).all()}\n    achievements = UserBadge.objects.filter(user=user)[:8]\n    expertises = UserExpertise.objects.filter(user=user).all()\n    posts = Post.objects_for_user(request.me)\\\n        .filter(author=user, is_visible=True)\\\n        .exclude(type__in=[Post.TYPE_INTRO, Post.TYPE_PROJECT])\n\n    return render(request, \"users/profile.html\", {\n        \"user\": user,\n        \"intro\": intro,\n        \"projects\": projects,\n        \"tags\": tags,\n        \"active_tags\": active_tags,\n        \"achievements\": achievements,\n        \"expertises\": expertises,\n        \"posts\": paginate(request, posts),\n    })\n\n\n@auth_required\ndef edit_profile(request, user_slug):\n    user = get_object_or_404(User, slug=user_slug)\n    if user.id != request.me.id and not request.me.is_moderator:\n        raise Http404()\n\n    if request.method == \"POST\":\n        form = UserEditForm(request.POST, request.FILES, instance=user)\n        if form.is_valid():\n            user = form.save(commit=False)\n            user.save()\n\n            SearchIndex.update_user_index(user)\n\n            return redirect(\"profile\", user.slug)\n    else:\n        form = UserEditForm(instance=user)\n\n    return render(request, \"users/edit.html\", {\"form\": form})\n\n\n@auth_required\n@moderator_role_required\ndef admin_profile(request, user_slug):\n    user = get_object_or_404(User, slug=user_slug)\n\n    if request.method == \"POST\":\n        form = UserAdminForm(request.POST, request.FILES)\n        if form.is_valid():\n            return do_user_admin_actions(request, user, form.cleaned_data)\n    else:\n        form = UserAdminForm()\n\n    return render(request, \"users/admin.html\", {\"user\": user, \"form\": form})\n\n\n@auth_required\n@ajax_request\ndef toggle_tag(request, tag_code):\n    if request.method != \"POST\":\n        raise Http404()\n\n    tag = get_object_or_404(Tag, code=tag_code)\n\n    user_tag, is_created = UserTag.objects.get_or_create(\n        user=request.me,\n        tag=tag,\n        defaults=dict(\n            name=tag.name\n        )\n    )\n\n    if not is_created:\n        user_tag.delete()\n\n    return {\n        \"status\": \"created\" if is_created else \"deleted\",\n        \"tag\": {\"code\": tag.code, \"name\": tag.name, \"color\": tag.color},\n    }\n\n\n@auth_required\n@ajax_request\ndef add_expertise(request):\n    if request.method == \"POST\":\n        form = ExpertiseForm(request.POST)\n        if form.is_valid():\n            user_expertise = form.save(commit=False)\n            user_expertise.user = request.me\n            UserExpertise.objects.filter(user=request.me, expertise=user_expertise.expertise).delete()\n            user_expertise.save()\n            return {\n                \"status\": \"created\",\n                \"expertise\": {\n                    \"name\": user_expertise.name,\n                    \"expertise\": user_expertise.expertise,\n                    \"value\": user_expertise.value,\n                },\n            }\n\n    return {\"status\": \"tipidor\"}\n\n\n@auth_required\n@ajax_request\ndef delete_expertise(request, expertise):\n    if request.method == \"POST\":\n        UserExpertise.objects.filter(user=request.me, expertise=expertise).delete()\n        return {\n            \"status\": \"deleted\",\n            \"expertise\": {\n                \"expertise\": expertise,\n            },\n        }\n\n    return {\"status\": \"tipidor\"}\n\n\n@auth_required\ndef on_review(request):\n    if request.me.is_profile_reviewed:\n        return redirect(\"profile\", request.me.slug)\n    return render(request, \"users/messages/on_review.html\")\n\n\n@auth_required\ndef rejected(request):\n    return render(request, \"users/messages/rejected.html\")\n\n\n@auth_required\ndef banned(request):\n    return render(request, \"users/messages/banned.html\")\n", "path": "users/views.py"}], "after_files": [{"content": "from django.http import Http404\nfrom django.shortcuts import render, redirect, get_object_or_404\nfrom django_q.tasks import async_task\n\nfrom auth.helpers import auth_required, moderator_role_required\nfrom common.pagination import paginate\nfrom common.request import ajax_request\nfrom notifications.telegram.users import notify_profile_needs_review\nfrom posts.models import Post\nfrom comments.models import Comment\nfrom search.models import SearchIndex\nfrom users.admin import do_user_admin_actions\nfrom users.forms.admin import UserAdminForm\nfrom users.forms.intro import UserIntroForm\nfrom users.forms.profile import UserEditForm, ExpertiseForm\nfrom users.models import User, UserBadge, UserExpertise, UserTag, Tag\n\n\n@auth_required\ndef intro(request):\n    if (\n        request.me.is_profile_complete\n        and request.me.is_profile_reviewed\n        and not request.me.is_profile_rejected\n    ):\n        return redirect(\"profile\", request.me.slug)\n\n    if request.method == \"POST\":\n        form = UserIntroForm(request.POST, request.FILES, instance=request.me)\n        if form.is_valid():\n            user = form.save(commit=False)\n\n            # send to moderation\n            user.is_profile_complete = True\n            user.is_profile_reviewed = False\n            user.is_profile_rejected = False\n            user.save()\n\n            # create intro post\n            intro_post = Post.upsert_user_intro(\n                user, form.cleaned_data[\"intro\"], is_visible=False\n            )\n\n            # notify moderators to review profile\n            async_task(notify_profile_needs_review, user, intro_post)\n\n            return redirect(\"on_review\")\n    else:\n        existing_intro = Post.get_user_intro(request.me)\n        form = UserIntroForm(\n            instance=request.me,\n            initial={\"intro\": existing_intro.text if existing_intro else \"\"},\n        )\n\n    return render(request, \"users/intro.html\", {\"form\": form})\n\n\n@auth_required\ndef profile(request, user_slug):\n    user = get_object_or_404(User, slug=user_slug)\n\n    if not request.me.is_moderator:\n        # hide unverified users\n        if not user.is_profile_complete or not user.is_profile_complete or user.is_profile_rejected:\n            raise Http404()\n\n    if user.id == request.me.id:\n        goto = request.GET.get(\"goto\")\n        if goto:\n            return redirect(goto)\n\n    tags = Tag.objects.filter(is_visible=True).all()\n\n    intro = Post.get_user_intro(user)\n    projects = Post.objects.filter(author=user, type=Post.TYPE_PROJECT).all()\n    active_tags = {t.tag_id for t in UserTag.objects.filter(user=user).all()}\n    achievements = UserBadge.objects.filter(user=user)[:8]\n    expertises = UserExpertise.objects.filter(user=user).all()\n    comments = Comment.visible_objects().filter(author=user).order_by(\"-created_at\")[:5]\n    posts = Post.objects_for_user(request.me)\\\n        .filter(author=user, is_visible=True)\\\n        .exclude(type__in=[Post.TYPE_INTRO, Post.TYPE_PROJECT])\n\n    return render(request, \"users/profile.html\", {\n        \"user\": user,\n        \"intro\": intro,\n        \"projects\": projects,\n        \"tags\": tags,\n        \"active_tags\": active_tags,\n        \"achievements\": achievements,\n        \"expertises\": expertises,\n        \"comments\": comments,\n        \"posts\": paginate(request, posts),\n    })\n\n\n@auth_required\ndef edit_profile(request, user_slug):\n    user = get_object_or_404(User, slug=user_slug)\n    if user.id != request.me.id and not request.me.is_moderator:\n        raise Http404()\n\n    if request.method == \"POST\":\n        form = UserEditForm(request.POST, request.FILES, instance=user)\n        if form.is_valid():\n            user = form.save(commit=False)\n            user.save()\n\n            SearchIndex.update_user_index(user)\n\n            return redirect(\"profile\", user.slug)\n    else:\n        form = UserEditForm(instance=user)\n\n    return render(request, \"users/edit.html\", {\"form\": form})\n\n\n@auth_required\n@moderator_role_required\ndef admin_profile(request, user_slug):\n    user = get_object_or_404(User, slug=user_slug)\n\n    if request.method == \"POST\":\n        form = UserAdminForm(request.POST, request.FILES)\n        if form.is_valid():\n            return do_user_admin_actions(request, user, form.cleaned_data)\n    else:\n        form = UserAdminForm()\n\n    return render(request, \"users/admin.html\", {\"user\": user, \"form\": form})\n\n\n@auth_required\n@ajax_request\ndef toggle_tag(request, tag_code):\n    if request.method != \"POST\":\n        raise Http404()\n\n    tag = get_object_or_404(Tag, code=tag_code)\n\n    user_tag, is_created = UserTag.objects.get_or_create(\n        user=request.me, tag=tag, defaults=dict(name=tag.name)\n    )\n\n    if not is_created:\n        user_tag.delete()\n\n    return {\n        \"status\": \"created\" if is_created else \"deleted\",\n        \"tag\": {\"code\": tag.code, \"name\": tag.name, \"color\": tag.color},\n    }\n\n\n@auth_required\n@ajax_request\ndef add_expertise(request):\n    if request.method == \"POST\":\n        form = ExpertiseForm(request.POST)\n        if form.is_valid():\n            user_expertise = form.save(commit=False)\n            user_expertise.user = request.me\n            UserExpertise.objects.filter(\n                user=request.me, expertise=user_expertise.expertise\n            ).delete()\n            user_expertise.save()\n            return {\n                \"status\": \"created\",\n                \"expertise\": {\n                    \"name\": user_expertise.name,\n                    \"expertise\": user_expertise.expertise,\n                    \"value\": user_expertise.value,\n                },\n            }\n\n    return {\"status\": \"tipidor\"}\n\n\n@auth_required\n@ajax_request\ndef delete_expertise(request, expertise):\n    if request.method == \"POST\":\n        UserExpertise.objects.filter(user=request.me, expertise=expertise).delete()\n        return {\n            \"status\": \"deleted\",\n            \"expertise\": {\"expertise\": expertise,},\n        }\n\n    return {\"status\": \"tipidor\"}\n\n\n@auth_required\ndef on_review(request):\n    if request.me.is_profile_reviewed:\n        return redirect(\"profile\", request.me.slug)\n    return render(request, \"users/messages/on_review.html\")\n\n\n@auth_required\ndef rejected(request):\n    return render(request, \"users/messages/rejected.html\")\n\n\n@auth_required\ndef banned(request):\n    return render(request, \"users/messages/banned.html\")\n", "path": "users/views.py"}]}