Best Python code snippet using Kiwi_python
update_permissions.py
Source:update_permissions.py
...44 if do_update:45 # update permission name's if changed46 for model in app.get_models():47 content_type = ContentType.objects.get_for_model(model)48 for codename, name in _get_all_permissions(model._meta):49 try:50 permission = Permission.objects.get(codename=codename, content_type=content_type)51 except Permission.DoesNotExist:52 continue53 if permission.name != name:54 old_str = str(permission)55 permission.name = name56 permission.save()57 if options['verbosity'] >= 2:58 self.stdout.write(59 self.style.SUCCESS(f"Update permission '{old_str}' to '{permission}'"),...
uma.py
Source:uma.py
...25 access_token = django_keycloak.services.client.get_access_token(26 client=client27 )28 for klass in app_config.get_models():29 scopes = _get_all_permissions(klass._meta)30 try:31 uma1_client.resource_set_create(32 token=access_token,33 name=klass._meta.label_lower,34 type='urn:{client}:resources:{model}'.format(35 client=slugify(client.client_id),36 model=klass._meta.label_lower37 ),38 scopes=scopes39 )40 except KeycloakClientError as e:41 if e.original_exc.response.status_code != 409:42 raise43def _get_all_permissions(meta):44 """45 :type meta: django.db.models.options.Options46 :rtype: list47 """...
fix_permissions.py
Source:fix_permissions.py
...19 sys.stdout.write('{}-{}\n'.format(opts.app_label, opts.object_name.lower()))20 ctype, created = ContentType.objects.get_or_create(21 app_label=opts.app_label,22 model=opts.object_name.lower())23 for codename, name in _get_all_permissions(opts):24 sys.stdout.write(' --{}\n'.format(codename))25 p, created = Permission.objects.get_or_create(26 codename=codename,27 content_type=ctype,28 defaults={'name': name})29 if created:...
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!!