Skip to content

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
def __init__(self):
    super(Privilege, self).__init__()
    self.uid = None
    self.slug = None
    self.name = None

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
  • The name is empty.
  • The slug already exists.
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
def save(self):
    """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:
        ValueError:
            - The name is empty.
            - The slug already exists.
    """
    if not self._is_modified and self.uid:
        return

    if not self.uid:
        self._generate_uid()

    self._validate()

    sink.user.save_privilege(self.to_dict())

    self._sink()

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
def __init__(self):
    super(Role, self).__init__()
    self.uid = None
    self.slug = None
    self.name = None
    self.plural = None

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
  • The name is empty.
  • The slug already exists.
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
def save(self):
    """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:
        ValueError:
            - The name is empty.
            - The slug already exists.
    """
    if not self._is_modified and self.uid:
        return

    if not self.uid:
        self._generate_uid()

    self._validate()

    sink.user.save_role(self.to_dict())

    self._sink()

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 (XX). Convenient identifier that can be used in filenames for instance.

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 (%d/%m/%Y).

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
def __init__(self):
    super(User, self).__init__()
    self.uid = None
    self.slug = None
    self.first_name = None
    self.last_name = None
    self.username = None
    self.password = None
    self.email = None
    self.messaging_link = None
    self.initials = None
    self.active = True
    self.last_announcement_seen = None
    self.is_new = True
    self.last_tip_day = None
    self._deleted = None

    self.role = Role
    self.privilege = Privilege

    self._recent_connections = None
    self._active_project_uid = None

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 vX.X.X.

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: %d/%m/%Y %H:%M:%S.

required
version str

Bip version. Must be formatted like: vX.X.X.

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
def add_recent_connection(self, hostname, date, version):
    """Adds a recent connection.

    Args:
        hostname (str): Machine name.
        date (str): Date and time. Must be formatted like: `%d/%m/%Y %H:%M:%S`.
        version (str): Bip version. Must be formatted like: `vX.X.X`.

    Todo:
        - Check date formatting
        - Check version formatting
    """
    limit = 10

    connections = self.recent_connections

    data = {"hostname": hostname, "date": date, "version": version}

    if hostname in [c["hostname"] for c in connections]:
        for index, value in enumerate(connections):
            if value["hostname"] == hostname:
                connections[index] = data
    else:
        connections.append(data)

    connections = sorted(connections, key=lambda i: i["date"], reverse=True)
    connections = connections[:limit]

    for c in connections:
        c["date"] = c["date"].strftime(DATE_FORMAT)

    serialized_connections = json.dumps(connections)
    self._recent_connections = serialized_connections

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
def clear_active_project(self):
    """Clears the user's active project.

    Note:
        Object method for `link.user.clear_active_project(user)`.
    """
    return clear_active_project(self)

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
@permission("delete_user")
def delete(self):
    """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.

    """
    self._deleted = True
    self.save()

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.

None
active_only bool

Show only active users. Defaults to False.

False

Returns:

Name Type Description
list

