Users Table
users/users.py¶
This class is used to import the auxilary tables into the primary table
UsersDB ¶
UsersDB(dburi='localhost/tm_admin')
Bases: DBSupport
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dburi |
str
|
The URI string for the database connection |
'localhost/tm_admin'
|
Returns:
Type | Description |
---|---|
UsersDB
|
An instance of this class |
Source code in tm_admin/users/users.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
mergeInterests
async
¶
mergeInterests(inpg)
Merge the user_interests table from the Tasking Manager
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inpg |
PostgresClient
|
The input database |
required |
Source code in tm_admin/users/users.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 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 169 170 171 172 173 174 175 176 177 178 179 |
|
mergeLicenses
async
¶
mergeLicenses(inpg)
Merge data from the TM user_licenses table into TM Admin. The fastest way to do a bulk update of a table is by copying the remote database table into the local database, and then merging into a new temporary table and then renaming it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inpg |
PostgresClient
|
The input database |
required |
Source code in tm_admin/users/users.py
181 182 183 184 185 186 187 188 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 260 261 262 263 264 |
|
mergeAuxTables
async
¶
mergeAuxTables(inuri, outuri)
Merge more tables from TM into the unified users table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inuri |
str
|
The input database |
required |
outuri |
str
|
The output database |
required |
Source code in tm_admin/users/users.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
interestsThread
async
¶
interestsThread(interests, db)
Thread to handle importing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interests |
list
|
The list of records to import |
required |
db |
PostgresClient
|
A database connection |
required |
Source code in tm_admin/users/users.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
favoritesThread
async
¶
favoritesThread(favorites, db)
Thread to handle importing favorites
Parameters:
Name | Type | Description | Default |
---|---|---|---|
favorites |
list
|
The list of records to import |
required |
db |
PostgresClient
|
A database connection |
required |
Source code in tm_admin/users/users.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
main
async
¶
main()
This main function lets this class be run standalone by a bash script.
Source code in tm_admin/users/users.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
|
options: show_source: false heading_level: 3
users/users_class.py¶
options: show_source: false heading_level: 3
users/api.py¶
UsersAPI ¶
UsersAPI()
Bases: PGSupport
Source code in tm_admin/users/api.py
61 62 63 64 65 |
|
initialize
async
¶
initialize(inuri)
Connect to all tables for API endpoints that require accessing multiple tables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inuri |
str
|
The URI for the TM Admin output database |
required |
Source code in tm_admin/users/api.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
getByID
async
¶
getByID(user_id)
Get all the information for a user using it's ID
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The user to get the data for |
required |
Returns:
Type | Description |
---|---|
dict
|
the user information |
Source code in tm_admin/users/api.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
getByName
async
¶
getByName(name)
Get all the information for a project using the name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The project to get the data for |
required |
Returns:
Type | Description |
---|---|
dict
|
the project information |
Source code in tm_admin/users/api.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
getRole
async
¶
getRole(user_id)
Get the role for a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The user's ID |
required |
Returns:
Type | Description |
---|---|
Userrole
|
The user's role |
Source code in tm_admin/users/api.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
getBlocked
async
¶
getBlocked(user_id)
Get the role for a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The user's ID |
required |
Returns:
Type | Description |
---|---|
bool
|
If the user is blocked or not |
Source code in tm_admin/users/api.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
updateMappingLevel
async
¶
updateMappingLevel(id, level)
Update the mapping level for a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The users ID. |
required |
level |
Mappinglevel
|
The new level. |
required |
Source code in tm_admin/users/api.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
updateExpert
async
¶
updateExpert(id, mode)
Toggle the expert mode for a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The users ID. |
required |
mode |
bool
|
The new mode.. |
required |
Source code in tm_admin/users/api.py
172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
getRegistered
async
¶
getRegistered(start, end)
Get all users registered in this timeframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
datetime
|
The starting timestamp |
required |
end |
datetime
|
The starting timestamp |
required |
Returns:
Type | Description |
---|---|
list
|
The users registered in this timeframe. |
Source code in tm_admin/users/api.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
getFavoriteProjects
async
¶
getFavoriteProjects(user_id)
Get the data for a users favorite projects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The user to get the favorites for |
required |
Returns:
Type | Description |
---|---|
list
|
A list of the projects data |
Source code in tm_admin/users/api.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
getPagedUsers
async
¶
getPagedUsers(
paged,
count,
username=None,
user_id=None,
role=None,
level=None,
)
Get paged list of all usernames using either the user ID or a partial username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
paged |
bool
|
Whether to page the results |
required |
count |
int
|
The number of entries in the page |
required |
username |
str
|
The partial user name |
None
|
user_id |
int
|
The user ID |
None
|
role |
Userrole
|
The user's role |
None
|
level |
Mappinglevel
|
The users mapping level |
None
|
Returns:
Type | Description |
---|---|
list
|
The users matching the query |
Source code in tm_admin/users/api.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
getFilterUsers
async
¶
getFilterUsers(
username, page=10, project_id=None, close=False
)
" Get paged lists of users matching OpenStreetMap using either the user ID or a partial username. The cursor gets closed when the class destructs, or by specifying the close parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The partial user name |
required |
page |
int
|
How many records in each page |
10
|
project_id |
int
|
Optional project ID |
None
|
close |
bool
|
Whether to close the cursor to restart from the beginning. |
False
|
Returns:
Type | Description |
---|---|
list
|
The users matching the query |
Source code in tm_admin/users/api.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
getLockedTasks
async
¶
getLockedTasks(username=None, user_id=None)
Gets any locked tasks on the project for the logged in user using either the user ID or a partial username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The partial user name |
None
|
user_id |
int
|
The ID of the logged in user |
None
|
Returns:
Type | Description |
---|---|
list
|
The task IDs this user has locked |
Source code in tm_admin/users/api.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
getStats
async
¶
getStats(username=None, user_id=None)
Get detailed statistics about a user using either the user ID or a partial username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The partial user name |
None
|
user_id |
int
|
The ID of the logged in user |
None
|
Returns:
Type | Description |
---|---|
UserStats
|
The statistics for this user |
Source code in tm_admin/users/api.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
getInterestsStats
async
¶
getInterestsStats(username=None, user_id=None)
Get rate of contributions from a user given their interests using either the user ID or a partial username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The partial user name |
None
|
user_id |
int
|
The ID of the logged in user |
None
|
Returns:
Type | Description |
---|---|
int
|
The rate of contributions |
Source code in tm_admin/users/api.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
getAllStats
async
¶
getAllStats(start, end)
Get rate of contributions from a user given their interests using either the user ID or a partial username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
datetime
|
The starting timestamp |
required |
end |
datetime
|
The ending timestamp |
required |
Returns:
Type | Description |
---|---|
list
|
A list of the stats for the users in this time frame |
Source code in tm_admin/users/api.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
getInteracts
async
¶
getInteracts(
tstatus,
pstatus,
project_id,
start,
end,
sort,
page=10,
username=None,
user_id=None,
)
Get a list of tasks a user has interacted with using either the user ID or a partial username.
Sort criteria is action_date or project_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The partial user name |
None
|
user_id |
int
|
The ID of the logged in user |
None
|
tstatus |
Taskstatus
|
The status of the task |
required |
pstatus |
Projectstatus
|
The status of the project |
required |
project_id |
int
|
The project ID |
required |
start |
datetime
|
The starting timestamp |
required |
end |
datetime
|
The ending timestamp |
required |
sort |
str
|
The column to use for sorting the results |
required |
page |
int
|
How many records in each page |
10
|
Returns:
Type | Description |
---|---|
list
|
FIXME! a list of task data ? |
Source code in tm_admin/users/api.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
main
async
¶
main()
This main function lets this class be run standalone by a bash script.
Source code in tm_admin/users/api.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|
options: show_source: false heading_level: 3