Coder Social home page Coder Social logo

Comments (7)

Nagyman avatar Nagyman commented on June 17, 2024

Good idea! I don't know off the top of my head, but the Transition object gives you access to permissions (https://github.com/kmmbvnr/django-fsm/blob/master/django_fsm/__init__.py#L68)

Between that and _fsm_get_transitions (https://github.com/gadventures/django-fsm-admin/blob/master/fsm_admin/mixins.py#L48), should allow for some permission checking. The problem might be how to get a reference to the current user.

from django-fsm-admin.

mord4z avatar mord4z commented on June 17, 2024

Maybe we can get the current user via session or via request?

from django-fsm-admin.

mord4z avatar mord4z commented on June 17, 2024

I'm trying to use the request template processor, here's what I've done til now:
Added 'django.core.context_processors.request' to TEMPLATE_CONTEXT_PROCESSORS
Changed a bit the fsm_submit_row method, added these line:
request = context['request']
And passed one more param to _fsm_get_transitions:
transitions = model_admin.fsm_get_transitions(original,request)
On mixing the code is like:
user = request.user
transitions_func = 'get_available_user
{0}_transitions'.format(self.fsm_field)
transitions = getattr(obj, transitions_func)(user) if obj else []

Need more tests here!

from django-fsm-admin.

mord4z avatar mord4z commented on June 17, 2024

Now I have a problem: the transition don't be automatic saved with the new version

from django-fsm-admin.

Nagyman avatar Nagyman commented on June 17, 2024

@mord4z Is the mixin first in your inheritence chain?

from django-fsm-admin.

mord4z avatar mord4z commented on June 17, 2024

Sorry, my mistake, I override the save_model method and forgot to pass super. The code is working now, I'll try another pull request.

from django-fsm-admin.

mord4z avatar mord4z commented on June 17, 2024

Made a new pull request

from django-fsm-admin.

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.