If username is not set, list of User objects.

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
@classmethod
@permission("read_user")
def get(cls, username=None, active_only=False):
    """Gets all users or gets one user by username.

    If username is left to None, all users are returned.

    Args:
        username (str, optional): Looked up username. Defaults to `None`.
        active_only (bool): Show only active users. Defaults to `False`.

    Returns:
        list: If `username` is not set, list of `User` objects.
        User: If `username is set, and a match has bee found, a user object.
        bool: False otherwise.
    """
    if username:
        return get_by_username(username)

    users = sink.user.get_all()
    users = [cls.from_dict(u) for u in users]

    if active_only:
        filtered_users = []
        for user in users:
            if user.active:
                filtered_users.append(user)
        return filtered_users

    return users

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
def get_active_project(self):
    """Gets the user's active project.

    Note:
        Object method for `link.user.get_active_project(user)`.
    """
    return get_active_project(self)

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
  • The first name is empty.
  • The last name is empty.
  • The username contains illegal characters.
  • The username already exists.
  • The role is not set.
  • The privilege is not set.
  • The initials are empty.
  • The initials are not in capital.
  • The initials are not two-letters long.
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
def save(self):
    """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:
        ValueError:
            - The first name is empty.
            - The last name is empty.
            - The username contains illegal characters.
            - The username already exists.
            - The role is not set.
            - The privilege is not set.
            - The initials are empty.
            - The initials are not in capital.
            - The initials are not two-letters long.
    """
    if not self._is_modified and self.uid:
        return

    if not self.uid:
        self._generate_uid()

    if not self.slug:
        # Exceptionally, no need to check for uniqueness
        # since the slug is based on the username, which
        # must be unique anyway.
        slug = slugify(self.username)
        self.slug = slug

    # Re-enables welcome tutorial for inactive users
    # Commented out because for now, producers won't think
    # about re-enabling a user if the freelancer comes back
    # if not user.active:
    #     user.is_new = True

    self._validate()

    sink.user.save(self.to_dict())

    was_floating = self.is_floating
    self._sink()

    if was_floating:
        try:
            execute_routine("user", CREATE, user=self)
        except Exception as e:
            self.delete()
            raise e

        try:
            plugin.apply_all_default_settings(user=self)
        except Exception as e:
            self.delete()
            raise e

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
def set_active_project(self, project):
    """Sets the user's active project.

    Note:
        Object method for `link.user.set_active_project(user, project)`.
    """
    return set_active_project(self, project)

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
def set_password(self, clear_password):
    """Sets a hashed and secured password from a clear string.

    Args:
        clear_password (str): Non-hashed password
    """
    full_hash = _hash_password(clear_password)
    self.password = full_hash

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
def clear_active_project(user):
    """Clears the active project of a user.

    Args:
        user (User): User that must have their active project cleared.
    """
    sink.user.clear_active_project(user.to_dict())

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
def 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."""
    sink.user.clear_announcement_views()

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
def 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.
    """
    sink.user.force_welcome_tutorial()

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.

None
active_only bool

Show only active users. Defaults to False.

False

Returns:

Name Type Description
list

If username is not set, list of User objects.

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
def 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.

    Args:
        username (str, optional): Looked up username. Defaults to `None`.
        active_only (bool): Show only active users. Defaults to `False`.

    Returns:
        list: If `username` is not set, list of `User` objects.
        User: If `username is set, and a match has bee found, a user object.
        bool: False otherwise.
    """
    return User.get(username, active_only)

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
def get_active_project(user):
    """Get the active project of a user.

    Args:
        user (User): User that must have their active project retrieved.

    Returns:
        Project: Active project.
        bool: False if no active project is set for this user.
    """
    uid = sink.user.get_active_project_uid(user.to_dict())
    if uid:
        from .project import get_project

        return get_project(uid=uid)
    else:
        return False

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 (str) with user (`User').

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
def 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

    Args:
        project (Project): A Bip project.

    Returns:
        dict: pairs of referent type (`str`) with user (`User').
    """
    users = sink.user.get_all_project_referents(project.to_dict())
    if users:
        return {type_: User.from_dict(user) for type_, user in users.items()}
    else:
        return {}

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
def get_by_username(username):
    """Get user by username.

    Args:
        username (str): Looked up username.

    Returns:
        User: If a match has been found, a user object.
        bool: False otherwise.
    """
    return User.get_by_username(username)

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
def get_current(force=False):
    """Gets the currently logged-in user.

    The credentials' validity is automatically checked.

    Returns:
        User: A user object if successful.
        bool: False otherwise.

    """
    global current_user

    username, password = get_login()
    if not username or not password:
        current_user = None
        raise ValueError("There is no Bip user logged in on this machine.")

    if not current_user or force:
        try:
            found_user = get_by_username(username)
        except LookupError:
            found_user = None

        if not found_user:
            raise ValueError(
                f"Invalid username stored in authentication file: {username}."
            )

        if not _check_hash(found_user, password):
            raise ValueError(f"Invalid password hash for {username}.")

        current_user = found_user

    return current_user

get_current_user(force=False)

Alias for link.user.get_current()

Source code in client/bip/link/user.py
656
657
658
def get_current_user(force=False):
    """Alias for `link.user.get_current()`"""
    return get_current(force)

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
def 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.

    Args:
        slug (str): Looked-up slug.
        uid (str): Looked-up uid.

    Returns:
        Privilege: A privilege object if successful.
        bool: False otherwise.

    Raises:
        ValueError: If no slug nor uid are specified.
    """
    result = sink.user.get_privilege(slug, uid)
    if result:
        return Privilege.from_dict(result)

get_privileges()

Get all privileges.

But don't forget to seize all the means of production. ✊

Returns:

Name Type Description
list

Collection of Privilege objects.

Source code in client/bip/link/user.py
661
662
663
664
665
666
667
668
669
def get_privileges():
    """Get all privileges.

    But don't forget to seize all the means of production. ✊

    Returns:
        list: Collection of `Privilege` objects.
    """
    return [Privilege.from_dict(u) for u in sink.user.get_privileges()]

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: - it - production - lead - pipeline

required

Returns:

Type Description
  • User: Found referent if defined.
  • bool: False otherwise.
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
def get_project_referent(project, referent_type):
    """Gets a project referent per type.

    Args:
        project (Project): Project to get the referent from.
        referent_type (str): Targeted type.
            Value can be:
                - `it`
                - `production`
                - `lead`
                - `pipeline`

    Returns:
        - User: Found referent if defined.
        - bool: False otherwise.
    """
    data = sink.user.get_project_referent(project.to_dict(), referent_type)
    if data:
        return User.from_dict(data)
    else:
        return False

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
def 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.

    Args:
        slug (str): Looked-up slug.
        uid (str): Looked-up uid.

    Returns:
        Role: A role object if successful.
        bool: False otherwise.

    Raises:
        ValueError: If no slug nor uid are specified.
    """
    return Role.get(slug, uid)

get_roles()

Get all roles.

Returns:

Name Type Description
list

Collection of Role objects.

Source code in client/bip/link/user.py
694
695
696
697
698
699
700
def get_roles():
    """Get all roles.

    Returns:
        list: Collection of `Role` objects.
    """
    return Role.get()

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
def new(
    username, password, first_name, last_name, privilege, role, auto_save=True, **kwargs
):
    """Creates a user and saves it.

    Args:
        username (str): The username is used for logging into Bip.
            Must only contain alphanumerical characters, dashes, dots and underscores.
        password (str): Clear password.
        first_name (str): First name of the user.
        last_name (str): Last name of the user.
        privilege (Privilege): Bip privilege object.
        role (Role): Bip role object.
        initials (str): Two capital letters.

    Returns:
        User: The generated user.
    """
    return User.generate(
        username, password, first_name, last_name, privilege, role, auto_save, **kwargs
    )

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
def new_privilege(name, slug=None, auto_save=True):
    """Creates a privilege and saves it.

    Args:
        name (str): The name of the privilege.
        slug (str, optional): If unspecified, the slug is generated automatically from the name.

    Returns:
        Privilege: The generated privilege.
    """
    privilege = Privilege.generate(name, slug)
    if auto_save:
        privilege.save()
    return privilege

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
def new_role(name, plural=None, slug=None, auto_save=True):
    """Creates a role and saves it.

    Args:
        name (str): The name of the role.
        plural (str, optional): If unspecified, a "s" is added to the name.
        slug (str, optional): If unspecified, the slug is generated automatically from the name.

    Returns:
        Role: The generated role.
    """
    role = Role.generate(name, plural, slug)
    if role:
        role.save()
    return role

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
def new_user(
    username, password, first_name, last_name, privilege, role, auto_save=True, **kwargs
):
    """Convenience alias for `link.user.new()`"""
    return new(
        username, password, first_name, last_name, privilege, role, auto_save, **kwargs
    )

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
def 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."""
    sink.user.reset_announcement_views()

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
def set_active_project(user, project):
    """Sets the active project of a user.

    Active project is the default/current user's project.

    Args:
        user (User): User that must have their active project changed.
        project (Project): New active project.
    """
    sink.user.set_active_project(user.to_dict(), project.to_dict())
    plugin.apply_all_default_settings(user, project)

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: - it - production - lead - pipeline

required
Source code in client/bip/link/user.py
903
904
905
906
907
908
909
910
911
912
913
914
915
916
def set_project_referent(project, user, referent_type):
    """Sets a project referent.

    Args:
        project (Project): Project to get the referent from.
        user (User): Assigned user.
        referent_type (str): Targeted type.
            Value can be:
                - `it`
                - `production`
                - `lead`
                - `pipeline`
    """
    sink.user.set_project_referent(project.to_dict(), user.to_dict(), referent_type)