Skip to content

Commit

Permalink
Fix errors (circular imports)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Mar 13, 2024
1 parent 85949d0 commit 7266e82
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
8 changes: 3 additions & 5 deletions lemarche/utils/apis/api_brevo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from huey.contrib.djhuey import task
from sib_api_v3_sdk.rest import ApiException

from lemarche.siaes.models import Siae
from lemarche.users.models import User
from lemarche.utils.urls import get_object_admin_url, get_object_share_url


Expand All @@ -27,7 +25,7 @@ def get_api_client():
return sib_api_v3_sdk.ApiClient(config)


def create_contact(user: User, list_id: int):
def create_contact(user, list_id: int):
api_client = get_api_client()
api_instance = sib_api_v3_sdk.ContactsApi(api_client)
new_contact = sib_api_v3_sdk.CreateContact(
Expand All @@ -51,7 +49,7 @@ def create_contact(user: User, list_id: int):
logger.error(f"Exception when calling Brevo->ContactsApi->create_contact: {e}")


def remove_contact_from_list(user: User, list_id: int):
def remove_contact_from_list(user, list_id: int):
api_client = get_api_client()
api_instance = sib_api_v3_sdk.ContactsApi(api_client)
contact_emails = sib_api_v3_sdk.RemoveContactFromList(emails=[user.email])
Expand All @@ -67,7 +65,7 @@ def remove_contact_from_list(user: User, list_id: int):
logger.error(f"Exception when calling Brevo->ContactsApi->remove_contact_from_list: {e}")


def create_or_update_company(siae: Siae):
def create_or_update_company(siae):
"""
Brevo docs:
- Python library: https://github.com/sendinblue/APIv3-python-library/blob/master/docs/CompaniesApi.md
Expand Down
7 changes: 2 additions & 5 deletions lemarche/utils/apis/api_hubspot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
from hubspot import Client
from hubspot.crm.contacts import ApiException, SimplePublicObject, SimplePublicObjectInput

from lemarche.tenders.models import Tender
from lemarche.users.models import User


# from huey.contrib.djhuey import task

Expand Down Expand Up @@ -85,7 +82,7 @@ def add_to_contacts(
logger.info("Hubspot: not add contact to the crm (STAGING or TEST environment detected)")


def add_user_to_crm(user: User):
def add_user_to_crm(user):
result = add_to_contacts(
email=user.email,
company=user.company_name,
Expand All @@ -100,7 +97,7 @@ def add_user_to_crm(user: User):


# @task
def create_deal_from_tender(tender: Tender):
def create_deal_from_tender(tender):
tender_author_hubspot_contact_id = tender.author.hubspot_contact_id
if not tender_author_hubspot_contact_id:
user_added_in_crm = add_user_to_crm(tender.author)
Expand Down
9 changes: 4 additions & 5 deletions lemarche/utils/apis/api_mailjet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from huey.contrib.djhuey import task

from lemarche.users import constants as user_constants
from lemarche.users.models import User
from lemarche.utils.emails import EMAIL_SUBJECT_PREFIX


Expand Down Expand Up @@ -36,17 +35,17 @@ def get_default_client(params={}):
return client


def get_mailjet_cl_on_signup(user: User, source: str = user_constants.SOURCE_SIGNUP_FORM):
if user.kind == user.KIND_SIAE:
def get_mailjet_cl_on_signup(user, source: str = user_constants.SOURCE_SIGNUP_FORM):
if user.kind == user_constants.KIND_SIAE:
return settings.MAILJET_NL_CL_SIAE_ID
elif user.kind == user.KIND_BUYER:
elif user.kind == user_constants.KIND_BUYER:
if source == user_constants.SOURCE_SIGNUP_FORM:
return settings.MAILJET_NL_CL_BUYER_ID
elif source == user_constants.SOURCE_TALLY_FORM:
return settings.MAILJET_NL_CL_BUYER_TALLY_ID
elif source == user_constants.SOURCE_TENDER_FORM:
return settings.MAILJET_NL_CL_BUYER_TENDER_ID
elif user.kind == user.KIND_PARTNER:
elif user.kind == user_constants.KIND_PARTNER:
if user.partner_kind == user_constants.PARTNER_KIND_FACILITATOR:
return settings.MAILJET_NL_CL_PARTNER_FACILITATORS_ID
elif user.partner_kind in (
Expand Down
3 changes: 1 addition & 2 deletions lemarche/utils/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from huey.contrib.djhuey import task

from lemarche.users import constants as user_constants
from lemarche.users.models import User
from lemarche.utils.apis import api_brevo, api_hubspot, api_mailjet


Expand All @@ -29,7 +28,7 @@ def whitelist_recipient_list(recipient_list):
return [email for email in recipient_list if (email and email.endswith("beta.gouv.fr"))]


def add_to_contact_list(user: User, type: str, source: str = user_constants.SOURCE_SIGNUP_FORM):
def add_to_contact_list(user, type: str, source: str = user_constants.SOURCE_SIGNUP_FORM):
"""Add user to contactlist
Args:
Expand Down

0 comments on commit 7266e82

Please sign in to comment.