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]
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.
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.
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