Skip to content

Commit

Permalink
fix: intro form (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Oct 23, 2023
1 parent 5b00ce7 commit df3daa5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions posts/forms/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def clean_is_visible_in_feeds(self):
return new_value


class PostIntroForm(forms.ModelForm):
class IntroForm(forms.ModelForm):
text = forms.CharField(
label="Текст интро",
required=True,
Expand Down Expand Up @@ -738,7 +738,7 @@ class Meta:


POST_TYPE_MAP = {
Post.TYPE_INTRO: PostIntroForm,
Post.TYPE_INTRO: IntroForm,
Post.TYPE_POST: PostTextForm,
Post.TYPE_LINK: PostLinkForm,
Post.TYPE_QUESTION: PostQuestionForm,
Expand Down
2 changes: 1 addition & 1 deletion posts/views/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def create_or_edit(request, post_type, post=None, mode="create"):
# validate form on POST
form = FormClass(request.POST, request.FILES, instance=post)
if form.is_valid():
if not request.me.is_moderator:
if post.type != Post.TYPE_INTRO and not request.me.is_moderator:
if Post.check_duplicate(
user=request.me,
title=form.cleaned_data["title"],
Expand Down
2 changes: 1 addition & 1 deletion users/forms/intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from common.forms import ImageUploadField


class UserIntroForm(ModelForm):
class UserInitialIntroForm(ModelForm):
slug = forms.CharField(
label="Никнейм",
required=True,
Expand Down
6 changes: 3 additions & 3 deletions users/views/intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from authn.decorators.auth import require_auth
from notifications.telegram.users import notify_profile_needs_review
from posts.models.post import Post
from users.forms.intro import UserIntroForm
from users.forms.intro import UserInitialIntroForm
from users.models.geo import Geo
from users.models.user import User

Expand All @@ -15,7 +15,7 @@ def intro(request):
return redirect("profile", request.me.slug)

if request.method == "POST":
form = UserIntroForm(request.POST, request.FILES, instance=request.me)
form = UserInitialIntroForm(request.POST, request.FILES, instance=request.me)
if form.is_valid():
user = form.save(commit=False)

Expand All @@ -36,7 +36,7 @@ def intro(request):
return redirect("on_review")
else:
existing_intro = Post.get_user_intro(request.me)
form = UserIntroForm(
form = UserInitialIntroForm(
instance=request.me,
initial={"intro": existing_intro.text if existing_intro else ""},
)
Expand Down

0 comments on commit df3daa5

Please sign in to comment.