-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added verification permission to mentor and to requests
- Loading branch information
Showing
6 changed files
with
43 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ def test_make_request(self): | |
create_url = reverse('email_requests:send_email', kwargs={'mentor_id': self.mentor.id}) | ||
|
||
request_params = { | ||
#'phone': '12345678910', | ||
'preferred_mentee_email': '[email protected]', | ||
'message': 'Hi this is test message', | ||
} | ||
|
@@ -46,7 +45,6 @@ def test_make_request(self): | |
|
||
self.assertEqual(request.mentor, self.mentor) | ||
self.assertEqual(request.mentee, self.mentee) | ||
#self.assertEqual(request.phone, request_params['phone']) | ||
self.assertEqual(request.preferred_mentee_email, request_params['preferred_mentee_email']) | ||
|
||
def test_make_request_no_phone(self): | ||
|
@@ -71,6 +69,22 @@ def test_make_request_no_phone(self): | |
self.assertEqual(request.phone, '') | ||
self.assertEqual(request.preferred_mentee_email, request_params['preferred_mentee_email']) | ||
|
||
def test_make_request_unverified(self): | ||
self.mentee = users_factories.ProfileFactory(verified=False) | ||
create_url = reverse('email_requests:send_email', kwargs={'mentor_id': self.mentor.id}) | ||
|
||
request_params = { | ||
'preferred_mentee_email': '[email protected]', | ||
'message': 'Hi this is test message', | ||
} | ||
|
||
resp = self.client.post( | ||
create_url, | ||
data=request_params, | ||
) | ||
|
||
self.assertFalse(Request.objects.filter(mentor=self.mentor, mentee=self.mentee).exists()) | ||
|
||
class ListRequestsTest(APITestCase): | ||
|
||
get_url = reverse('email_requests:requests_list') | ||
|
@@ -166,17 +180,10 @@ def test_mentee_only_requests(self): | |
|
||
|
||
def test_list_reqests_empty(self): | ||
|
||
|
||
resp = self.client.get( | ||
self.get_url, | ||
) | ||
|
||
self.assertEqual(resp.data['count'], 0) | ||
self.assertEqual(len(resp.data['results']), 0) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from rest_framework import permissions | ||
|
||
|
||
class VerifiedUser(permissions.BasePermission): | ||
""" | ||
Custom permission to only allow verified users | ||
""" | ||
|
||
def has_object_permission(self, request, view, obj): | ||
return obj.verified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters