link.user
Privilege()
Bases: BipObject
Privilege Bip object.
Privileges are used for handling permissions within applications.
Attributes:
Name | Type | Description |
---|---|---|
uid |
str
|
Bip unique identifier (uuid4). Edition is forbidden if this is an existing (recorded in database) entity. |
slug |
str
|
Human-readable unique identifier. |
name |
str
|
Name of the privilege. |
Source code in client/bip/link/user.py
441 442 443 444 445 |
|
save()
Saves a Privilege
object.
If the object is not floating (exists in the database) and has not been modified, nothing will be done.
If floating, the uid is automatically generated.
If not specified, the unique slug is automatically generated from the name.
Raises:
Type | Description |
---|---|
ValueError
|
|
Source code in client/bip/link/user.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
|
Role()
Bases: BipObject
Role Bip object.
Attributes:
Name | Type | Description |
---|---|---|
uid |
str
|
Bip unique identifier (uuid4). Edition if forbidden is this is an existing (recorded in database) entity. |
slug |
str
|
Human-readable unique identifier. |
name |
str
|
Name of the role. |
plural |
str
|
Plural of the role. |
Source code in client/bip/link/user.py
513 514 515 516 517 518 |
|
save()
Saves a Role
object.
If the object is not floating (exists in the database) and has not been modified, nothing will be done.
If floating, the uid is automatically generated.
If not specified, the unique slug is automatically generated from the name.
Raises:
Type | Description |
---|---|
ValueError
|
|
Source code in client/bip/link/user.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
|
User()
Bases: BipObject
User Bip object.
Attributes:
Name | Type | Description |
---|---|---|
uid |
str
|
Bip unique identifier (uuid4). Edition is forbidden if this is an existing (recorded in database) entity. |
slug |
str
|
Human-readable unique identifier. |
first_name |
str
|
First name of the user. |
last_name |
str
|
Last name of the user. |
username |
str
|
The username is used for logging into Bip. |
password |
str
|
Hashed password. |
email |
str
|
Email address of the user. |
messaging_link |
str
|
Messaging url. It can be a direct messaging url from Slack, Rocket.Chat, Mattermost... |
initials |
str
|
Two capital letters ( |
active |
bool
|
True if active, False if inactive user. |
last_announcement_seen |
str
|
Identifier of the last announcement seen (uuid4). |
is_new |
bool
|
Helper value for determining if a user has never used their account yet. |
last_tip_day |
str
|
Date when the last tip has been seen ( |
role |
Role
|
Bip role object. |
privilege |
privilege
|
Bip privilege object. |
Source code in client/bip/link/user.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
cached_project_uid: str
property
Active project uid.
This value is cached when the User object is retrieved, since the active project must be gotten from an additional and expensive request.
Helper property for internal needs (avoids massive queries).
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Bip unique identifier (uuid4). |
deleted: bool
property
Is the user a ghost data.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True is the user is a ghost (kept for database consistency), False if the user is enabled. |
full_name
property
str: space-joined first name and last name.
last_hostname
property
str: Machine hostname where the user has used Bip for the last time.
last_seen
property
str: Date and time when the user has used Bip for the last time (%d/%m/%Y %H:%M:%S).
last_version_used
property
Last version of Bip used.
Returns:
Name | Type | Description |
---|---|---|
str |
Formatted like |
recent_connections
property
list: List of data from the last ten connections.
Each dict has the following keys:
- hostname
(str): Machine
- date
(str): Date and time (%d/%m/%Y %H:%M:%S)
- version
(str): Bip version (vX.X.X)
add_recent_connection(hostname, date, version)
Adds a recent connection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hostname |
str
|
Machine name. |
required |
date |
str
|
Date and time. Must be formatted like: |
required |
version |
str
|
Bip version. Must be formatted like: |
required |
Todo
- Check date formatting
- Check version formatting
Source code in client/bip/link/user.py
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 265 |
|
clear_active_project()
Clears the user's active project.
Note
Object method for link.user.clear_active_project(user)
.
Source code in client/bip/link/user.py
288 289 290 291 292 293 294 |
|
delete()
Deletes a user.
Note
Bip does not delete users in order to keep existing data relationship consistent. Instead, the user is marked as deleted. The username becomes available again.
Source code in client/bip/link/user.py
220 221 222 223 224 225 226 227 228 229 230 231 |
|
get(username=None, active_only=False)
classmethod
Gets all users or gets one user by username.
If username is left to None, all users are returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
Looked up username. Defaults to |
None
|
active_only |
bool
|
Show only active users. Defaults to |
False
|
Returns:
Name | Type | Description |
---|---|---|
list |
If |
|
User |
If `username is set, and a match has bee found, a user object. |
|
bool |
False otherwise. |
Source code in client/bip/link/user.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
get_active_project()
Gets the user's active project.
Note
Object method for link.user.get_active_project(user)
.
Source code in client/bip/link/user.py
272 273 274 275 276 277 278 |
|
save()
Saves a User
object.
If the object is not floating (exists in the database) and has not been modified, nothing will be done.
If floating, the uid is automatically generated.
If not specified, the unique slug is automatically generated from the name.
Raises:
Type | Description |
---|---|
ValueError
|
|
Source code in client/bip/link/user.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 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 |
|
set_active_project(project)
Sets the user's active project.
Note
Object method for link.user.set_active_project(user, project)
.
Source code in client/bip/link/user.py
280 281 282 283 284 285 286 |
|
set_password(clear_password)
Sets a hashed and secured password from a clear string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clear_password |
str
|
Non-hashed password |
required |
Source code in client/bip/link/user.py
296 297 298 299 300 301 302 303 |
|
clear_active_project(user)
Clears the active project of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
User
|
User that must have their active project cleared. |
required |
Source code in client/bip/link/user.py
801 802 803 804 805 806 807 |
|
clear_announcement_views()
Clears the announcement views.
If an announcement is currently active, set it as seen for all of the users, even if they have not seen it already.
Source code in client/bip/link/user.py
838 839 840 841 842 843 844 |
|
force_welcome_tutorial()
Forces to display the welcome tutorial for all users.
Sets the is_new
attribute of all users to True
, which would
triggers the "newcomers" procedures in the various Bip applications.
Source code in client/bip/link/user.py
847 848 849 850 851 852 853 |
|
get(username=None, active_only=False)
Gets all users or gets one user by username.
If username is left to None, all users are returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
Looked up username. Defaults to |
None
|
active_only |
bool
|
Show only active users. Defaults to |
False
|
Returns:
Name | Type | Description |
---|---|---|
list |
If |
|
User |
If `username is set, and a match has bee found, a user object. |
|
bool |
False otherwise. |
Source code in client/bip/link/user.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
|
get_active_project(user)
Get the active project of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
User
|
User that must have their active project retrieved. |
required |
Returns:
Name | Type | Description |
---|---|---|
Project |
Active project. |
|
bool |
False if no active project is set for this user. |
Source code in client/bip/link/user.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
|
get_all_project_referents(project)
Get all the referents of a given project.
Referents are users who have a specific role in a project.
The referent scopes can be: - IT - Lead - Production - Pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
Project
|
A Bip project. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
pairs of referent type ( |
Source code in client/bip/link/user.py
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 |
|
get_by_username(username)
Get user by username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
Looked up username. |
required |
Returns:
Name | Type | Description |
---|---|---|
User |
If a match has been found, a user object. |
|
bool |
False otherwise. |
Source code in client/bip/link/user.py
602 603 604 605 606 607 608 609 610 611 612 |
|
get_current(force=False)
Gets the currently logged-in user.
The credentials' validity is automatically checked.
Returns:
Name | Type | Description |
---|---|---|
User |
A user object if successful. |
|
bool |
False otherwise. |
Source code in client/bip/link/user.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
|
get_current_user(force=False)
Alias for link.user.get_current()
Source code in client/bip/link/user.py
656 657 658 |
|
get_privilege(slug=None, uid=None)
Get a privilege by name or uid.
At least one parameter (slug or uid) must be specified. If both are specified, the slug is used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slug |
str
|
Looked-up slug. |
None
|
uid |
str
|
Looked-up uid. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Privilege |
A privilege object if successful. |
|
bool |
False otherwise. |
Raises:
Type | Description |
---|---|
ValueError
|
If no slug nor uid are specified. |
Source code in client/bip/link/user.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
|
get_privileges()
Get all privileges.
But don't forget to seize all the means of production. ✊
Returns:
Name | Type | Description |
---|---|---|
list |
Collection of |
Source code in client/bip/link/user.py
661 662 663 664 665 666 667 668 669 |
|
get_project_referent(project, referent_type)
Gets a project referent per type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
Project
|
Project to get the referent from. |
required |
referent_type |
str
|
Targeted type.
Value can be:
- |
required |
Returns:
Type | Description |
---|---|
|
|
|
Source code in client/bip/link/user.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 |
|
get_role(slug=None, uid=None)
Get a role by name or uid.
At least one parameter (slug or uid) must be specified. If both are specified, the slug is used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slug |
str
|
Looked-up slug. |
None
|
uid |
str
|
Looked-up uid. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Role |
A role object if successful. |
|
bool |
False otherwise. |
Raises:
Type | Description |
---|---|
ValueError
|
If no slug nor uid are specified. |
Source code in client/bip/link/user.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
|
get_roles()
Get all roles.
Returns:
Name | Type | Description |
---|---|---|
list |
Collection of |
Source code in client/bip/link/user.py
694 695 696 697 698 699 700 |
|
new(username, password, first_name, last_name, privilege, role, auto_save=True, **kwargs)
Creates a user and saves it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username is used for logging into Bip. Must only contain alphanumerical characters, dashes, dots and underscores. |
required |
password |
str
|
Clear password. |
required |
first_name |
str
|
First name of the user. |
required |
last_name |
str
|
Last name of the user. |
required |
privilege |
Privilege
|
Bip privilege object. |
required |
role |
Role
|
Bip role object. |
required |
initials |
str
|
Two capital letters. |
required |
Returns:
Name | Type | Description |
---|---|---|
User |
The generated user. |
Source code in client/bip/link/user.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
|
new_privilege(name, slug=None, auto_save=True)
Creates a privilege and saves it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the privilege. |
required |
slug |
str
|
If unspecified, the slug is generated automatically from the name. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Privilege |
The generated privilege. |
Source code in client/bip/link/user.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
|
new_role(name, plural=None, slug=None, auto_save=True)
Creates a role and saves it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the role. |
required |
plural |
str
|
If unspecified, a "s" is added to the name. |
None
|
slug |
str
|
If unspecified, the slug is generated automatically from the name. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Role |
The generated role. |
Source code in client/bip/link/user.py
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
|
new_user(username, password, first_name, last_name, privilege, role, auto_save=True, **kwargs)
Convenience alias for link.user.new()
Source code in client/bip/link/user.py
746 747 748 749 750 751 752 |
|
reset_announcement_views()
Resets the announcement views.
If an announcement is currently active, set it as unseen for all of the users, even if they have seen it already.
Source code in client/bip/link/user.py
829 830 831 832 833 834 835 |
|
set_active_project(user, project)
Sets the active project of a user.
Active project is the default/current user's project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
User
|
User that must have their active project changed. |
required |
project |
Project
|
New active project. |
required |
Source code in client/bip/link/user.py
788 789 790 791 792 793 794 795 796 797 798 |
|
set_project_referent(project, user, referent_type)
Sets a project referent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
Project
|
Project to get the referent from. |
required |
user |
User
|
Assigned user. |
required |
referent_type |
str
|
Targeted type.
Value can be:
- |
required |
Source code in client/bip/link/user.py
903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
|