コード例 #1
0
 def create_profile():
     """Creates a new profile for the agents"""
     try:
         profile = Profile.objects.get(name="Agente")
     except Profile.DoesNotExist:
         profile = Profile()
         profile.name = "Agente"
         profile.active = True
         profile.save()
     return profile
コード例 #2
0
    def create_admin_profile():
        try:
            admin_profile = Profile.objects.get(name="ADMINISTRADOR")
        except Profile.DoesNotExist:
            admin_profile = Profile()
            admin_profile.name = "ADMINISTRADOR"
            admin_profile.active = True
            admin_profile.save()

        actions = Action.objects.all()
        for action in actions:
            try:
                permission = ProfilePermissions.objects.get(
                    profile=admin_profile.id, action=action.id)
            except ProfilePermissions.DoesNotExist:
                permission = ProfilePermissions()
                permission.profile = admin_profile
                permission.action = action

            permission.permission = True
            permission.save()
        Command.create_admin_user(admin_profile)