Skip to content
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

#161254669 : favorite and unfavorite an article #36

Closed
wants to merge 0 commits into from

Conversation

TheSteelGuy
Copy link
Contributor

What does this PR do?

Adds functionality for users to favorite or unfavorite an article

Description of Task to be completed?

an authenticated user hitting api/articles/<slug>/favorite/
with POST request should be able to favorite an article
with DELETE request should be able to unfavorite an article

How should this be manually tested?

$ virtualenv env
$ source env/bin/activate
$ cd env

- Clone this repo.

$ git clone https://github.com/andela/ah-orcas.git

- Switch to this branch

$ git checkout ft-favorite-article-161254669

- Create a .env file and run it. Check sample.env file to configure yours.

$ source .env

- Run the app

$ python manage.py runserver

Any background context you want to provide?

Authentication is required

What are the relevant pivotal tracker stories?

#161254669

authors/apps/article/urls.py Outdated Show resolved Hide resolved
authors/apps/article/tests/test_favorite.py Outdated Show resolved Hide resolved
authors/apps/article/tests/test_favorite.py Outdated Show resolved Hide resolved
@TheSteelGuy TheSteelGuy added the wip work in progress label Nov 14, 2018
@TheSteelGuy TheSteelGuy force-pushed the ft-favorite-article-161254669 branch 2 times, most recently from 339a7e3 to 60e8b91 Compare November 14, 2018 08:59

'url',
'favorited')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace

authors/urls.py Outdated
@@ -42,3 +50,4 @@
('authors.apps.report.urls',
'report'),
namespace='report'))]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line at end of file

@coveralls
Copy link

Pull Request Test Coverage Report for Build 572

  • 61 of 71 (85.92%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 87.471%

Changes Missing Coverage Covered Lines Changed/Added Lines %
authors/apps/article/views.py 36 38 94.74%
authors/apps/profiles/models.py 4 7 57.14%
authors/apps/article/serializers.py 8 13 61.54%
Totals Coverage Status
Change from base Build 569: -0.2%
Covered Lines: 761
Relevant Lines: 870

💛 - Coveralls

@TheSteelGuy TheSteelGuy force-pushed the ft-favorite-article-161254669 branch 2 times, most recently from c9e12cf to 44a8890 Compare November 14, 2018 12:16
authors/apps/article/views.py Outdated Show resolved Hide resolved
authors/apps/article/views.py Outdated Show resolved Hide resolved
@@ -25,6 +30,12 @@
RetrieveAPIView,
DestroyAPIView,
get_object_or_404, RetrieveUpdateDestroyAPIView)
from rest_framework.permissions import (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'AllowAny' from line 2
redefinition of unused 'IsAuthenticated' from line 2
redefinition of unused 'IsAuthenticatedOrReadOnly' from line 2

CommentsSerializer)
CommentsSerializer,
FavoriteSerializer)
from rest_framework.views import APIView

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'APIView' from line 4

@@ -185,3 +197,15 @@ def update(self, instance, validated_data):
instance.body = validated_data.get('body', instance.body)
instance.save()
return instance
class FavoriteSerializer(serializers.ModelSerializer):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 0

@@ -9,6 +9,9 @@

from authors.apps.profiles.models import UserProfile
from .models import RateArticle, Comments
from rest_framework.validators import UniqueTogetherValidator

from .models import RateArticle, Favorite

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'RateArticle' from line 11

@@ -24,3 +24,14 @@ def render(self, data, media_type=None, renderer_context=None):
class CommentsThreadsRenderer(AuthorsJSONRenderer):
charset = 'utf-8'
object_name = 'threads'
from rest_framework.renderers import JSONRenderer
from rest_framework import status

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module level import not at top of file

@@ -24,3 +24,14 @@ def render(self, data, media_type=None, renderer_context=None):
class CommentsThreadsRenderer(AuthorsJSONRenderer):
charset = 'utf-8'
object_name = 'threads'
from rest_framework.renderers import JSONRenderer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines after class or function definition, found 0
module level import not at top of file

@@ -172,3 +172,14 @@ class Comments(TimestampedModel):

def __str__(self):
return self.body

class Favorite(models.Model):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 1

@@ -172,3 +172,14 @@ class Comments(TimestampedModel):

def __str__(self):
return self.body

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants