Skip to content

Commit

Permalink
Populate username by default
Browse files Browse the repository at this point in the history
  • Loading branch information
akatsoulas committed May 13, 2024
1 parent 9b0a653 commit a3fce96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion kitsune/messages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def outbox(request):

@login_required
def new_message(request):
form = MessageForm(request.POST or None, user=request.user)
data = request.POST or None
form_kwargs = {"user": request.user}
if not data:
form_kwargs["initial"] = request.GET.dict()
form = MessageForm(data, **form_kwargs)
if form.is_valid() and not is_ratelimited(request, "private-message-day", "50/d"):
send_message(
form.cleaned_data["to"],
Expand Down
6 changes: 3 additions & 3 deletions kitsune/sumo/form_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def to_python(self, value):
# parts, strips whitespace from each part, and then further splits each non-empty
# part by the colon.
# Each resulting pair of values (before and after the colon) is stripped of
# any extra whitespace and returned as a tuple. This process is done lazily,
# generating each tuple only when iterated over.
key_value_pairs = (
tuple(map(str.strip, part.split(":"))) for part in value.split(",") if part.strip()
tuple(map(str.strip, (part if ":" in part else "user: " + part).split(":")[:2]))
for part in value.split(",")
if part.strip()
)

# Create data structure to hold values grouped by keys
Expand Down

0 comments on commit a3fce96

Please sign in to comment.