Coder Social home page Coder Social logo

Comments (2)

davidpofo avatar davidpofo commented on August 16, 2024

Because the Discussion Model has a GenericForeignKey( attached_to = GenericForeignKey('attached_to_content_type', 'attached_to_object_id')) it can be attached to any model with a GenericRelation like so:

class Comment(models.Model):
    ...
    likes = GenericRelation(Discussion)
# Creating a new like in the discussion
discussion.likes.create(attached_to_content_type=Discussion.LIKE, user=request.user)

In this example there is a constant in Discussion called LIKE. This issue then seems to either be enhancing the Discussion methods are present and applying GenericRelations to at least the User and Comment models. This is all to say the Discussion model is all setup to attach to other models.

from govready-q.

davidpofo avatar davidpofo commented on August 16, 2024

Unless otherwise discussed below the methods are already ready to be added given the Generic Relationship Discussion can have with any other model (given its GenericForeignKey)

  • is_discussion_deleted() is now .is_discussion_inactive() (note there is no deleting of a discussion yet implemented.)
  • get_project_context_dict doesn't seem relevant for any other model besides task.
  • is_public() doesn't seems to do anything as assigning the attribute is_discussion_public to a model doesn't happen anywhere so it always returns the default which is False.
  • Added get_discussion_autocompletes changes to get the organization from the discussion(should be 1 to 1). If another models wants to implement it they can look at the get_discussion_autocompletes in TaskAnswer
  • on_discussion_comment assumes a task to get the org which is easy enough to replace (comment.discussion.organization) however it also needs a project for the task which you cannot get from the comment.
  • on_discussion_comment_edited is not implemented see TODO line 95 in discussion/views.py
  • get_user_role is implemented solely assuming a task in TaskAnswer

from govready-q.

Related Issues (20)

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.