How to use rename_permissions method in Kiwi

Best Python code snippet using Kiwi_python

0042_auto_20210503_1523.py

Source:0042_auto_20210503_1523.py Github

copy

Full Screen

...10def delete_permissions(model, codenames):11 for codename in codenames:12 permission = model.objects.get(codename=codename)13 permission.delete()14def rename_permissions(model, name_pairs):15 for codename, name in name_pairs:16 permission = model.objects.get(codename=codename)17 permission.name = name18 permission.save()19def update_permissions(apps, schema_editor):20 Permission = apps.get_model('auth', 'Permission')21 try:22 delete_permissions(Permission, [23 'add_answer',24 'change_answer',25 'check_answer',26 'delete_answer',27 'view_answer',28 ])29 for codename in ['add_question', 'change_question', 'delete_question', 'view_question']:30 permission = Permission.objects.get(codename=codename, content_type_id=46)31 permission.delete()32 delete_permissions(Permission, [33 'add_test',34 'change_test',35 'delete_test',36 'view_test',37 ])38 delete_permissions(Permission, [39 'add_testmembership',40 'change_testmembership',41 'delete_testmembership',42 'view_testmembership',43 ])44 delete_permissions(Permission, [45 'add_testsubmission',46 'change_testsubmission',47 'delete_testsubmission',48 'view_testsubmission',49 ])50 delete_permissions(Permission, [51 'add_testsuite',52 'change_testsuite',53 'delete_testsuite',54 'view_testsuite',55 ])56 delete_permissions(Permission, [57 'add_testsuitesubmission',58 'change_testsuitesubmission',59 'delete_testsuitesubmission',60 'view_testsuitesubmission',61 ])62 except Permission.DoesNotExist:63 pass64 rename_permissions(Permission, [65 ('add_faculty', "Добавлять Факультет"),66 ('change_faculty', "Изменять Факультет"),67 ('delete_faculty', "Удалять Факультет"),68 ('view_faculty', "Просматривать Факультет"),69 ])70 rename_permissions(Permission, [71 ('add_subscription', "Добавлять Подписку"),72 ('change_subscription', "Изменять Подписку"),73 ('delete_subscription', "Удалять Подписку"),74 ('view_subscription', "Просматривать Подписку"),75 ])76 rename_permissions(Permission, [77 ('add_filter', "Добавлять Фильтр"),78 ('change_filter', "Изменять Фильтр"),79 ('delete_filter', "Удалять Фильтр"),80 ('view_filter', "Просматривать Фильтр"),81 ])82 rename_permissions(Permission, [83 ('add_option', "Добавлять Вариант ответа"),84 ('change_option', "Изменять Вариант ответа"),85 ('delete_option', "Удалять Вариант ответа"),86 ('view_option', "Просматривать Вариант ответа"),87 ])88 rename_permissions(Permission, [89 ('add_submissionpattern', "Добавлять Шаблон посылки"),90 ('change_submissionpattern', "Изменять Шаблон посылки"),91 ('delete_submissionpattern', "Удалять Шаблон посылки"),92 ('view_submissionpattern', "Просматривать Шаблон посылки"),93 ])94 rename_permissions(Permission, [95 ('add_subproblem', "Добавлять Подзадачу"),96 ('change_subproblem', "Изменять Подзадачу"),97 ('delete_subproblem', "Удалять Подзадачу"),98 ('view_subproblem', "Просматривать Подзадачу"),99 ])100 rename_permissions(Permission, [101 ('add_schedule', "Добавлять Расписание"),102 ('change_schedule', "Изменять Расписание"),103 ('delete_schedule', "Удалять Расписание"),104 ('view_schedule', "Просматривать Расписание"),105 ])106 rename_permissions(Permission, [107 ('add_scheduleattachment', "Добавлять Файл расписания"),108 ('change_scheduleattachment', "Изменять Файл расписания"),109 ('delete_scheduleattachment', "Удалять Файл расписания"),110 ('view_scheduleattachment', "Просматривать Файл расписания"),111 ])112 rename_permissions(Permission, [113 ('add_report', "Добавлять Сообщение об ошибке"),114 ('change_report', "Изменять Сообщение об ошибке"),115 ('delete_report', "Удалять Сообщение об ошибке"),116 ('view_report', "Просматривать Сообщение об ошибке"),117 ])118class Migration(migrations.Migration):119 dependencies = [120 ('accounts', '0041_auto_20210427_0211'),121 ]122 operations = [123 migrations.RunPython(ensure_permissions_exist, migrations.RunPython.noop),124 migrations.RunPython(update_permissions, migrations.RunPython.noop)...

Full Screen

Full Screen

0018_auto_20211014_1857.py

Source:0018_auto_20211014_1857.py Github

copy

Full Screen

...6 for app_config in apps.get_app_configs():7 app_config.models_module = True8 create_permissions(app_config, verbosity=0)9 app_config.models_module = None10def rename_permissions(model, name_pairs):11 for codename, name in name_pairs:12 permission = model.objects.get(codename=codename)13 permission.name = name14 permission.save()15def update_permissions(apps, schema_editor):16 Permission = apps.get_model('auth', 'Permission')17 Group = apps.get_model('auth', 'Group')18 rename_permissions(Permission, [19 ('add_discussion', "Добавлять Обсуждение"),20 ('change_discussion', "Изменять Обсуждение"),21 ('delete_discussion', "Удалять Обсуждение"),22 ('view_discussion', "Просматривать Обсуждение"),23 ])24 rename_permissions(Permission, [25 ('add_courseleader', "Добавлять Преподавателя курса"),26 ('change_courseleader', "Изменять Преподавателя курса"),27 ('delete_courseleader', "Удалять Преподавателя курса"),28 ('view_courseleader', "Просматривать Преподавателя курса"),29 ])30 rename_permissions(Permission, [31 ('add_tutorialsteppass', "Добавлять Шаг руководства"),32 ('change_tutorialsteppass', "Изменять Шаг руководства"),33 ('delete_tutorialsteppass', "Удалять Шаг руководства"),34 ('view_tutorialsteppass', "Просматривать Шаг руководства"),35 ])36 group = Group.objects.get(name='Преподаватель')37 permission = Permission.objects.get(codename='view_discussion')38 group.permissions.add(permission)39class Migration(migrations.Migration):40 dependencies = [41 ('support', '0017_auto_20211014_1548'),42 ]43 operations = [44 migrations.RunPython(ensure_permissions_exist, migrations.RunPython.noop),...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1# Import version files2from . import create_tables, rename_permissions3modules = [4 create_tables, rename_permissions...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful