(cls, linked_domain, master_domain, remote_details=None)
return link
With the GAing of linked projects in the form of ERM/MRM, this will become an internal method in favor
        of the link_domains method in linked_domain/views.py to allow for proper validation of domain and user
        privileges before creating any links
With the GAing of linked projects in the form of ERM/MRM, this will become an internal method in favor
        of the link_domains method in linked_domain/views.py to allow for proper validation of domain and user
        privileges before creating any links
With the GAing of linked projects in the form of ERM / MRM this will become an internal method in favor of the link_domains method in linked_domain / views . py to allow for proper validation of domain and user privileges before creating any links
def link_domains(cls, linked_domain, master_domain, remote_details=None):
        """
        With the GAing of linked projects in the form of ERM/MRM, this will become an internal method in favor
        of the link_domains method in linked_domain/views.py to allow for proper validation of domain and user
        privileges before creating any links
        """
        existing_links = cls.all_objects.filter(linked_domain=linked_domain)
        active_links_with_other_domains = [
            domain_link for domain_link in existing_links
            if not domain_link.deleted and domain_link.master_domain != master_domain
        ]
        if active_links_with_other_domains:
            already_linked_domain = active_links_with_other_domains[0].master_domain
            raise DomainLinkError(
                _('{} is already a downstream project space of {}.\nYou must remove the existing link before '
                  'creating this new link.').format(linked_domain, already_linked_domain)
            )

        deleted_existing_links = [
            domain_link for domain_link in existing_links
            if domain_link.deleted and domain_link.master_domain == master_domain
        ]
        active_links_with_this_domain = [
            domain_link for domain_link in existing_links
            if not domain_link.deleted and domain_link.master_domain == master_domain
        ]

        if deleted_existing_links:
            # if there was a deleted link, just undelete it
            link = deleted_existing_links[0]
            link.deleted = False
        elif active_links_with_this_domain:
            # if there is already an active link, just update it with the new information
            link = active_links_with_this_domain[0]
        else:
            link = DomainLink(linked_domain=linked_domain, master_domain=master_domain)

        if remote_details:
            link.remote_base_url = remote_details.url_base
            link.remote_username = remote_details.username
            link.remote_api_key = remote_details.api_key

        link.save()
        return link
def link_domains ( cls , linked_domain , master_domain , remote_details = None ) : existing_links = cls . all_objects . filter ( linked_domain = linked_domain ) active_links_with_other_domains = [ domain_link for domain_link in existing_links if not domain_link . deleted and domain_link . master_domain != master_domain ] if active_links_with_other_domains : already_linked_domain = active_links_with_other_domains [ 0 ] . master_domain raise DomainLinkError ( _ ( '{} is already a downstream project space of {}.\nYou must remove the existing link before ' 'creating this new link.' ) . format ( linked_domain , already_linked_domain ) ) deleted_existing_links = [ domain_link for domain_link in existing_links if domain_link . deleted and domain_link . master_domain == master_domain ] active_links_with_this_domain = [ domain_link for domain_link in existing_links if not domain_link . deleted and domain_link . master_domain == master_domain ] if deleted_existing_links : # if there was a deleted link, just undelete it link = deleted_existing_links [ 0 ] link . deleted = False elif active_links_with_this_domain : # if there is already an active link, just update it with the new information link = active_links_with_this_domain [ 0 ] else : link = DomainLink ( linked_domain = linked_domain , master_domain = master_domain ) if remote_details : link . remote_base_url = remote_details . url_base link . remote_username = remote_details . username link . remote_api_key = remote_details . api_key link . save ( ) return link