Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to forbid change_permission and delete_permission... #180

Open
fucktx opened this issue Jan 29, 2023 · 3 comments
Open

how to forbid change_permission and delete_permission... #180

fucktx opened this issue Jan 29, 2023 · 3 comments
Labels

Comments

@fucktx
Copy link

fucktx commented Jan 29, 2023

i hope forbidden ( change, delete,add) permission

admin.py:


 def has_change_permission(self, request, obj=None):
     return False

 def has_delete_permission(self, request, obj=None):
     return False

extended django-apscheduler/admin.py DjangoJobExecutionAdmin,but not effect,alse i18n also not effect

image

version:
django_apscheduler==0.6.2
Django==4.1.5

@Undertone0809
Copy link

Undertone0809 commented Apr 25, 2023

你解决问题了吗?我也想把这个权限给删掉。同用simpleui,还有一个问题就是这个Django APScheduler没有图标的问题,你有尝试过给它们加图标上去吗?

Did you solve the problem? I'd like to get rid of that, too. Another problem with simpleui is that this Django APScheduler doesn't have an icon. Have you tried to add an icon to it?

@Undertone0809
Copy link

Undertone0809 commented Apr 25, 2023

我认为可能无效的原因是因为,单单的继承是无效的?需要子类@admin.register(DjangoJob),如果可以,我想看看你当时的代码是怎么执行的。

而且,如果简单继承,然后使用@admin.register(DjangoJob)注册,如下面的代码所示:

@admin.register(DjangoJob)
class CustomDjangoJobAdmin(DjangoJobAdmin):
    pass

会产生django.contrib.admin.sites.AlreadyRegistered: The model DjangoJob is already registered with 'django_apscheduler.DjangoJobAdmin'. 的错误。如果你遇到了这个错误,我想知道你是怎么解决的。


And the reason why I think it might not work is because inheritance alone is not working, right? I need to subclass
@admin.register(DjangoJob) , if I can, I'd like to see how your code executes at the time.

Also, if you simply inherit, then register with '@admin.register(DjangoJob)', as shown in the following code:

@admin.register(DjangoJob)
class CustomDjangoJobAdmin(DjangoJobAdmin):
    pass

Creates a django. Contrib. Admin. Sites. AlreadyRegistered: The model DjangoJob is already registered with django_apscheduler. DjangoJobAdmin. error. If you come across this mistake, I'd like to know what you did to fix it.

image

@luliangce
Copy link

luliangce commented Aug 7, 2024

make app load this code
it just work

from django_apscheduler.admin import DjangoJobAdmin, DjangoJobExecutionAdmin


def always_false(*args, **kwargs):
    return False

DjangoJobAdmin.has_add_permission = always_false
DjangoJobAdmin.has_change_permission = always_false
DjangoJobAdmin.has_delete_permission = always_false
DjangoJobExecutionAdmin.has_add_permission = always_false
DjangoJobExecutionAdmin.has_change_permission = always_false
DjangoJobExecutionAdmin.has_delete_permission = always_false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants