8000 Stop using django.contrib.comments and django_comments_xtd by berkerpeksag · Pull Request #981 · python/pythondotorg · GitHub
[go: up one dir, main page]

Skip to content

Stop using django.contrib.comments and django_comments_xtd #981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Raise 401 if a non-admin user tries to approve a job
  • Loading branch information
berkerpeksag committed Aug 6, 2017
commit b46e90d7db568f12b645ec73e3a499406ae271b5
13 changes: 13 additions & 0 deletions jobs/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,16 @@ def test_job_comment_401(self):
response = self.client.post(url, form_data)
self.assertEqual(response.status_code, 401)
self.assertEqual(len(mail.outbox), 0)

def test_job_comment_401_approve(self):
mail.outbox = []
self.client.login(username=self.creator_username, password=self.creator_password)
url = reverse('jobs:job_review_comment_create')
form_data = {
'job': self.job1.pk,
'action': 'approve',
}
self.assertEqual(len(mail.outbox), 0)
response = self.client.post(url, form_data)
self.assertEqual(response.status_code, 401)
self.assertEqual(len(mail.outbox), 0)
4 changes: 3 additions & 1 deletion jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ def form_valid(self, form):
return HttpResponse('Unauthorized', status=401)
action = self.request.POST.get('action')
valid_actions = {'approve': Job.STATUS_APPROVED, 'reject': Job.STATUS_REJECTED}
if action is not None and action in valid_actions and self.has_jobs_board_admin_access():
if action is not None and action in valid_actions:
if not self.has_jobs_board_admin_access():
return HttpResponse('Unauthorized', status=401)
action_status = valid_actions.get(action)
getattr(form.instance.job, action)(self.request.user)
messages.add_message(
Expand Down
0