Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Commit

Permalink
Update create link
Browse files Browse the repository at this point in the history
  • Loading branch information
enisbt committed Aug 17, 2018
1 parent 7512e51 commit a06953d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion factlist/claims/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LinkSerializer(serializers.ModelSerializer):

class Meta:
model = Link
fields = ('link', 'embed')
fields = ('id','link', 'embed')

def get_embed(self, link):
return cache.get(link.link)
Expand Down
19 changes: 19 additions & 0 deletions factlist/perspective/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,22 @@ def test_delete_an_issue(self):

response = enis_client.delete('/api/v1/issues/%s/' % issue_id)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

def test_create_a_link(self):
enis, enis_client = self.create_user_and_user_client()
ali, ali_client = self.create_user_and_user_client()

data = {
'title': 'Test issue',
'link': "https://github.com",
}
response = enis_client.post('/api/v1/issues/', data=data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

issue_id = response.data["id"]

data = {
"link": "https://twitter.com"
}
response = enis_client.post("/api/v1/issues/%s/links/" % issue_id, data=data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
2 changes: 1 addition & 1 deletion factlist/perspective/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
urlpatterns = [
path('issues/', ListAndCreateIssueView.as_view()),
path('issues/<int:pk>/', IssueView.as_view()),
path('issues/<int:pk>/links', CreateLinkView.as_view()),
path('issues/<int:pk>/links/', CreateLinkView.as_view()),
]
2 changes: 1 addition & 1 deletion factlist/perspective/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ class CreateLinkView(CreateAPIView):

def perform_create(self, serializer):
serializer.save()
print(serializer.data)
IssueLinks.objects.create(issue_id=self.kwargs["pk"], link_id=serializer.data["id"])

0 comments on commit a06953d

Please sign in to comment.