Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda96fee

Browse files
committed
Merge pull requestpython#857 from malemburg/master
Disable anonymous postings by returning a 404.
2 parentsca4fdf5 +1fcd1e3 commitda96fee

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

‎jobs/tests/test_views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def test_job_create(self):
193193
'email':'hr@company.com'
194194
}
195195

196+
# Check that anonymous posting is not allowed. See #852.
197+
response=self.client.post(url,post_data)
198+
self.assertEqual(response.status_code,404)
199+
196200
if0:
197201
# Disabled for now, until we have found a better solution
198202
# to fight spammers. See #852.

‎jobs/views.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ def get_form_kwargs(self):
278278

279279
defform_valid(self,form):
280280
""" set the creator to the current user """
281-
# Associate Job to user if they are logged in
282-
ifself.request.user.is_authenticated():
283-
form.instance.creator=self.request.user
284-
else:
285-
# Temporary measure against spammers. See #852.
286-
returnsuper().form_invalid(form)
287-
returnsuper().form_valid(form)
288-
281+
282+
# Don't allow anonymous postings; see #852.
283+
ifnotself.request.user.is_authenticated():
284+
raiseHttp404
285+
286+
# Associate Job to user
287+
form.instance.creator=self.request.user
288+
returnsuper().form_valid(form)
289289

290290

291291
classJobEdit(JobMixin,UpdateView):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp