Best Python code snippet using Kiwi_python
0042_auto_20210503_1523.py
Source:0042_auto_20210503_1523.py
...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)...
0018_auto_20211014_1857.py
Source:0018_auto_20211014_1857.py
...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),...
__init__.py
Source:__init__.py
1# Import version files2from . import create_tables, rename_permissions3modules = [4 create_tables, rename_permissions...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!