fix news_type

This commit is contained in:
Dmitriy Kuzmenko 2019-09-20 15:55:37 +03:00
parent 193ecfba7a
commit 1e1b09660d
2 changed files with 13 additions and 3 deletions

View File

@ -13,11 +13,13 @@ class BaseTestCase(APITestCase):
self.password = 'sedragurdaredips19'
self.email = 'sedragurda@desoz.com'
self.newsletter = True
self.user = User.objects.create_user(username=self.username, email=self.email, password=self.password)
self.user = User.objects.create_user(
username=self.username, email=self.email, password=self.password)
#get tokkens
tokkens = User.create_jwt_tokens(self.user)
self.client.cookies = SimpleCookie({'access_token': tokkens.get('access_token'),
'refresh_token': tokkens.get('refresh_token')})
self.client.cookies = SimpleCookie(
{'access_token': tokkens.get('access_token'),
'refresh_token': tokkens.get('refresh_token')})
class EmployeeTests(BaseTestCase):

View File

@ -46,3 +46,11 @@ class NewsDocument(Document):
def prepare_description(self, instance):
return instance.description
def get_instances_from_related(self, related_instance):
"""If related_models is set, define how to retrieve the Car instance(s) from the related model.
The related_models option should be used with caution because it can lead in the index
to the updating of a lot of items.
"""
if isinstance(related_instance, models.NewsType):
return related_instance.news_set.all()