Tutor Plugin for Admin Action Button

I created and enabled a tutor plugin successfully using this command

cookiecutter GitHub - overhangio/cookiecutter-tutor-plugin: Cookiecutter for tutor plugins

How would I use this plugin to implement Admin Action Button:
I have a folder adminUser with 2 files init.py from . import admin and admin.py see content below:

from django.contrib import admin
from django.contrib.auth.models import User

@admin.action(description="Mark selected Users as inactive")
def mark_users_inactive(modeladmin, request, queryset):
    queryset.update(is_active=False)
    modeladmin.message_user(request, f"{queryset.count()} users marked as inactive.")

admin.site.unregister(User)

@admin.register(User)
class CustomUserAdmin(admin.ModelAdmin):
    list_display = ("username", "email", "first_name", "last_name", "is_staff", "is_active")
    actions = [mark_users_inactive]

I added the lines below to the plugin.py:

PLUGIN_ROOT = Path(__file__).parent.parent.resolve()
hooks.Filters.COMPOSE_MOUNTS.add_item(("lms", (str(PLUGIN_ROOT / "adminAction"), "/openedx/edx-platform/adminAction")))
hooks.Filters.COMPOSE_MOUNTS.add_item(("cms", (str(PLUGIN_ROOT / "adminAction"), "/openedx/edx-platform/adminAction")))

Added patches/openedx-lms-env with INSTALLED_APPS += ["adminAction"]

Added recursive-include adminAction * in ./MANIFEST.in

In pyproject.toml
Added include = ["adminAction"] under [tool.hatch.build.targets.wheel]

Updated include = [ "/tutoradmin", "/adminAction", ".hatch_build.py"] under [tool.hatch.build.targets.sdist]

Yet the Action Button is not visible. Please what am I doing wrong?

@tutor-maintainers any help or pointers to documentation?

It looks like you mixed up a Tutor Plugin and an Open edX Platform plugin. If you trying to modify the Django Admin of the Open edX Platform, then you should create a “django app plugin” using the edx-cookiecutters. See the documentation here on how to use the cookiecutters repo.

Once you have that, you can simply add a tutor mount and install it inside the container manually for development and testing.

@arunmozhi you are right! regarding this I have installed openedx-plugin-example with hope I can modify it locally and add my action button in openedx_plugin/admin.py, import this file inside openedx_plugin/apps.py:ready() so that UserAdmin get reigistered, yet it has no effect.

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)

Please I need some help, am also wondering if I can achieve same with tutor-indigo, I am open with which ever approach that could work I just need a guide.

@pauldic I am not familiar with the openedx-plugin-example and it has too many things for me to quickly understand.

I have only used the edx-cookiecutter I linked before and the documentation to develop platform plugins. And I haven’t tried overriding Django Admin views in that context to share any issues, fixes, or known-workarounds.

However, I don’t think tutor-indigo has anything to do with it. It’s only for the Indigo theme and you can even disable it for you testing.

Thanks @arunmozhi for that clarification with tutor-indigo so I will stop wasting my time with it. I agree with you about the too many things in openedx-plugin-example I am trying to see if I can leverage on what it has already achieved though I am yet to make any headway