model
mlte/user/model.py
Model implementation for a User.
RESOURCE_ALL_VALUES = '*'
module-attribute
Special character used to identify all values of a certain permission.
BasicUser
Bases: BaseModel
A model class representing a user of the system
Source code in mlte/user/model.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
disabled = False
class-attribute
instance-attribute
Whether the user is disabled.
email = None
class-attribute
instance-attribute
An optional email associated to the user.
full_name = None
class-attribute
instance-attribute
The full name of the user.
groups = []
class-attribute
instance-attribute
The groups the user is in.
role = RoleType.REGULAR
class-attribute
instance-attribute
The role associated to the user.
username
instance-attribute
The username to uniquely identify a user.
is_equal_to(user, only_group_names=True, ignore_groups=False)
Compares users at the BasicUser level.
Source code in mlte/user/model.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
Group
Bases: BaseModel
A user group to which permissions are associated.
Source code in mlte/user/model.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
name
instance-attribute
The name of the group.
permissions = []
class-attribute
instance-attribute
The permissions associated to the group.
get_group_names(groups)
staticmethod
Given a list of groups, returns a similar list with groups that only contain their names.
Source code in mlte/user/model.py
180 181 182 183 184 185 186 |
|
MethodType
Bases: StrEnum
Types of methods for permissions.
Source code in mlte/user/model.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
ANY = 'any'
class-attribute
instance-attribute
Special action to represent all/any of them.
DELETE = 'delete'
class-attribute
instance-attribute
Deletion action.
GET = 'get'
class-attribute
instance-attribute
Get or read action.
POST = 'post'
class-attribute
instance-attribute
Creation action.
PUT = 'put'
class-attribute
instance-attribute
Action to edit.
Permission
Bases: BaseModel
Permissions for manipulating resources.
Source code in mlte/user/model.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
SEPARATOR_REPLACEMENT = '___'
class-attribute
Used when serializing to string.
method = MethodType.ANY
class-attribute
instance-attribute
The HTTP method applied on the resource.
resource_id = None
class-attribute
instance-attribute
The specific resource id to give permissions to, if any.
resource_type
instance-attribute
The type of resource resource.
from_str(permission_str)
staticmethod
Creates a permission from its string serialization.
Source code in mlte/user/model.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
grants_access(request)
Checks if this permission grants access to the recieved request.
Source code in mlte/user/model.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
to_str()
Serialize the permission to a string
Source code in mlte/user/model.py
205 206 207 208 209 210 |
|
ResourceType
Bases: StrEnum
Supported resource types.
Source code in mlte/user/model.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
CATALOG = 'catalog'
class-attribute
instance-attribute
Test catalogs.
CUSTOM_LIST = 'custom_list'
class-attribute
instance-attribute
Custom lists.
GROUP = 'group'
class-attribute
instance-attribute
Group resources.
MODEL = 'model'
class-attribute
instance-attribute
Model and all related artifacts.
USER = 'user'
class-attribute
instance-attribute
User resources.
get_type_from_url(url)
staticmethod
Returns the resource type for the given URL.
Source code in mlte/user/model.py
160 161 162 163 164 165 166 167 168 |
|
RoleType
Bases: StrEnum
Roles for users.
Source code in mlte/user/model.py
24 25 26 27 28 29 30 31 |
|
ADMIN = 'admin'
class-attribute
instance-attribute
An admin role, access to everything.
REGULAR = 'regular'
class-attribute
instance-attribute
A role with access to artifacts only.
User
Bases: BasicUser
User with additional information only used locally when stored.
Source code in mlte/user/model.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
hashed_password
instance-attribute
The hashed password of the user.
update_user_data(new_user_data)
Update this user, but keeping existing hashed password.
Source code in mlte/user/model.py
82 83 84 85 86 87 88 89 |
|
UserWithPassword
Bases: BasicUser
User with additional information only used when creating a user.
Source code in mlte/user/model.py
92 93 94 95 96 97 98 99 100 101 102 103 |
|
password
instance-attribute
The plain password of the user.
to_hashed_user()
Converts a UserWithPassword model with plain password into a User with a hashed one.
Source code in mlte/user/model.py
98 99 100 101 102 103 |
|
update_user_data(curr_user, new_user_data)
Get updated user depending on the type, keeping hashed password if no new password is received.
Source code in mlte/user/model.py
106 107 108 109 110 111 112 113 114 115 |
|