Git Product home page Git Product logo

blog_drf's People

Watchers

 avatar  avatar

blog_drf's Issues

Implement token authentication through API endpoint

Implement token authentication. Specifically. There should be an option to generate and manage tokens through an API endpoint.
Create a new API endpoint that generates access tokens upon successful authentication.
Test this endpoint.

Create an API for managing post images

Create an API for managing PostImage objects. It should have permission_classes = [IsAdminUser] so only the staff can create, update and delete post images. 'Normal' users can access them by fetching post details.

Create an API for managing comments

Create an API for managing comments. This ViewSet should handle creating, updating, and deleting comments. permission_classes should be set to [IsAuthenticated] so every logged-in user can comment on posts. Additionally, there should be a check in the partial_update and destroy methods so that users can alter only comments that they are authors of.

Create voting feature

Create a voting feature.

  • Create a Vote model that will have a user, comment and vote type fields
  • Create a vote serializer. The user field is read_only because it should be set based on the user making the request
  • Create a vote viewset. It should handle creating and deleting votes only. In the destroy method, a check should be added that raises an error if the user making the request is not the author of the vote
  • Create signals that will automatically calculate UserProfile.points based on vote type and on the fact, whether is the vote being created or deleted

Create a signal for deleting unassigned tags

Create a signal for deleting tags that are not assigned to any post. The function should run pre_delete. It should loop through the tags of the post that is being deleted, and check if the tag is assigned to any other post. if it's not, the tag should be deleted. That will make sure that there are no pointless tag objects in the database.

Create a posts API

Create a posts API. Create endpoints to GET, POST, PATCH and DELETE posts. GET should require no authentication. The rest of the methodes should require is_staff property set to True (rest_framework.permissions.IsAdminUser).
Test all of the endpoints.

Update the user model

Update the user model by removing all fields except of email ans password. For the rest of the fields create a new model - UserProfile. It should be created automatically after User. Use signals and post_save

Add no pagination option to list tags endpoint

Add no pagination option to list tags endpoint.
Add the following code to the posts.views.TagViewSet:

    def paginate_queryset(self, queryset, view=None):
        if 'no_page' in self.request.query_params:
            return None
        else:
            return self.paginator.paginate_queryset(queryset, self.request, view=self)

Thanks to this, when no_page is present in query params all tags will be listed at once - with no pagination.

Add a post-sorting feature.

Add a post-sorting feature. It should take as a query param sort and sort posts depending on the value.
Sorting options:

  • by title
  • by the number of comments
  • by date (created_at)
  • by update date
    Each of those should sort in ascending or descending order (for example sort=title-asc or sort=comments-desc)

Extend the `CommentSerializer`

Tweak posts.serializers to better refrect data nedded in the frontend app. Comment serializer should have this:

class UserProfileSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserProfile
        fields = ('first_name', 'last_name',
                  'date_of_birth', 'profile_image', 'points')


class PublicUserSerializer(UserSerializer):
    user_profile = UserProfileSerializer()

    class Meta(UserSerializer.Meta):
        fields = UserSerializer.Meta.fields + ('user_profile',)

and set author = PublicUserSerializer() in comment serializer.

Add redis, posts page cache

Add Redis to the project. By integrating Redis into the project, we can improve the performance and scalability of the application, particularly when it comes to handling high-traffic web pages like the posts page.

Create a post details endpoint

Create a post details endpoint. The serializer should extend the PostsSerializer and additionally have three fields - body, images, and comments.
Also, add the number_of_comments property to the Post model and add it to the PostsSerializer. There should be information about the number of comments while listing posts.

Add an option to reset a password

Add an option to reset a password.
There should be an option to send a POST request with an email of the user that has forgotten their password to get a link to reset it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.