def save_model (self, request, obj, form, change): """ Hey Hey Hey...let me see your id...or your boobs-your choice...i prefer the BOOBS unless you're OVER 18...EEEWWWWWWW """ if not request.user.is_superuser: if not request.user.has_perm ("condor."+ Student.objects.get (pk = request.POST["student"]).class_room.grade.grade +"_"+ Student.objects.get (pk = request.POST["student"]).class_room.section +"_"+ Subject.objects.get (pk = request.POST ["subject"]).name): messages.add_message (request, messages.ERROR, "Denied, the request you've made has content you are not authorized to add/edit. Your request has not been saved") return None elif request.user.has_perm ("condor."+ Student.objects.get (pk = request.POST["student"]).class_room.grade.grade +"_"+ Student.objects.get (pk = request.POST["student"]).class_room.section +"_"+ Subject.objects.get (pk = request.POST ["subject"]).name): if not Permission.objects.filter (codename = "generate_report_card").exists(): NEW_P = Permission () NEW_P.codename = "generate_report_card" NEW_P.name = "Can Generate Report Card" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="gradereport") NEW_P.save() obj.save() elif request.user.is_superuser: if not Permission.objects.filter (codename = "generate_report_card").exists(): NEW_P = Permission () NEW_P.codename = "generate_report_card" NEW_P.name = "Can Generate Report Card" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="gradereport") NEW_P.save() """ we are going have to check whether or not the super user has made the right choices...i feel OLD...which takes like two lines """ if obj.subject not in obj.student.class_room.grade.subject.all(): messages.add_message (request, messages.ERROR, "Error: the subject you have selected is not given in the specified grade level, No changes have been made.") return None obj.save()
def test_add_groups_add_permissions(self): '''Tests adding a group to a user and add a permission to the group''' p1 = Permission() p1.name = 'Can Create' p1.codename = 'can_create' p1.content_type = ContentType.objects.get(id=1) p1.save() g1 = Group() g1.name = "employee" g1.save() g1.permissions.add(p1) g1.save() p2 = Permission() p2.name = 'Can Delete' p2.codename = 'can_delete' p2.content_type = ContentType.objects.get(id=1) p2.save() g2 = Group() g2.name = "manager" g2.save() g2.permissions.add(p2) g2.save() self.u1.groups.add(g1) self.u1.groups.add(g2) self.assertTrue(self.u1.groups.filter(name="employee")) self.assertTrue(self.u1.groups.filter(name="manager")) self.assertTrue(self.u1.has_perm(p1.name)) self.assertTrue(self.u1.has_perm(p2.name))
def save (self, *args, **kwargs): if self.id == None: # object is bein created for the first time super (ClassRoom, self).save(*args, **kwargs) # saving object LEVEL = self.grade.grade SECTION = self.section for S in self.grade.subject.all(): if not Permission.objects.filter (codename = (u""+ LEVEL +"_"+ SECTION +"_"+ S.__unicode__())).exists(): # creating... # Permission Structure # codename: {Level.grade}_{ClassRoom.section}_{Subject.name} # name: {Level.grade}-{ClassRoom.section}: {Subject.name} NEW_P = Permission () NEW_P.name = u""+ LEVEL +"-"+ SECTION +": "+ S.__unicode__() NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.codename = u""+ LEVEL +"_"+ SECTION +"_"+ S.__unicode__() NEW_P.save() NEW_P = Permission () NEW_P.name = u"Head Teacher of "+ self.grade.grade +"-"+ self.section NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.codename = u"H_"+ self.grade.grade +"_"+ self.section NEW_P.save() else: # object is being edited... PREVIOUS_CLASSROOM = ClassRoom.objects.get (pk = self.id) # we know this exists! PREVIOUS_GRADE = PREVIOUS_CLASSROOM.grade super (ClassRoom, self).save(*args, **kwargs) if self.__unicode__() != PREVIOUS_CLASSROOM.__unicode__(): # There has been change in the object, Permissions update is necessary """ NOTE: - On permission, when a class is changed say from 1A to 1B or 2A: we will assume (for permission sake) 1B is a different class! - i.e. all permissions associated with 1A will be removed, and new Permissions for 1B will be created """ Permission.objects.filter (codename__istartswith = PREVIOUS_GRADE.grade +"_"+ PREVIOUS_CLASSROOM.section +"_").delete() # Deleting all associated permissions with the previous class room object Permission.objects.filter (codename = u"H_" + PREVIOUS_GRADE.grade +"_"+ PREVIOUS_CLASSROOM.section).delete() for S in self.grade.subject.all(): # Creating permissions for the NEW class room NEW_P = Permission() NEW_P.codename = self.grade.grade +"_"+ self.section +"_"+ S.name NEW_P.name = self.grade.grade +"-"+ self.section +": "+ S.name NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.save() NEW_P = Permission () NEW_P.name = u"Head Teacher of "+ self.grade.grade +"-"+ self.section NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.codename = u"H_"+ self.grade.grade +"_"+ self.section NEW_P.save() if not Permission.objects.filter (codename = "generate_report_card").exists(): NEW_P = Permission () NEW_P.codename = "generate_report_card" NEW_P.name = "Can Generate Report Card" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.save()
def save_related (self, request, form, formsets, change): if change: # If any grade change occurred; the save override will take care of the removal of previous permissions associated with the previous grade # All we have to care aboot here is saving the related objects i.e. subject with the appropriate permissions # codename: {Level.grade}_{ClassRoom.section}_{Subject.name} # name: {Level.grade}-{ClassRoom.section}: {Subject.name} LEVEL = Level.objects.get (pk = request.META['HTTP_REFERER'][request.META['HTTP_REFERER'].rfind('/', 0, -1) + 1: -1]) # level object: related fields UNSAVED untill form save if LEVEL.classroom_set.count(): # we will have to create/edit permission if a level is associated with a class room NEW_SUBJECT_LIST = [] for SID in request.POST.getlist ("subject"): # Looping through the subject id's NEW_SUBJECT_LIST.append (Subject.objects.get(pk = SID).name) for CR in LEVEL.classroom_set.all(): # After finishing this loop we would have deleted any permission that shouldn't exist anymore due to the change in the level object for S in LEVEL.subject.all(): if S.name not in NEW_SUBJECT_LIST: Permission.objects.filter (codename = LEVEL.grade +"_"+ CR.section +"_"+ S.name).delete() for CR in LEVEL.classroom_set.all(): # After finishing this loop we would have created any new permission that should be created due to the change in the level object for S in NEW_SUBJECT_LIST: if not Permission.objects.filter (codename = LEVEL.grade +"_"+ CR.section +"_"+ S).exists(): # Permission Structure # codename: {Level.grade}_{ClassRoom.section}_{Subject.name} # name: {Level.grade}-{ClassRoom.section}: {Subject.name} NEW_P = Permission () NEW_P.codename = LEVEL.grade +"_"+ CR.section +"_"+ S NEW_P.name = LEVEL.grade +"-"+ CR.section +": "+ S NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.save() form.save()
def test_groups_permissions(self): '''Test permissions and adding groups to users''' g1 = Group() g1.name = 'Salespeople' # you must save before you add test_groups_permissions g1.save() g1.permissions.add(Permission.objects.get(id=1)) # prints out all available test_groups_permissions # for p in Permission.objects.all(): # print('Codename: ' + p.codename) # print('Name: ' + p.name) # print('ContentType: ' + str(p.content_type)) # this is a pretty bad idea: self.u1.user_permissions.add(p) # create a permission p = Permission() p.codename = 'change_product_price' p.name = 'Change the price of a product' p.content_type = ContentType.objects.get(id=1) p.save() # add permission to groups g1.permissions.add( Permission.objects.get(codename='change_product_price')) g1.save() # add user to group self.u1.groups.add(g1) self.u1.save() # check to see if the group has the new permissions self.assertTrue(self.u1.groups.filter(name='Salespeople')) self.assertTrue(self.u1.has_perm('admin.change_product_price'))
def setUp(self): self.factory = RequestFactory() self.test_user = UserModel.objects.create_user("test_user", "*****@*****.**", "123456") self.test_noscope_user = UserModel.objects.create_user( "test_no_scope_user", "*****@*****.**", "123456") from django.contrib.auth.models import Permission p = Permission() p.name = "test_user_scope" p.content_type_id = 7 p.save() self.test_user.user_permissions.add(p) self.application = Application( name="Test Application", user=self.test_user, client_type=Application.CLIENT_CONFIDENTIAL, client_id="test_client_id", authorization_grant_type=Application.GRANT_PASSWORD, client_secret="test_client_secret", scopes="test_app_scope1 test_app_scope2") self.application.save() oauth2_settings._SCOPES = ['read', 'write']
def test_permissions(self): """Test adding permissions to users and then test those permissions""" p1 = Permission() p1.codename = 'change_product_name' p1.name = 'Change the name of a product' p1.content_type = ContentType.objects.get(id=1) p1.save() p2 = Permission() p2.codename = 'give_discount' p2.name = 'Can give a discount to a customer' p2.content_type = ContentType.objects.get(id=2) p2.save() self.u1.user_permissions.add(p1,p2) self.assertTrue(self.u1.has_perm('change_product_name')) self.assertTrue(self.u1.has_perm('give_discount'))
def new_permission(self, name, content_type_id, codename): permission = Permission() permission.name = name permission.content_type_id = content_type_id permission.codename = codename permission.save() return False if permission.pk is None else permission
def test_add_and_test_permissions(self): p1 = Permission() p1.name = 'Change product price' p1.codename = 'change_product_price' p1.content_type = ContentType.objects.get(id=101) p1.save() self.u3.user_permissions.add(p1) self.assertTrue(self.u3.has_perm('account.change_product_price'))
def save(self, *args, **kwargs): if not self.id and hasattr(self, "instance_permissions"): for perm in self.instance_permissions: p = Permission() p.codename = "%s%s" % (perm[0], self.slug) p.name = "%s%s" % (perm[1], self.name) p.content_type = ContentType.objects.get_for_model(self) p.save() return super(PermissionMixIn, self).save(*args, **kwargs)
def test_user_permission(self): """Test to make sure user receive permissions correctly""" p = Permission() p.codename = 'change_product_price' p.name = 'Change the price of a product' p.content_type = ContentType.objects.get(id=1) p.save() self.u1.user_permissions.add(p) self.assertTrue(self.u1.has_perm('admin.change_product_price'))
def test_add_groups_check_permissions(self): for p in Permission.objects.all(): print(p.content_type.app_label + "." + p.codename) p1 = Permission() p1.name = 'Change product price' p1.codename = 'change_product_price' p1.content_type = ContentType.objects.get(id=1) p1.save() self.u1.user_permissions.add(p1)
def tagPreSave(sender, instance, created, **kwargs): if not created: return permission = Permission() permission.codename = 'tag_{0}'.format(instance.name) permission.name = 'Can add tag {0}'.format(instance.name) permission.content_type = ContentType.objects.get_for_model(Tag) permission.full_clean() permission.save()
def test_add_check_user_permissions(self): '''Check user permissions''' p1 = Permission() p1.name = 'Change product name' p1.codename = 'change_product_name' ct1 = ContentType.objects.get(id=1) #pulling an object here p1.content_type = ct1 p1.save() self.u1.user_permissions.add(p1) self.u1.has_perm('change_product_name')
def create_permission(request): new_permission=Permission() new_permission.content_type_id=1 new_permission.codename=request.POST.get("codename") new_permission.name=request.POST.get("permission_title") new_permission.save() description=request.POST.get("permission_desc") permission_type=request.POST.get("permission_type") new_permission.save() PermissionService.create_permission_extend(new_permission.id,permission_type, description)
def create(self,validated_data): p=Permission() c=ContentType.objects.get(id=7) p.name=validated_data["name"] p.content_type_id=c.id p.codename=validated_data["codename"] p.save() return validated_data
def test_add_permissions_to_user(self): '''Tests adding a permission to a user''' p1 = Permission() p1.name = 'Can Create' p1.codename = 'can_create' p1.content_type = ContentType.objects.get(id=1) p1.save() p2 = Permission() p2.name = 'Can Delete' p2.codename = 'can_delete' p2.content_type = ContentType.objects.get(id=1) p2.save() self.u1.user_permissions.add(p1) self.u1.user_permissions.add(p2) self.assertTrue(self.u1.has_perm(p1.name)) self.assertTrue(self.u1.has_perm(p2.name))
def save (self, *args, **kwargs): self.first_name = self.first_name.title() self.father_name = self.father_name.title() super (Parent, self).save(*args, **kwargs) if not Permission.objects.filter (codename = "send_message_p").exists(): NEW_P = Permission () NEW_P.codename = "send_message_p" NEW_P.name = "Can Send Messages to Parents (Directly)" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="parent") NEW_P.save()
def test_user_permissions(self): '''Add permissions to users and test permissions''' p = Permission() p.codename = 'change_product_price' p.name = 'Change the price of a product' p.content_type = ContentType.objects.get(id=1) p.save() p1 = Permission() p1.codename = 'change_product_name' p1.name = 'Change the name of a product' p1.content_type = ContentType.objects.get(id=1) p1.save() # add permission to user self.u1.user_permissions.add(p) self.u1.user_permissions.add(p1) self.u1.save() self.assertTrue(self.u1.has_perm('admin.change_product_price')) self.assertTrue(self.u1.has_perm('admin.change_product_name'))
def test_add_permissions(self): """Tests the creation and adding of Permissions""" self.u1 = amod.User.objects.get(email='*****@*****.**') p1 = Permission() p1.id = 1 p1.name = 'Change product price' p1.codename = 'change_product_price' p1.content_type = ContentType.objects.get(id=1) p1.save() self.u1.user_permissions.add(p1) self.assertTrue(self.u1.has_perm('account.change_product_price'))
def permissions_edit(request): _id = request.POST.get("id", None) name = request.POST.get("title", None) code = request.POST.get("code", None) if _id == None or _id == '': permissions = Permission(name=name, codename=code) else: permissions = Permission.objects.get(id=_id) permissions.name = name permissions.codename = code permissions.save() return HttpResponse(dialog('ok', 'success', '修改成功', {}))
def permit_add(form_data): # try: # permission = Permission.objects.create(codename=form_data.get('codename'), # name=form_data.get('name'), # content_type=form_data['content_type']) # except: # pass p = Permission() p.name = form_data['name'] p.codename = form_data['codename'] p.content_type_id = form_data['content_type_id'] p.save() return True, '权限添加成功,name: ' + form_data[ 'name'] + ' ,codename' + form_data['codename']
def save (self, *args, **kwargs): super (Student, self).save(*args, **kwargs) # Creating permissions which allows the super user to assign privileges on users if not Permission.objects.filter (codename = "send_message").exists(): NEW_P = Permission () NEW_P.codename = "send_message" NEW_P.name = "Can Send Messages to Parents" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="student") NEW_P.save() if not Permission.objects.filter (codename = "grade_report").exists(): NEW_P = Permission () NEW_P.codename = "grade_report" NEW_P.name = "Can Submit Grade Report" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="student") NEW_P.save() if not Permission.objects.filter (codename = "transfer_student").exists(): NEW_P = Permission () NEW_P.codename = "transfer_student" NEW_P.name = "Can Transfer Student" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="student") NEW_P.save()
def test_add_group_check_group_permissions(self): '''Add permissions to a group and check permissions''' # for p in Permission.objects.all(): # print(p.codename) p1 = Permission() p1.name = 'Change product price' p1.codename = 'change_product_price' ct1 = ContentType.objects.get(id=1) #pulling an object here p1.content_type = ct1 p1.save() g1 = Group() g1.name = 'Test Group' g1.save() g1.permissions.add(p1) g1.save() self.u1.groups.add(g1) self.u1.has_perm('account.change_product_price')
def test_add_group_test_permissions(self): g1 = Group() g1.name = 'SalesPeople' g1.save() self.u1.groups.add(g1) self.u1.save() self.assertTrue(self.u1.groups.filter(id=g1.id)) g1.permissions.add(Permission.objects.get(id=g1.id)) p = Permission() p.codename = 'change_product_price' p.name = 'Change the price of a product' p.content_type = ContentType.objects.get(id=1) p.save() g1.permissions.add(p) g1.save()
def test_add_groups_check_permissions(self): '''Add groups to a user and check permissions''' # for p in Permission.objects.all(): # print(p.content_type.app_label + '.' + p.codename) p1 = Permission() p1.name = 'Change product price' p1.codename = 'change_product_price' p1.content_type = ContentType.objects.get(id=1) p1.save() g1 = Group() g1.name = 'Salespeople' g1.save() g1.permissions.add(p1) g1.save() self.u3.groups.add(g1) self.assertTrue(self.u3.has_perm('admin.change_product_price'))
def test_adding_groups(self): """Test adding a few groups with permissions to users and then test those permissions""" g1 = Group() g1.name = 'Salespeople' g1.save() self.u1.groups.add(g1) self.u1.save() p1 = Permission() p1.codename = 'change_product_price' p1.name = 'Change the price of a product' p1.content_type = ContentType.objects.get(id=1) p1.save() g1.permissions.add(p1) g1.save() self.assertTrue(len(self.u1.groups.filter(name='Salespeople')), 1) self.assertTrue(self.u1.has_perm('change_product_price'))
def get_permission(permission_type, compendium_db): p = None ct = None try: ct = ContentType.objects.get( app_label=compendium_db.compendium_nick_name) except Exception as e: ct = ContentType() ct.app_label = compendium_db.compendium_nick_name ct.save() try: p = Permission.objects.get(content_type=ct, codename=permission_type) except Exception as e: p = Permission() p.content_type = ct p.codename = permission_type p.name = CommandPermission.get_name(permission_type) p.save() return p
def handle(self, *args, **options): #we create a variable with the path our config application file #with "yaml" library, we open application config file on read mode permissions_config=yaml.safe_load(open(os.path.join(settings.CONFIG_DIR,"permissions.yml"), "r")) #LOG_LEVEL = application_config[API_ENVIRONMENT]["LOG_LEVEL"] #DEFAULT_PWD= application_config[API_ENVIRONMENT]["DEFAULT_PWD"] print (permissions_config) all_groups=permissions_config['info']['groups'] all_models=permissions_config['info']['models'] all_permissions=permissions_config['info']['permissions'] for group in all_groups: new_group, created = Group.objects.get_or_create(name=group) new_group_default_permissions=permissions_config[group]['default'] new_group.permissions.clear() for model in all_models: try: permissions=permissions_config[group][model]['permissions'] print('Añado del fichero el permiso:'+",".join(permissions)+' del group:'+group+' del modelo:'+model) except KeyError: permissions=new_group_default_permissions print('Añado del default el permiso:'+",".join(permissions)+' del group:'+group+' del modelo:'+model) for permission in permissions: name = 'Can {} {}'.format(permission, model) print("Creating {}".format(name)) try: model_add_perm = Permission.objects.get(name=name) except Permission.DoesNotExist: model_add_perm=Permission() model_add_perm.content_type=ContentType.objects.get(model=model) model_add_perm.codename=permission+"_"+model model_add_perm.name=name model_add_perm.save() continue except Exception as e: print("Error creating the permission with name %s Error: %s" %(name, str(e)) ) new_group.permissions.add(model_add_perm)
def check_user_permission(self): """ Check all permissions. Permissions are not depend of current user""" if not self.token_valid: return user_permissions: List = self.data.get('user_permissions_all') ##print('User permissions: ', user_permissions[0]) for user_permission in user_permissions: content_type, created = ContentType.objects.get_or_create( app_label=user_permission.get('app_label'), model=user_permission.get('model'), ) codename = user_permission.get('codename') if not Permission.objects.filter(content_type=content_type, codename=codename).exists(): perm = Permission() perm.name = user_permission.get('name') perm.content_type = content_type perm.codename = codename perm.save() print('Content type: ', content_type, 'Created: ', created)
def save (self, *args, **kwargs): PREVIOUS_LEVEL = None if self.id != None: # Testing whether or not the object is being edited or being created PREVIOUS_LEVEL = Level.objects.get (pk = self.id) super (Level, self).save(*args, **kwargs) if PREVIOUS_LEVEL != None: # If we know the object is being edited, we have to test whether or not the object is affiliated with permissions if true permission updates necessary if self.grade != PREVIOUS_LEVEL.grade: # if change in grade occurred, we have to remove all permissions associated with the previous grade level Permission.objects.filter (codename__istartswith = PREVIOUS_LEVEL.grade +"_").delete() # Deleted all associated permissions with the previous grade if self.classroom_set.count(): # Testing whether or not the edited level object is associated with class room, if so NEW permission set is necessary for CR in self.classroom_set.all(): for S in self.subject.all(): # Permission Structure # codename: {Level.grade}_{ClassRoom.section}_{Subject.name} # name: {Level.grade}-{ClassRoom.section}: {Subject.name} NEW_P = Permission() NEW_P.codename = self.grade +"_"+ CR.section +"_"+ S.name NEW_P.name = self.grade +"-"+ CR.section +": "+ S.name NEW_P.content_type = ContentType.objects.get (app_label="condor", model="classroom") NEW_P.save()
def setUp(self): self.factory = RequestFactory() self.test_user = UserModel.objects.create_user("test_user", "*****@*****.**", "123456") self.test_noscope_user = UserModel.objects.create_user("test_no_scope_user", "*****@*****.**", "123456") from django.contrib.auth.models import Permission p = Permission() p.name = "test_user_scope" p.content_type_id = 7 p.save() self.test_user.user_permissions.add(p) self.application = Application( name="Test Application", user=self.test_user, client_type=Application.CLIENT_CONFIDENTIAL, client_id="test_client_id", authorization_grant_type=Application.GRANT_PASSWORD, client_secret="test_client_secret", scopes="test_app_scope1 test_app_scope2" ) self.application.save() oauth2_settings._SCOPES = ['read', 'write']
user = hmod.User() user.username = data[0] user.set_password(data[1]) user.is_superuser = data[2] user.is_staff = data[3] user.first_name = data[4] user.last_name = data[5] user.email = data[6] user.is_active = data[7] user.date_joined = data[8] user.save() permission = Permission() permission.codename = data[9] permission.content_type = ContentType.objects.get(id=data[10]) permission.name = data[11] permission.save() group = Group() group.name = data[12] group.save() group.permissions.add(permission) permission = Permission.objects.get(id=data[13]) group.permissions.add(permission) group.user_set.add(user) # assign the user to the group # create permissions and groups '''
import os os.environ['DJANGO_SETTINGS_MODULE'] = 'test_dmp.settings' import django; django.setup() from django.contrib.auth import models as conmod import homepage.models as hmod from django.contrib.auth.models import Group, Permission, ContentType # Create Super Group, Permissions, and User permission = Permission() permission.codename = 'super' permission.content_type = ContentType.objects.get(id=7) permission.name = 'Super Privileges' permission.save() group = Group() group.name = "super" group.save() group.permissions.add(permission) permission = Permission.objects.get(id=28) group.permissions.add(permission) user = hmod.User() user.is_staff = 'True' user.is_active = 'True' user.is_superuser = '******' user.username = '******' user.set_password('asdf') user.first_name = 'Super' user.last_name = 'User' user.email = '*****@*****.**' user.address1 = '4387 South 1400 East'
########################################################################################## #########Group #Delete old groups ########################################################################################## #########User ######################### -CREATE PERMISSIONS/GROUPS- ##################### Permission.objects.all().delete() Group.objects.all().delete() permission = Permission() permission.codename = 'manager_rights' permission.content_type = ContentType.objects.get(id=7) permission.name = 'Has Manager Rights' permission.save() group = Group() group.name = "Managers" group.save() group.permissions.add(permission) print('permissions initialized') #Delete old users hmod.SiteUser.objects.all().delete() #create som users ############################### -ADD FIRST USER- ############################### u = hmod.SiteUser()
import os os.environ['DJANGO_SETTINGS_MODULE'] = 'colheritage.settings' import django; django.setup() import homepage.models as hmod import datetime from django.contrib.auth.models import Group, Permission, ContentType permission = Permission() permission.codename = 'Admin' permission.content_type = ContentType.objects.get(id=7) permission.name = 'Super Privileges' permission.save() group = Group() group.name = "Admin" group.save() group.permissions.add(permission) permission = Permission.objects.get(id=94) group.permissions.add(permission) user = hmod.User() user.username = '******' user.set_password('asdf') user.is_superuser = True user.is_staff = True user.first_name = '' user.last_name = '' user.email = '' user.is_active = True
def create_permission(): permission = Permission() permission.name = 'Do stuff' permission.codename = 'Can do stuff' permission.content_type = {} return permission
#empty or drop the tables cursor = connection.cursor() cursor.execute("DROP SCHEMA PUBLIC CASCADE") cursor.execute("CREATE SCHEMA PUBLIC") subprocess.call([sys.executable, "manage.py", "migrate"]) #### Create permissions/groups ###### Permission.objects.all().delete() Group.objects.all().delete() ##Admin permission = Permission() permission.codename = 'admin_rights' permission.content_type = ContentType.objects.get(id=7) permission.name = 'AdminRights' permission.save() agroup = Group() agroup.name = "Admin" agroup.save() agroup.permissions.add(permission) subprocess.call([sys.executable, "manage.py", "migrate"]) ###Manager permission = Permission() permission.codename = 'manager_rights' permission.content_type = ContentType.objects.get(id=5) permission.name = 'ManagerRights' permission.save()
cursor = connection.cursor() cursor.execute("DROP SCHEMA PUBLIC CASCADE") cursor.execute("CREATE SCHEMA PUBLIC") subprocess.call([sys.executable, "manage.py", "migrate"]) print('Database Migrated') # #### CREATE PERMISSIONS/GROUPS ##################### Permission.objects.all().delete() Group.objects.all().delete() permissionU = Permission() permissionU.codename = 'User' permissionU.content_type = ContentType.objects.get(id=9) permissionU.name = 'user' permissionU.save() User = Group() User.name = "User" User.save() User.permissions.add(permissionU) permissionM = Permission() permissionM.codename = 'Manager' permissionM.content_type = ContentType.objects.get(id=8) permissionM.name = 'manager' permissionM.save() Manager = Group() Manager.name = "Manager" Manager.save() Manager.permissions.add(permissionM, permissionU)
def save_related (self, request, form, formsets, change): if not Permission.objects.filter (codename = "notify_parents_attendance").exists(): # Creating a permission, that allows a user to notify parents on attendance sheet...what-what NEW_P = Permission() NEW_P.codename = "notify_parents_attendance" NEW_P.name = "Can Notify Parents (on Attendance)" NEW_P.content_type = ContentType.objects.get (app_label="condor", model="attendance") NEW_P.save() if not change: """ - a new attendance object is being added, we will have to check for collision in the attendance sheet before saving the students in the requested list - We don't have to check whether or not the user has removed a student which he/she isn't supposed to, we only check the added one and check em' - we also have to make sure that the user [i.e. the teacher] is authenticated to do what he/she did """ # Step Uno: Checking for double dip --------------------------------------------------------------------------------------------------------------------------------------------------- DOBULE_DIP = [] for A in Attendance.objects.filter (academic_semester__id__exact = request.POST['academic_semester'], attendance_date__exact=request.POST['attendance_date']): for S in A.student.all(): DOBULE_DIP.append (S.id) for S in request.POST.getlist ('student'): if int (S) in DOBULE_DIP: # Collision detected!, add a message and return without saving the related object of students messages.add_message (request, messages.ERROR, "Collision has been detected; the student(s) you have selected already exist in another attendance sheet. The student(s) you've selected was/were not added to the attendance sheet") return # if it didn't return, that means we can go to step dos...well what are we waiting for; Let's get to it........that was SOO GAY! # Step Dos: Checking user permission -------------------------------------------------------------------------------------------------------------------------------------------------- PERMISSION_LIST = [] # It'll hold all the permission that a user must have in order for the request to be valid one for S in Student.objects.filter (id__in = request.POST.getlist ("student")): PERMISSION_LIST.append (u"condor.H_"+ S.class_room.grade.grade +"_"+ S.class_room.section) # Adding head of teacher permission if not request.user.has_perms (PERMISSION_LIST): # MOT...drum roll, The user doesn't have permission to do what he did messages.add_message (request, messages.ERROR, "Permission denied, your request has not been saved because you do not have the necessary permission") return form.save() # The user is a legit one, so your wish is my command or is it... elif change: # Object is being edited, now things might get messy but is doable...doable [funny] PREVIOUS_ATTENDANCE = Attendance.objects.get (id = request.META['HTTP_REFERER'][request.META['HTTP_REFERER'].rfind('/', 0, -1) + 1: -1]) # we know this exists PREVIOUS_LIST = [] # Holds list of student id's who were in the previous attendance state for S in PREVIOUS_ATTENDANCE.student.all(): PREVIOUS_LIST.append (u""+ str(S.id)) # Since get list in request returns a list containing id's as UNICODE: we have to cast to that one in order to compare # Step Uno: Checking for double dip --------------------------------------------------------------------------------------------------------------------------------------------------- DOBULE_DIP = [] if request.user.is_superuser: # Only super users are allowed to change details of an already existing attendance object, yall feell me...WEST SIIIIIED! for A in Attendance.objects.filter (academic_semester__id__exact = request.POST['academic_semester'], attendance_date__exact=request.POST['attendance_date']).exclude (id = request.META['HTTP_REFERER'][request.META['HTTP_REFERER'].rfind('/', 0, -1) + 1: -1]): for S in A.student.all(): DOBULE_DIP.append (S.id) else: # If you aren't a super user the only thing you can change is the student list, little MITCH for A in Attendance.objects.filter (academic_semester = PREVIOUS_ATTENDANCE.academic_semester, attendance_date = PREVIOUS_ATTENDANCE.attendance_date).exclude (id = request.META['HTTP_REFERER'][request.META['HTTP_REFERER'].rfind('/', 0, -1) + 1: -1]): for S in A.student.all(): DOBULE_DIP.append (S.id) for S in request.POST.getlist ('student'): if int (S) in DOBULE_DIP: messages.add_message (request, messages.ERROR, "Collision has been detected; the student(s) you have selected already exist in another attendance sheet. The student(s) you've selected was/were not added to the attendance sheet") return # Step Dos: Checking user permission -------------------------------------------------------------------------------------------------------------------------------------------------- PERMISSION_LIST = [] # Here permission list will be built a little differently; it'll hold permission for adding and removing a student from the list for S in request.POST.getlist ("student"): # Looping through the requested student id list, Added Student if S not in PREVIOUS_LIST: PERMISSION_LIST.append (u"condor.H_"+ Student.objects.get (pk = S).class_room.grade.grade +"_"+ Student.objects.get (pk = S).class_room.section) for S in PREVIOUS_LIST: # removed Student if S not in request.POST.getlist ("student"): PERMISSION_LIST.append (u"condor.H_"+ Student.objects.get (pk = S).class_room.grade.grade +"_"+ Student.objects.get (pk = S).class_room.section) if not request.user.has_perms (PERMISSION_LIST): messages.add_message (request, messages.ERROR, "Permission denied, your request has not been saved because you do not have the necessary permission") return form.save()
'place_taken': 'Germany', 'description': 'photo5', 'image': 'photo5.jpg' }, ]: d = hmod.Photograph() for k, v in data.items(): setattr(d, k, v) d.save() # Create Super Group, Permissions, and User permission = Permission() permission.codename = 'super' permission.content_type = ContentType.objects.get(id=7) permission.name = 'Super Privileges' permission.save() group = Group() group.name = "super" group.save() group.permissions.add(permission) permission = Permission.objects.get(id=61) group.permissions.add(permission) user = hmod.User() user.is_staff = 'True' user.is_active = 'True' user.is_superuser = '******' user.username = '******' user.set_password('asdf')
['权限管理',['分配权限','/rbac/distribute/permissions/','distribute_permissions']],\ ['权限管理',['批量操作权限','/rbac/multi/permissions/','multi_permissions']],\ ['',['添加权限','/rbac/menu/permission/add/(?P<second_menu_id>\d+)/$','menu_permission_add']],\ ['',['删除权限','/rbac/menu/permission/del/(?P<pk>\d+)/$','menu_permission_del']],\ ['',['修改权限','/rbac/menu/permission/edit/(?P<pk>\d+)/$','menu_permission_edit']],\ ['',['批量删除权限','/rbac/multi/permissions/del/(?P<pk>\d+)/$','multi_permissions_del']],\ ] for d in perlistdict: p = Permission() p.title = d[1][0] p.url = d[1][1] p.name = d[1][2] if d[0]: p.menu = Menu.objects.get(title = d[0]) p.save() # 角色 初始化 -- 3个角色(CEO、主管、普通用户) # CEO -- 具有所有权限 r = Role() r.title = 'CEO' r.save() r = Role.objects.get(title = 'CEO') r.permissions.add(Permission.objects.get(title = '首页'),\ Permission.objects.get(title = '帮助文档'),\ Permission.objects.get(title = '上传文件'),\ Permission.objects.get(title = '下载文件'),\
from django.contrib.auth.models import Group, Permission, ContentType from django.contrib.auth.decorators import permission_required permission = Permission() permission.codename = 'jedi_level' permission.content_type = ContentType.objects.get(id=7) permission.name = 'Has Jedi Privileges' permission.save() group = Group() group.name = "Jedis" group.save() group.permissions.add(permission) group.user_set.add(UserObjectHere)
def on_add_module(request,module_type,parent_id): context = {} try: parent = Module.objects.get(id=parent_id) context.update({'parent_name':parent.name}) context.update({'app_name':parent.app.name}) # title title = "" if module_type=="G": title = _(u"THÊM NHÓM MODULE") elif module_type=="M": title = _(u"THÊM MODULE") elif module_type=="P": title = _(u"THÊM QUYỀN") context.update({'title':title}) if request.POST: #auto commit transaction.set_autocommit(False) #parameter code = request.POST["txtCode"] name = request.POST["txtName"] action = request.POST["txtAction"] url = request.POST["txtUrl"] icon = request.POST["txtIcon"] ord_num = request.POST["txtOrd"] #new Module module = Module() module.code = code module.name = name module.action = action module.url = url module.type = module_type module.icon_class = icon module.ord = ord_num if request.POST.get('ckStatus'): module.status = "1" else: module.status = "0" module.parent = parent module.app = parent.app module.user_name = request.user.username if module_type=="M": #Insert content type content_type = ContentType() content_type.app_label = parent.app.code content_type.model = code content_type.name = name content_type.save() module.content_type = content_type elif module_type=="P": #Insert permission permission = Permission() permission.content_type = parent.content_type permission.name = name permission.codename = code permission.save() module.permission = permission #save module module.save() #commit transaction.commit() return HttpResponseRedirect(str("%s?app_id="+str(parent.app.id)) % resolve_url("module")) except Exception as ex: transaction.rollback() context.update({'has_error':str(ex)}) finally: context.update(csrf(request)) return render_to_response("admin/module/add-module.html", context, RequestContext(request))
def handle(self, *args, **options): usuario = ContentType.objects.filter(name='usuario')[0] sucursal = ContentType.objects.filter(name='sucursal')[0] menu = ContentType.objects.filter(name='menu')[0] producto = ContentType.objects.filter(name='producto')[0] producto_de_sucursal = ContentType.objects.filter(name='producto_de_sucursal')[0] ticket = ContentType.objects.filter(name='ticket')[0] productos_del_ticket = ContentType.objects.filter(name='productos_del_ticket')[0] corte = ContentType.objects.filter(name='corte')[0] corte_productos = ContentType.objects.filter(name='corte_productos')[0] codigo = ContentType.objects.filter(name='codigo')[0] Permission.objects.filter(content_type__app_label = 'app').delete() permiso = Permission() permiso.name = 'Agregar codigos' permiso.content_type = codigo permiso.codename = 'add_codigo' permiso.save() permiso = Permission() permiso.name = 'Cambiar codigos' permiso.content_type = codigo permiso.codename = 'change_codigo' permiso.save() permiso = Permission() permiso.name = 'Borrar codigos' permiso.content_type = codigo permiso.codename = 'delete_codigo' permiso.save() permiso = Permission() permiso.name = 'Borrar cortes' permiso.content_type = corte permiso.codename = 'delete_corte' permiso.save() permiso = Permission() permiso.name = 'Ver cortes' permiso.content_type = corte permiso.codename = 'change_corte' permiso.save() permiso = Permission() permiso.name = 'Agregar menus' permiso.content_type = menu permiso.codename = 'add_menu' permiso.save() permiso = Permission() permiso.name = 'Cambiar menus' permiso.content_type = menu permiso.codename = 'change_menu' permiso.save() permiso = Permission() permiso.name = 'Eliminar menus' permiso.content_type = menu permiso.codename = 'delete_menu' permiso.save() permiso = Permission() permiso.name = 'Agregar productos' permiso.content_type = producto permiso.codename = 'add_producto' permiso.save() permiso = Permission() permiso.name = 'Cambiar productos' permiso.content_type = producto permiso.codename = 'change_producto' permiso.save() permiso = Permission() permiso.name = 'Eliminar productos' permiso.content_type = producto permiso.codename = 'delete_producto' permiso.save() permiso = Permission() permiso.name = 'Modificar datos productos' permiso.content_type = producto_de_sucursal permiso.codename = 'change_producto_de_sucursal' permiso.save() permiso = Permission() permiso.name = 'Eliminar productos de sucursales' permiso.content_type = producto_de_sucursal permiso.codename = 'delete_producto_de_sucursal' permiso.save() permiso = Permission() permiso.name = 'Agregar sucursales' permiso.content_type = sucursal permiso.codename = 'add_sucursal' permiso.save() permiso = Permission() permiso.name = 'Cambiar sucursales' permiso.content_type = sucursal permiso.codename = 'change_sucursal' permiso.save() permiso = Permission() permiso.name = 'Borrar sucursales' permiso.content_type = sucursal permiso.codename = 'delete_sucursal' permiso.save() permiso = Permission() permiso.name = 'Ver Tickets' permiso.content_type = ticket permiso.codename = 'change_ticket' permiso.save() permiso = Permission() permiso.name = 'Eliminar Tickets' permiso.content_type = ticket permiso.codename = 'delete_ticket' permiso.save() permiso = Permission() permiso.name = 'Agregar usuarios' permiso.content_type = usuario permiso.codename = 'add_usuario' permiso.save() permiso = Permission() permiso.name = 'Cambiar usuarios' permiso.content_type = usuario permiso.codename = 'change_usuario' permiso.save() permiso = Permission() permiso.name = 'Borrar usuarios' permiso.content_type = usuario permiso.codename = 'delete_usuario' permiso.save() print 'Permisos actualizados!'
def update_action_permission(app, model, new_config, old_config): """更新inlineAction,对比新旧内容。新的、相同的使用新配置,旧的删除掉。""" new_action_ids, old_action_ids = set([]), set([]) new_actions = get_actions(new_config) old_actions = get_actions(old_config) if new_actions: actions = [ c for c in new_actions if isinstance(c, dict) and "groups" in c ] new_action_ids = set([action["id"] for action in actions]) if old_actions: actions = [ c for c in old_actions if isinstance(c, dict) and "groups" in c ] old_action_ids = set([action["id"] for action in actions]) create = [ action for action in new_actions if action["id"] in list(new_action_ids - old_action_ids) ] update = [ action for action in new_actions if action["id"] in list(new_action_ids & old_action_ids) ] delete = [ action for action in old_actions if isinstance(action, dict) and action["id"] in list(old_action_ids - new_action_ids) ] log.debug( f"ations of create: {create}, update: {update}, delete: {delete}") content_type = ContentType.objects.get(app_label=app, model=model) if create: ids = [action["id"] for action in create] actions = [action for action in new_actions if action["id"] in ids] for action in actions: log.debug(f"create permission for action: {action}") permission = Permission( name=action["title"], codename=f'{action["action"]}_{model}_{action["id"]}', content_type=content_type, ) permission.save() if action["groups"]: permission.group_set.set(action["groups"]) if update: ids = [action["id"] for action in update] actions = [action for action in new_actions if action["id"] in ids] for action in actions: log.debug(f"update permission for action: {action}") try: permission = Permission.objects.get( codename=f'{action["action"]}_{model}_{action["id"]}', content_type=content_type, ) if permission.name != action["title"]: permission.name = action["title"] permission.save() permission.group_set.set(action["groups"]) except Permission.DoesNotExist: log.error("update and set permission error", exc_info=True) permission = Permission( name=action["title"], codename=f'{action["action"]}_{model}_{action["id"]}', content_type=content_type, ) permission.save() if action["groups"]: log.debug(f'groups: {action["groups"]}') permission.group_set.set(action["groups"]) # TODO 没有生效。 if delete: ids = [action["id"] for action in delete] actions = [action for action in old_actions if action["id"] in ids] for action in actions: log.debug(f"delete permission for action: {action}") try: permission = Permission.objects.get( codename=f'{action["action"]}_{model}_{action["id"]}', content_type=content_type, ).delete() except: log.warn("delete permission error, may be does not exist")
##### DROP DATABASE, RECREATE IT, THEN MIGRATE IT ################# cursor = connection.cursor() cursor.execute("DROP SCHEMA PUBLIC CASCADE") cursor.execute("CREATE SCHEMA PUBLIC") subprocess.call([sys.executable, "manage.py", "migrate"]) ##### CREATE PERMISSIONS/GROUPS ##################### Permission.objects.all().delete() Group.objects.all().delete() AdminPermission = Permission() AdminPermission.codename = 'admin_rights' AdminPermission.content_type = ContentType.objects.get(id=7) AdminPermission.name = 'Has Admin Rights' AdminPermission.save() ManagerPermission = Permission() ManagerPermission.codename = 'manager_rights' ManagerPermission.content_type = ContentType.objects.get(id=7) ManagerPermission.name = 'Has Manager Rights' ManagerPermission.save() AdminGroup = Group() AdminGroup.name = "AdminGroup" AdminGroup.save() AdminGroup.permissions.add(AdminPermission) AdminGroup.permissions.add(ManagerPermission) ManagerGroup = Group()
def import_data(): # Initial Imports # Processing model: django.contrib.auth.models.Permission from django.contrib.auth.models import Permission auth_permission_1 = Permission() auth_permission_1.name = 'Can add email address' auth_permission_1.content_type = ContentType.objects.get( app_label="account", model="emailaddress") auth_permission_1.codename = 'add_emailaddress' auth_permission_1 = importer.save_or_locate(auth_permission_1) auth_permission_2 = Permission() auth_permission_2.name = 'Can change email address' auth_permission_2.content_type = ContentType.objects.get( app_label="account", model="emailaddress") auth_permission_2.codename = 'change_emailaddress' auth_permission_2 = importer.save_or_locate(auth_permission_2) auth_permission_3 = Permission() auth_permission_3.name = 'Can delete email address' auth_permission_3.content_type = ContentType.objects.get( app_label="account", model="emailaddress") auth_permission_3.codename = 'delete_emailaddress' auth_permission_3 = importer.save_or_locate(auth_permission_3) auth_permission_4 = Permission() auth_permission_4.name = 'Can view email address' auth_permission_4.content_type = ContentType.objects.get( app_label="account", model="emailaddress") auth_permission_4.codename = 'view_emailaddress' auth_permission_4 = importer.save_or_locate(auth_permission_4) auth_permission_5 = Permission() auth_permission_5.name = 'Can add email confirmation' auth_permission_5.content_type = ContentType.objects.get( app_label="account", model="emailconfirmation") auth_permission_5.codename = 'add_emailconfirmation' auth_permission_5 = importer.save_or_locate(auth_permission_5) auth_permission_6 = Permission() auth_permission_6.name = 'Can change email confirmation' auth_permission_6.content_type = ContentType.objects.get( app_label="account", model="emailconfirmation") auth_permission_6.codename = 'change_emailconfirmation' auth_permission_6 = importer.save_or_locate(auth_permission_6) auth_permission_7 = Permission() auth_permission_7.name = 'Can delete email confirmation' auth_permission_7.content_type = ContentType.objects.get( app_label="account", model="emailconfirmation") auth_permission_7.codename = 'delete_emailconfirmation' auth_permission_7 = importer.save_or_locate(auth_permission_7) auth_permission_8 = Permission() auth_permission_8.name = 'Can view email confirmation' auth_permission_8.content_type = ContentType.objects.get( app_label="account", model="emailconfirmation") auth_permission_8.codename = 'view_emailconfirmation' auth_permission_8 = importer.save_or_locate(auth_permission_8) auth_permission_9 = Permission() auth_permission_9.name = 'Can add log entry' auth_permission_9.content_type = ContentType.objects.get(app_label="admin", model="logentry") auth_permission_9.codename = 'add_logentry' auth_permission_9 = importer.save_or_locate(auth_permission_9) auth_permission_10 = Permission() auth_permission_10.name = 'Can change log entry' auth_permission_10.content_type = ContentType.objects.get( app_label="admin", model="logentry") auth_permission_10.codename = 'change_logentry' auth_permission_10 = importer.save_or_locate(auth_permission_10) auth_permission_11 = Permission() auth_permission_11.name = 'Can delete log entry' auth_permission_11.content_type = ContentType.objects.get( app_label="admin", model="logentry") auth_permission_11.codename = 'delete_logentry' auth_permission_11 = importer.save_or_locate(auth_permission_11) auth_permission_12 = Permission() auth_permission_12.name = 'Can view log entry' auth_permission_12.content_type = ContentType.objects.get( app_label="admin", model="logentry") auth_permission_12.codename = 'view_logentry' auth_permission_12 = importer.save_or_locate(auth_permission_12) auth_permission_13 = Permission() auth_permission_13.name = 'Can add social account' auth_permission_13.content_type = ContentType.objects.get( app_label="allauth", model="socialaccount") auth_permission_13.codename = 'add_socialaccount' auth_permission_13 = importer.save_or_locate(auth_permission_13) auth_permission_14 = Permission() auth_permission_14.name = 'Can change social account' auth_permission_14.content_type = ContentType.objects.get( app_label="allauth", model="socialaccount") auth_permission_14.codename = 'change_socialaccount' auth_permission_14 = importer.save_or_locate(auth_permission_14) auth_permission_15 = Permission() auth_permission_15.name = 'Can delete social account' auth_permission_15.content_type = ContentType.objects.get( app_label="allauth", model="socialaccount") auth_permission_15.codename = 'delete_socialaccount' auth_permission_15 = importer.save_or_locate(auth_permission_15) auth_permission_16 = Permission() auth_permission_16.name = 'Can view social account' auth_permission_16.content_type = ContentType.objects.get( app_label="allauth", model="socialaccount") auth_permission_16.codename = 'view_socialaccount' auth_permission_16 = importer.save_or_locate(auth_permission_16) auth_permission_17 = Permission() auth_permission_17.name = 'Can add social application' auth_permission_17.content_type = ContentType.objects.get( app_label="allauth", model="socialapp") auth_permission_17.codename = 'add_socialapp' auth_permission_17 = importer.save_or_locate(auth_permission_17) auth_permission_18 = Permission() auth_permission_18.name = 'Can change social application' auth_permission_18.content_type = ContentType.objects.get( app_label="allauth", model="socialapp") auth_permission_18.codename = 'change_socialapp' auth_permission_18 = importer.save_or_locate(auth_permission_18) auth_permission_19 = Permission() auth_permission_19.name = 'Can delete social application' auth_permission_19.content_type = ContentType.objects.get( app_label="allauth", model="socialapp") auth_permission_19.codename = 'delete_socialapp' auth_permission_19 = importer.save_or_locate(auth_permission_19) auth_permission_20 = Permission() auth_permission_20.name = 'Can view social application' auth_permission_20.content_type = ContentType.objects.get( app_label="allauth", model="socialapp") auth_permission_20.codename = 'view_socialapp' auth_permission_20 = importer.save_or_locate(auth_permission_20) auth_permission_21 = Permission() auth_permission_21.name = 'Can add social application token' auth_permission_21.content_type = ContentType.objects.get( app_label="allauth", model="socialtoken") auth_permission_21.codename = 'add_socialtoken' auth_permission_21 = importer.save_or_locate(auth_permission_21) auth_permission_22 = Permission() auth_permission_22.name = 'Can change social application token' auth_permission_22.content_type = ContentType.objects.get( app_label="allauth", model="socialtoken") auth_permission_22.codename = 'change_socialtoken' auth_permission_22 = importer.save_or_locate(auth_permission_22) auth_permission_23 = Permission() auth_permission_23.name = 'Can delete social application token' auth_permission_23.content_type = ContentType.objects.get( app_label="allauth", model="socialtoken") auth_permission_23.codename = 'delete_socialtoken' auth_permission_23 = importer.save_or_locate(auth_permission_23) auth_permission_24 = Permission() auth_permission_24.name = 'Can view social application token' auth_permission_24.content_type = ContentType.objects.get( app_label="allauth", model="socialtoken") auth_permission_24.codename = 'view_socialtoken' auth_permission_24 = importer.save_or_locate(auth_permission_24) auth_permission_25 = Permission() auth_permission_25.name = 'Can add group' auth_permission_25.content_type = ContentType.objects.get(app_label="auth", model="group") auth_permission_25.codename = 'add_group' auth_permission_25 = importer.save_or_locate(auth_permission_25) auth_permission_26 = Permission() auth_permission_26.name = 'Can change group' auth_permission_26.content_type = ContentType.objects.get(app_label="auth", model="group") auth_permission_26.codename = 'change_group' auth_permission_26 = importer.save_or_locate(auth_permission_26) auth_permission_27 = Permission() auth_permission_27.name = 'Can delete group' auth_permission_27.content_type = ContentType.objects.get(app_label="auth", model="group") auth_permission_27.codename = 'delete_group' auth_permission_27 = importer.save_or_locate(auth_permission_27) auth_permission_28 = Permission() auth_permission_28.name = 'Can view group' auth_permission_28.content_type = ContentType.objects.get(app_label="auth", model="group") auth_permission_28.codename = 'view_group' auth_permission_28 = importer.save_or_locate(auth_permission_28) auth_permission_29 = Permission() auth_permission_29.name = 'Can add permission' auth_permission_29.content_type = ContentType.objects.get( app_label="auth", model="permission") auth_permission_29.codename = 'add_permission' auth_permission_29 = importer.save_or_locate(auth_permission_29) auth_permission_30 = Permission() auth_permission_30.name = 'Can change permission' auth_permission_30.content_type = ContentType.objects.get( app_label="auth", model="permission") auth_permission_30.codename = 'change_permission' auth_permission_30 = importer.save_or_locate(auth_permission_30) auth_permission_31 = Permission() auth_permission_31.name = 'Can delete permission' auth_permission_31.content_type = ContentType.objects.get( app_label="auth", model="permission") auth_permission_31.codename = 'delete_permission' auth_permission_31 = importer.save_or_locate(auth_permission_31) auth_permission_32 = Permission() auth_permission_32.name = 'Can view permission' auth_permission_32.content_type = ContentType.objects.get( app_label="auth", model="permission") auth_permission_32.codename = 'view_permission' auth_permission_32 = importer.save_or_locate(auth_permission_32) auth_permission_33 = Permission() auth_permission_33.name = 'Can add user' auth_permission_33.content_type = ContentType.objects.get(app_label="auth", model="user") auth_permission_33.codename = 'add_user' auth_permission_33 = importer.save_or_locate(auth_permission_33) auth_permission_34 = Permission() auth_permission_34.name = 'Can change user' auth_permission_34.content_type = ContentType.objects.get(app_label="auth", model="user") auth_permission_34.codename = 'change_user' auth_permission_34 = importer.save_or_locate(auth_permission_34) auth_permission_35 = Permission() auth_permission_35.name = 'Can delete user' auth_permission_35.content_type = ContentType.objects.get(app_label="auth", model="user") auth_permission_35.codename = 'delete_user' auth_permission_35 = importer.save_or_locate(auth_permission_35) auth_permission_36 = Permission() auth_permission_36.name = 'Can view user' auth_permission_36.content_type = ContentType.objects.get(app_label="auth", model="user") auth_permission_36.codename = 'view_user' auth_permission_36 = importer.save_or_locate(auth_permission_36) auth_permission_37 = Permission() auth_permission_37.name = 'Can add Token' auth_permission_37.content_type = ContentType.objects.get( app_label="authtoken", model="token") auth_permission_37.codename = 'add_token' auth_permission_37 = importer.save_or_locate(auth_permission_37) auth_permission_38 = Permission() auth_permission_38.name = 'Can change Token' auth_permission_38.content_type = ContentType.objects.get( app_label="authtoken", model="token") auth_permission_38.codename = 'change_token' auth_permission_38 = importer.save_or_locate(auth_permission_38) auth_permission_39 = Permission() auth_permission_39.name = 'Can delete Token' auth_permission_39.content_type = ContentType.objects.get( app_label="authtoken", model="token") auth_permission_39.codename = 'delete_token' auth_permission_39 = importer.save_or_locate(auth_permission_39) auth_permission_40 = Permission() auth_permission_40.name = 'Can view Token' auth_permission_40.content_type = ContentType.objects.get( app_label="authtoken", model="token") auth_permission_40.codename = 'view_token' auth_permission_40 = importer.save_or_locate(auth_permission_40) auth_permission_41 = Permission() auth_permission_41.name = 'Can add content type' auth_permission_41.content_type = ContentType.objects.get( app_label="contenttypes", model="contenttype") auth_permission_41.codename = 'add_contenttype' auth_permission_41 = importer.save_or_locate(auth_permission_41) auth_permission_42 = Permission() auth_permission_42.name = 'Can change content type' auth_permission_42.content_type = ContentType.objects.get( app_label="contenttypes", model="contenttype") auth_permission_42.codename = 'change_contenttype' auth_permission_42 = importer.save_or_locate(auth_permission_42) auth_permission_43 = Permission() auth_permission_43.name = 'Can delete content type' auth_permission_43.content_type = ContentType.objects.get( app_label="contenttypes", model="contenttype") auth_permission_43.codename = 'delete_contenttype' auth_permission_43 = importer.save_or_locate(auth_permission_43) auth_permission_44 = Permission() auth_permission_44.name = 'Can view content type' auth_permission_44.content_type = ContentType.objects.get( app_label="contenttypes", model="contenttype") auth_permission_44.codename = 'view_contenttype' auth_permission_44 = importer.save_or_locate(auth_permission_44) auth_permission_45 = Permission() auth_permission_45.name = 'Can add Dataset' auth_permission_45.content_type = ContentType.objects.get( app_label="datastore", model="datasetmodel") auth_permission_45.codename = 'add_datasetmodel' auth_permission_45 = importer.save_or_locate(auth_permission_45) auth_permission_46 = Permission() auth_permission_46.name = 'Can change Dataset' auth_permission_46.content_type = ContentType.objects.get( app_label="datastore", model="datasetmodel") auth_permission_46.codename = 'change_datasetmodel' auth_permission_46 = importer.save_or_locate(auth_permission_46) auth_permission_47 = Permission() auth_permission_47.name = 'Can delete Dataset' auth_permission_47.content_type = ContentType.objects.get( app_label="datastore", model="datasetmodel") auth_permission_47.codename = 'delete_datasetmodel' auth_permission_47 = importer.save_or_locate(auth_permission_47) auth_permission_48 = Permission() auth_permission_48.name = 'Can view Dataset' auth_permission_48.content_type = ContentType.objects.get( app_label="datastore", model="datasetmodel") auth_permission_48.codename = 'view_datasetmodel' auth_permission_48 = importer.save_or_locate(auth_permission_48) auth_permission_49 = Permission() auth_permission_49.name = 'Can add Entry' auth_permission_49.content_type = ContentType.objects.get( app_label="datastore", model="entrymodel") auth_permission_49.codename = 'add_entrymodel' auth_permission_49 = importer.save_or_locate(auth_permission_49) auth_permission_50 = Permission() auth_permission_50.name = 'Can change Entry' auth_permission_50.content_type = ContentType.objects.get( app_label="datastore", model="entrymodel") auth_permission_50.codename = 'change_entrymodel' auth_permission_50 = importer.save_or_locate(auth_permission_50) auth_permission_51 = Permission() auth_permission_51.name = 'Can delete Entry' auth_permission_51.content_type = ContentType.objects.get( app_label="datastore", model="entrymodel") auth_permission_51.codename = 'delete_entrymodel' auth_permission_51 = importer.save_or_locate(auth_permission_51) auth_permission_52 = Permission() auth_permission_52.name = 'Can view Entry' auth_permission_52.content_type = ContentType.objects.get( app_label="datastore", model="entrymodel") auth_permission_52.codename = 'view_entrymodel' auth_permission_52 = importer.save_or_locate(auth_permission_52) auth_permission_53 = Permission() auth_permission_53.name = 'Can add schema model' auth_permission_53.content_type = ContentType.objects.get( app_label="datastore", model="schemamodel") auth_permission_53.codename = 'add_schemamodel' auth_permission_53 = importer.save_or_locate(auth_permission_53) auth_permission_54 = Permission() auth_permission_54.name = 'Can change schema model' auth_permission_54.content_type = ContentType.objects.get( app_label="datastore", model="schemamodel") auth_permission_54.codename = 'change_schemamodel' auth_permission_54 = importer.save_or_locate(auth_permission_54) auth_permission_55 = Permission() auth_permission_55.name = 'Can delete schema model' auth_permission_55.content_type = ContentType.objects.get( app_label="datastore", model="schemamodel") auth_permission_55.codename = 'delete_schemamodel' auth_permission_55 = importer.save_or_locate(auth_permission_55) auth_permission_56 = Permission() auth_permission_56.name = 'Can view schema model' auth_permission_56.content_type = ContentType.objects.get( app_label="datastore", model="schemamodel") auth_permission_56.codename = 'view_schemamodel' auth_permission_56 = importer.save_or_locate(auth_permission_56) auth_permission_57 = Permission() auth_permission_57.name = 'Can add Argument' auth_permission_57.content_type = ContentType.objects.get( app_label="engine", model="argumentmodel") auth_permission_57.codename = 'add_argumentmodel' auth_permission_57 = importer.save_or_locate(auth_permission_57) auth_permission_58 = Permission() auth_permission_58.name = 'Can change Argument' auth_permission_58.content_type = ContentType.objects.get( app_label="engine", model="argumentmodel") auth_permission_58.codename = 'change_argumentmodel' auth_permission_58 = importer.save_or_locate(auth_permission_58) auth_permission_59 = Permission() auth_permission_59.name = 'Can delete Argument' auth_permission_59.content_type = ContentType.objects.get( app_label="engine", model="argumentmodel") auth_permission_59.codename = 'delete_argumentmodel' auth_permission_59 = importer.save_or_locate(auth_permission_59) auth_permission_60 = Permission() auth_permission_60.name = 'Can view Argument' auth_permission_60.content_type = ContentType.objects.get( app_label="engine", model="argumentmodel") auth_permission_60.codename = 'view_argumentmodel' auth_permission_60 = importer.save_or_locate(auth_permission_60) auth_permission_61 = Permission() auth_permission_61.name = 'Can add execution model' auth_permission_61.content_type = ContentType.objects.get( app_label="engine", model="executionmodel") auth_permission_61.codename = 'add_executionmodel' auth_permission_61 = importer.save_or_locate(auth_permission_61) auth_permission_62 = Permission() auth_permission_62.name = 'Can change execution model' auth_permission_62.content_type = ContentType.objects.get( app_label="engine", model="executionmodel") auth_permission_62.codename = 'change_executionmodel' auth_permission_62 = importer.save_or_locate(auth_permission_62) auth_permission_63 = Permission() auth_permission_63.name = 'Can delete execution model' auth_permission_63.content_type = ContentType.objects.get( app_label="engine", model="executionmodel") auth_permission_63.codename = 'delete_executionmodel' auth_permission_63 = importer.save_or_locate(auth_permission_63) auth_permission_64 = Permission() auth_permission_64.name = 'Can view execution model' auth_permission_64.content_type = ContentType.objects.get( app_label="engine", model="executionmodel") auth_permission_64.codename = 'view_executionmodel' auth_permission_64 = importer.save_or_locate(auth_permission_64) auth_permission_65 = Permission() auth_permission_65.name = 'Can add Process' auth_permission_65.content_type = ContentType.objects.get( app_label="engine", model="processmodel") auth_permission_65.codename = 'add_processmodel' auth_permission_65 = importer.save_or_locate(auth_permission_65) auth_permission_66 = Permission() auth_permission_66.name = 'Can change Process' auth_permission_66.content_type = ContentType.objects.get( app_label="engine", model="processmodel") auth_permission_66.codename = 'change_processmodel' auth_permission_66 = importer.save_or_locate(auth_permission_66) auth_permission_67 = Permission() auth_permission_67.name = 'Can delete Process' auth_permission_67.content_type = ContentType.objects.get( app_label="engine", model="processmodel") auth_permission_67.codename = 'delete_processmodel' auth_permission_67 = importer.save_or_locate(auth_permission_67) auth_permission_68 = Permission() auth_permission_68.name = 'Can view Process' auth_permission_68.content_type = ContentType.objects.get( app_label="engine", model="processmodel") auth_permission_68.codename = 'view_processmodel' auth_permission_68 = importer.save_or_locate(auth_permission_68) auth_permission_69 = Permission() auth_permission_69.name = 'Can add Airport' auth_permission_69.content_type = ContentType.objects.get( app_label="mdm", model="airportmodel") auth_permission_69.codename = 'add_airportmodel' auth_permission_69 = importer.save_or_locate(auth_permission_69) auth_permission_70 = Permission() auth_permission_70.name = 'Can change Airport' auth_permission_70.content_type = ContentType.objects.get( app_label="mdm", model="airportmodel") auth_permission_70.codename = 'change_airportmodel' auth_permission_70 = importer.save_or_locate(auth_permission_70) auth_permission_71 = Permission() auth_permission_71.name = 'Can delete Airport' auth_permission_71.content_type = ContentType.objects.get( app_label="mdm", model="airportmodel") auth_permission_71.codename = 'delete_airportmodel' auth_permission_71 = importer.save_or_locate(auth_permission_71) auth_permission_72 = Permission() auth_permission_72.name = 'Can view Airport' auth_permission_72.content_type = ContentType.objects.get( app_label="mdm", model="airportmodel") auth_permission_72.codename = 'view_airportmodel' auth_permission_72 = importer.save_or_locate(auth_permission_72) auth_permission_73 = Permission() auth_permission_73.name = 'Can add Bagtype' auth_permission_73.content_type = ContentType.objects.get( app_label="mdm", model="bagtypemodel") auth_permission_73.codename = 'add_bagtypemodel' auth_permission_73 = importer.save_or_locate(auth_permission_73) auth_permission_74 = Permission() auth_permission_74.name = 'Can change Bagtype' auth_permission_74.content_type = ContentType.objects.get( app_label="mdm", model="bagtypemodel") auth_permission_74.codename = 'change_bagtypemodel' auth_permission_74 = importer.save_or_locate(auth_permission_74) auth_permission_75 = Permission() auth_permission_75.name = 'Can delete Bagtype' auth_permission_75.content_type = ContentType.objects.get( app_label="mdm", model="bagtypemodel") auth_permission_75.codename = 'delete_bagtypemodel' auth_permission_75 = importer.save_or_locate(auth_permission_75) auth_permission_76 = Permission() auth_permission_76.name = 'Can view Bagtype' auth_permission_76.content_type = ContentType.objects.get( app_label="mdm", model="bagtypemodel") auth_permission_76.codename = 'view_bagtypemodel' auth_permission_76 = importer.save_or_locate(auth_permission_76) auth_permission_77 = Permission() auth_permission_77.name = 'Can add Board' auth_permission_77.content_type = ContentType.objects.get( app_label="mdm", model="boardmodel") auth_permission_77.codename = 'add_boardmodel' auth_permission_77 = importer.save_or_locate(auth_permission_77) auth_permission_78 = Permission() auth_permission_78.name = 'Can change Board' auth_permission_78.content_type = ContentType.objects.get( app_label="mdm", model="boardmodel") auth_permission_78.codename = 'change_boardmodel' auth_permission_78 = importer.save_or_locate(auth_permission_78) auth_permission_79 = Permission() auth_permission_79.name = 'Can delete Board' auth_permission_79.content_type = ContentType.objects.get( app_label="mdm", model="boardmodel") auth_permission_79.codename = 'delete_boardmodel' auth_permission_79 = importer.save_or_locate(auth_permission_79) auth_permission_80 = Permission() auth_permission_80.name = 'Can view Board' auth_permission_80.content_type = ContentType.objects.get( app_label="mdm", model="boardmodel") auth_permission_80.codename = 'view_boardmodel' auth_permission_80 = importer.save_or_locate(auth_permission_80) auth_permission_81 = Permission() auth_permission_81.name = 'Can add Flight provider' auth_permission_81.content_type = ContentType.objects.get( app_label="mdm", model="flightprovidermodel") auth_permission_81.codename = 'add_flightprovidermodel' auth_permission_81 = importer.save_or_locate(auth_permission_81) auth_permission_82 = Permission() auth_permission_82.name = 'Can change Flight provider' auth_permission_82.content_type = ContentType.objects.get( app_label="mdm", model="flightprovidermodel") auth_permission_82.codename = 'change_flightprovidermodel' auth_permission_82 = importer.save_or_locate(auth_permission_82) auth_permission_83 = Permission() auth_permission_83.name = 'Can delete Flight provider' auth_permission_83.content_type = ContentType.objects.get( app_label="mdm", model="flightprovidermodel") auth_permission_83.codename = 'delete_flightprovidermodel' auth_permission_83 = importer.save_or_locate(auth_permission_83) auth_permission_84 = Permission() auth_permission_84.name = 'Can view Flight provider' auth_permission_84.content_type = ContentType.objects.get( app_label="mdm", model="flightprovidermodel") auth_permission_84.codename = 'view_flightprovidermodel' auth_permission_84 = importer.save_or_locate(auth_permission_84) auth_permission_85 = Permission() auth_permission_85.name = 'Can add Hotel' auth_permission_85.content_type = ContentType.objects.get( app_label="mdm", model="hotelmodel") auth_permission_85.codename = 'add_hotelmodel' auth_permission_85 = importer.save_or_locate(auth_permission_85) auth_permission_86 = Permission() auth_permission_86.name = 'Can change Hotel' auth_permission_86.content_type = ContentType.objects.get( app_label="mdm", model="hotelmodel") auth_permission_86.codename = 'change_hotelmodel' auth_permission_86 = importer.save_or_locate(auth_permission_86) auth_permission_87 = Permission() auth_permission_87.name = 'Can delete Hotel' auth_permission_87.content_type = ContentType.objects.get( app_label="mdm", model="hotelmodel") auth_permission_87.codename = 'delete_hotelmodel' auth_permission_87 = importer.save_or_locate(auth_permission_87) auth_permission_88 = Permission() auth_permission_88.name = 'Can view Hotel' auth_permission_88.content_type = ContentType.objects.get( app_label="mdm", model="hotelmodel") auth_permission_88.codename = 'view_hotelmodel' auth_permission_88 = importer.save_or_locate(auth_permission_88) auth_permission_89 = Permission() auth_permission_89.name = 'Can add Market' auth_permission_89.content_type = ContentType.objects.get( app_label="mdm", model="marketmodel") auth_permission_89.codename = 'add_marketmodel' auth_permission_89 = importer.save_or_locate(auth_permission_89) auth_permission_90 = Permission() auth_permission_90.name = 'Can change Market' auth_permission_90.content_type = ContentType.objects.get( app_label="mdm", model="marketmodel") auth_permission_90.codename = 'change_marketmodel' auth_permission_90 = importer.save_or_locate(auth_permission_90) auth_permission_91 = Permission() auth_permission_91.name = 'Can delete Market' auth_permission_91.content_type = ContentType.objects.get( app_label="mdm", model="marketmodel") auth_permission_91.codename = 'delete_marketmodel' auth_permission_91 = importer.save_or_locate(auth_permission_91) auth_permission_92 = Permission() auth_permission_92.name = 'Can view Market' auth_permission_92.content_type = ContentType.objects.get( app_label="mdm", model="marketmodel") auth_permission_92.codename = 'view_marketmodel' auth_permission_92 = importer.save_or_locate(auth_permission_92) auth_permission_93 = Permission() auth_permission_93.name = 'Can add Roomtype' auth_permission_93.content_type = ContentType.objects.get( app_label="mdm", model="roomtypemodel") auth_permission_93.codename = 'add_roomtypemodel' auth_permission_93 = importer.save_or_locate(auth_permission_93) auth_permission_94 = Permission() auth_permission_94.name = 'Can change Roomtype' auth_permission_94.content_type = ContentType.objects.get( app_label="mdm", model="roomtypemodel") auth_permission_94.codename = 'change_roomtypemodel' auth_permission_94 = importer.save_or_locate(auth_permission_94) auth_permission_95 = Permission() auth_permission_95.name = 'Can delete Roomtype' auth_permission_95.content_type = ContentType.objects.get( app_label="mdm", model="roomtypemodel") auth_permission_95.codename = 'delete_roomtypemodel' auth_permission_95 = importer.save_or_locate(auth_permission_95) auth_permission_96 = Permission() auth_permission_96.name = 'Can view Roomtype' auth_permission_96.content_type = ContentType.objects.get( app_label="mdm", model="roomtypemodel") auth_permission_96.codename = 'view_roomtypemodel' auth_permission_96 = importer.save_or_locate(auth_permission_96) auth_permission_97 = Permission() auth_permission_97.name = 'Can add Supplier' auth_permission_97.content_type = ContentType.objects.get( app_label="mdm", model="suppliermodel") auth_permission_97.codename = 'add_suppliermodel' auth_permission_97 = importer.save_or_locate(auth_permission_97) auth_permission_98 = Permission() auth_permission_98.name = 'Can change Supplier' auth_permission_98.content_type = ContentType.objects.get( app_label="mdm", model="suppliermodel") auth_permission_98.codename = 'change_suppliermodel' auth_permission_98 = importer.save_or_locate(auth_permission_98) auth_permission_99 = Permission() auth_permission_99.name = 'Can delete Supplier' auth_permission_99.content_type = ContentType.objects.get( app_label="mdm", model="suppliermodel") auth_permission_99.codename = 'delete_suppliermodel' auth_permission_99 = importer.save_or_locate(auth_permission_99) auth_permission_100 = Permission() auth_permission_100.name = 'Can view Supplier' auth_permission_100.content_type = ContentType.objects.get( app_label="mdm", model="suppliermodel") auth_permission_100.codename = 'view_suppliermodel' auth_permission_100 = importer.save_or_locate(auth_permission_100) auth_permission_101 = Permission() auth_permission_101.name = 'Can add session' auth_permission_101.content_type = ContentType.objects.get( app_label="sessions", model="session") auth_permission_101.codename = 'add_session' auth_permission_101 = importer.save_or_locate(auth_permission_101) auth_permission_102 = Permission() auth_permission_102.name = 'Can change session' auth_permission_102.content_type = ContentType.objects.get( app_label="sessions", model="session") auth_permission_102.codename = 'change_session' auth_permission_102 = importer.save_or_locate(auth_permission_102) auth_permission_103 = Permission() auth_permission_103.name = 'Can delete session' auth_permission_103.content_type = ContentType.objects.get( app_label="sessions", model="session") auth_permission_103.codename = 'delete_session' auth_permission_103 = importer.save_or_locate(auth_permission_103) auth_permission_104 = Permission() auth_permission_104.name = 'Can view session' auth_permission_104.content_type = ContentType.objects.get( app_label="sessions", model="session") auth_permission_104.codename = 'view_session' auth_permission_104 = importer.save_or_locate(auth_permission_104) auth_permission_105 = Permission() auth_permission_105.name = 'Can add site' auth_permission_105.content_type = ContentType.objects.get( app_label="sites", model="site") auth_permission_105.codename = 'add_site' auth_permission_105 = importer.save_or_locate(auth_permission_105) auth_permission_106 = Permission() auth_permission_106.name = 'Can change site' auth_permission_106.content_type = ContentType.objects.get( app_label="sites", model="site") auth_permission_106.codename = 'change_site' auth_permission_106 = importer.save_or_locate(auth_permission_106) auth_permission_107 = Permission() auth_permission_107.name = 'Can delete site' auth_permission_107.content_type = ContentType.objects.get( app_label="sites", model="site") auth_permission_107.codename = 'delete_site' auth_permission_107 = importer.save_or_locate(auth_permission_107) auth_permission_108 = Permission() auth_permission_108.name = 'Can view site' auth_permission_108.content_type = ContentType.objects.get( app_label="sites", model="site") auth_permission_108.codename = 'view_site' auth_permission_108 = importer.save_or_locate(auth_permission_108) # Processing model: django.contrib.auth.models.Group from django.contrib.auth.models import Group auth_group_1 = Group() auth_group_1.name = 'reviewer' auth_group_1 = importer.save_or_locate(auth_group_1) auth_group_1.permissions.add(auth_permission_57) auth_group_1.permissions.add(auth_permission_58) auth_group_1.permissions.add(auth_permission_59) auth_group_1.permissions.add(auth_permission_61) auth_group_1.permissions.add(auth_permission_62) auth_group_1.permissions.add(auth_permission_63) auth_group_1.permissions.add(auth_permission_65) auth_group_1.permissions.add(auth_permission_66) auth_group_1.permissions.add(auth_permission_67) auth_group_2 = Group() auth_group_2.name = 'contentmanager' auth_group_2 = importer.save_or_locate(auth_group_2) auth_group_3 = Group() auth_group_3.name = 'datarecorder' auth_group_3 = importer.save_or_locate(auth_group_3) auth_group_4 = Group() auth_group_4.name = 'analyst' auth_group_4 = importer.save_or_locate(auth_group_4) auth_group_5 = Group() auth_group_5.name = 'customer' auth_group_5 = importer.save_or_locate(auth_group_5) # Processing model: django.contrib.auth.models.User from django.contrib.auth.models import User auth_user_1 = User() auth_user_1.password = '******' auth_user_1.last_login = None auth_user_1.is_superuser = False auth_user_1.username = '******' auth_user_1.first_name = 'Customer' auth_user_1.last_name = 'Test' auth_user_1.email = '*****@*****.**' auth_user_1.is_staff = False auth_user_1.is_active = True auth_user_1.date_joined = dateutil.parser.parse( "2018-08-06T21:46:41+00:00") auth_user_1 = importer.save_or_locate(auth_user_1) auth_user_1.groups.add(auth_group_5) auth_user_2 = User() auth_user_2.password = '******' auth_user_2.last_login = None auth_user_2.is_superuser = False auth_user_2.username = '******' auth_user_2.first_name = 'Administrator' auth_user_2.last_name = 'Test' auth_user_2.email = '*****@*****.**' auth_user_2.is_staff = False auth_user_2.is_active = True auth_user_2.date_joined = dateutil.parser.parse( "2018-08-06T21:48:06+00:00") auth_user_2 = importer.save_or_locate(auth_user_2) auth_user_2.groups.add(auth_group_1) auth_user_2.groups.add(auth_group_2) auth_user_2.groups.add(auth_group_3) auth_user_3 = User() auth_user_3.password = '******' auth_user_3.last_login = dateutil.parser.parse( "2018-08-07T16:19:41.407710+00:00") auth_user_3.is_superuser = True auth_user_3.username = '******' auth_user_3.first_name = 'Gergely' auth_user_3.last_name = 'Kurinyecz' auth_user_3.email = '*****@*****.**' auth_user_3.is_staff = True auth_user_3.is_active = True auth_user_3.date_joined = dateutil.parser.parse( "2018-08-06T21:41:05+00:00") auth_user_3 = importer.save_or_locate(auth_user_3) auth_user_4 = User() auth_user_4.password = '******' auth_user_4.last_login = dateutil.parser.parse( "2018-08-28T17:31:53.948139+00:00") auth_user_4.is_superuser = True auth_user_4.username = '******' auth_user_4.first_name = 'László' auth_user_4.last_name = 'Hegedűs' auth_user_4.email = '*****@*****.**' auth_user_4.is_staff = True auth_user_4.is_active = True auth_user_4.date_joined = dateutil.parser.parse( "2018-08-06T21:37:42+00:00") auth_user_4 = importer.save_or_locate(auth_user_4)