Limit django rest framework api according to payment plans











up vote
0
down vote

favorite












I have some dynamically added features performed by an admin user, which i will associate with certain endpoints.



What would be a good approach to solve this problem?



The problem is how can i do this association?










share|improve this question
























  • Have you looked at django-rest-framework.org/api-guide/permissions? Until you've got a more concrete question/problem I'm not sure what anyone can advise here except to read through the permissions system and see if it fits what you're after/can be used for whatever it is you're after. (If that doesn't quite fit - then github.com/allisson/django-rest-framework-role-filters sounds like it might be feasible)
    – Jon Clements
    Nov 10 at 18:29












  • I will try to give more details
    – Juan Ignacio Sánchez
    Nov 10 at 18:34










  • i found out a posible solution, now i want to know how good it is.
    – Juan Ignacio Sánchez
    Nov 12 at 5:26















up vote
0
down vote

favorite












I have some dynamically added features performed by an admin user, which i will associate with certain endpoints.



What would be a good approach to solve this problem?



The problem is how can i do this association?










share|improve this question
























  • Have you looked at django-rest-framework.org/api-guide/permissions? Until you've got a more concrete question/problem I'm not sure what anyone can advise here except to read through the permissions system and see if it fits what you're after/can be used for whatever it is you're after. (If that doesn't quite fit - then github.com/allisson/django-rest-framework-role-filters sounds like it might be feasible)
    – Jon Clements
    Nov 10 at 18:29












  • I will try to give more details
    – Juan Ignacio Sánchez
    Nov 10 at 18:34










  • i found out a posible solution, now i want to know how good it is.
    – Juan Ignacio Sánchez
    Nov 12 at 5:26













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have some dynamically added features performed by an admin user, which i will associate with certain endpoints.



What would be a good approach to solve this problem?



The problem is how can i do this association?










share|improve this question















I have some dynamically added features performed by an admin user, which i will associate with certain endpoints.



What would be a good approach to solve this problem?



The problem is how can i do this association?







python django api permissions django-rest-framework






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 18:57









Shakil

4391313




4391313










asked Nov 10 at 18:23









Juan Ignacio Sánchez

305111




305111












  • Have you looked at django-rest-framework.org/api-guide/permissions? Until you've got a more concrete question/problem I'm not sure what anyone can advise here except to read through the permissions system and see if it fits what you're after/can be used for whatever it is you're after. (If that doesn't quite fit - then github.com/allisson/django-rest-framework-role-filters sounds like it might be feasible)
    – Jon Clements
    Nov 10 at 18:29












  • I will try to give more details
    – Juan Ignacio Sánchez
    Nov 10 at 18:34










  • i found out a posible solution, now i want to know how good it is.
    – Juan Ignacio Sánchez
    Nov 12 at 5:26


















  • Have you looked at django-rest-framework.org/api-guide/permissions? Until you've got a more concrete question/problem I'm not sure what anyone can advise here except to read through the permissions system and see if it fits what you're after/can be used for whatever it is you're after. (If that doesn't quite fit - then github.com/allisson/django-rest-framework-role-filters sounds like it might be feasible)
    – Jon Clements
    Nov 10 at 18:29












  • I will try to give more details
    – Juan Ignacio Sánchez
    Nov 10 at 18:34










  • i found out a posible solution, now i want to know how good it is.
    – Juan Ignacio Sánchez
    Nov 12 at 5:26
















Have you looked at django-rest-framework.org/api-guide/permissions? Until you've got a more concrete question/problem I'm not sure what anyone can advise here except to read through the permissions system and see if it fits what you're after/can be used for whatever it is you're after. (If that doesn't quite fit - then github.com/allisson/django-rest-framework-role-filters sounds like it might be feasible)
– Jon Clements
Nov 10 at 18:29






Have you looked at django-rest-framework.org/api-guide/permissions? Until you've got a more concrete question/problem I'm not sure what anyone can advise here except to read through the permissions system and see if it fits what you're after/can be used for whatever it is you're after. (If that doesn't quite fit - then github.com/allisson/django-rest-framework-role-filters sounds like it might be feasible)
– Jon Clements
Nov 10 at 18:29














I will try to give more details
– Juan Ignacio Sánchez
Nov 10 at 18:34




I will try to give more details
– Juan Ignacio Sánchez
Nov 10 at 18:34












i found out a posible solution, now i want to know how good it is.
– Juan Ignacio Sánchez
Nov 12 at 5:26




i found out a posible solution, now i want to know how good it is.
– Juan Ignacio Sánchez
Nov 12 at 5:26












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I did the following:



1) Stablish some constants strings representing what I know as 'features'. i.e:




  • feat1 = 'f1'

  • feat2 = 'f2'


2) Used this to create FEATURE_CHOICES into a Feature model. (This one would be created dynamically by admin users. Such users will associate the corresponding choice, and add additional representative metadata, useful for user-agents.



FEATURE_CHOICES = ((feat1, 'Awesome feature'), (feat2, 'Just a regular feature'))


3) On my views, added the corresponding value as a class variable: api_feature = feat1



4) Created a custom DRF Permission Class that implements a has_feature function which checks if the user's plan has such requested feature.



This is the solution that i've implemented for now. All constants were managed by django-decouple.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242074%2flimit-django-rest-framework-api-according-to-payment-plans%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I did the following:



    1) Stablish some constants strings representing what I know as 'features'. i.e:




    • feat1 = 'f1'

    • feat2 = 'f2'


    2) Used this to create FEATURE_CHOICES into a Feature model. (This one would be created dynamically by admin users. Such users will associate the corresponding choice, and add additional representative metadata, useful for user-agents.



    FEATURE_CHOICES = ((feat1, 'Awesome feature'), (feat2, 'Just a regular feature'))


    3) On my views, added the corresponding value as a class variable: api_feature = feat1



    4) Created a custom DRF Permission Class that implements a has_feature function which checks if the user's plan has such requested feature.



    This is the solution that i've implemented for now. All constants were managed by django-decouple.






    share|improve this answer

























      up vote
      0
      down vote













      I did the following:



      1) Stablish some constants strings representing what I know as 'features'. i.e:




      • feat1 = 'f1'

      • feat2 = 'f2'


      2) Used this to create FEATURE_CHOICES into a Feature model. (This one would be created dynamically by admin users. Such users will associate the corresponding choice, and add additional representative metadata, useful for user-agents.



      FEATURE_CHOICES = ((feat1, 'Awesome feature'), (feat2, 'Just a regular feature'))


      3) On my views, added the corresponding value as a class variable: api_feature = feat1



      4) Created a custom DRF Permission Class that implements a has_feature function which checks if the user's plan has such requested feature.



      This is the solution that i've implemented for now. All constants were managed by django-decouple.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I did the following:



        1) Stablish some constants strings representing what I know as 'features'. i.e:




        • feat1 = 'f1'

        • feat2 = 'f2'


        2) Used this to create FEATURE_CHOICES into a Feature model. (This one would be created dynamically by admin users. Such users will associate the corresponding choice, and add additional representative metadata, useful for user-agents.



        FEATURE_CHOICES = ((feat1, 'Awesome feature'), (feat2, 'Just a regular feature'))


        3) On my views, added the corresponding value as a class variable: api_feature = feat1



        4) Created a custom DRF Permission Class that implements a has_feature function which checks if the user's plan has such requested feature.



        This is the solution that i've implemented for now. All constants were managed by django-decouple.






        share|improve this answer












        I did the following:



        1) Stablish some constants strings representing what I know as 'features'. i.e:




        • feat1 = 'f1'

        • feat2 = 'f2'


        2) Used this to create FEATURE_CHOICES into a Feature model. (This one would be created dynamically by admin users. Such users will associate the corresponding choice, and add additional representative metadata, useful for user-agents.



        FEATURE_CHOICES = ((feat1, 'Awesome feature'), (feat2, 'Just a regular feature'))


        3) On my views, added the corresponding value as a class variable: api_feature = feat1



        4) Created a custom DRF Permission Class that implements a has_feature function which checks if the user's plan has such requested feature.



        This is the solution that i've implemented for now. All constants were managed by django-decouple.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 5:24









        Juan Ignacio Sánchez

        305111




        305111






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242074%2flimit-django-rest-framework-api-according-to-payment-plans%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues