fix sms
This commit is contained in:
1 parent
1dea3509a7
commit
e3a6d1f9d4
42 files changed
+33086
-15779
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""افزودن پرمیشن جداگانهٔ ``ManageSMSSettings`` برای صفحات تنظیمات/قالبهای پیامک.
|
||||
|
||||
پیش از این، همهٔ مسیرهای پیامک با ``ManageSMS`` کنترل میشد. از این پس صفحات
|
||||
«تنظیمات سامانه» و «قالبها» با ``ManageSMSSettings`` جدا میشوند تا مدیر بتواند
|
||||
دسترسی به آنها را فقط به کاربران مشخصی بدهد، بدون دادن کل اختیارات پیامک.
|
||||
"""
|
||||
from django.db import migrations
|
||||
from django.db.models import F
|
||||
|
||||
|
||||
def ensure_permission(apps, schema_editor):
|
||||
"""رکورد Permission جدید را (اگر نبود) میسازد و نام نمایشیاش را اصلاح میکند."""
|
||||
Permission = apps.get_model('auth', 'Permission')
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
|
||||
content_type, _created = ContentType.objects.get_or_create(
|
||||
app_label='admin_panel', model='smsproviderconfig',
|
||||
)
|
||||
Permission.objects.get_or_create(
|
||||
content_type=content_type,
|
||||
codename='ManageSMSSettings',
|
||||
defaults={'name': 'ManageSMSSettings'},
|
||||
)
|
||||
# نام نمایشی هر دو پرمیشن پیامک را با قرارداد پروژه همراستا میکند.
|
||||
Permission.objects.filter(
|
||||
content_type=content_type, codename__in=['ManageSMS', 'ManageSMSSettings'],
|
||||
).update(name=F('codename'))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('admin_panel', '0070_sms_types_seven'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='smsproviderconfig',
|
||||
options={
|
||||
'permissions': [('ManageSMS', 'ManageSMS'),
|
||||
('ManageSMSSettings', 'ManageSMSSettings')],
|
||||
'verbose_name': 'تنظیمات سامانه پیامک',
|
||||
'verbose_name_plural': 'تنظیمات سامانه پیامک',
|
||||
},
|
||||
),
|
||||
migrations.RunPython(ensure_permission, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in new issue
Block a user