0

I created and enabled a tutor plugin successfully using this command

cookiecutter https://github.com/overhangio/cookiecutter-tutor-plugin.git

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?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.