Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vgrange/contact modes #306

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

vgrange/contact modes #306

wants to merge 2 commits into from

Conversation

dejafait
Copy link
Contributor

No description provided.

@dejafait
Copy link
Contributor Author

dejafait commented Jan 2, 2019

review stp @regisb

FTR il me reste encore à valider/compléter avec les métiers les wordings de CONTACT_MODE_LABELS et CONTACT_MODE_STEPS


from labonneboite.common import encoding as encoding_util
from labonneboite.common import scoring as scoring_util
from labonneboite.common import hiring_type_util
from labonneboite.common.contact_mode import (CONTACT_MODE_MAIL, CONTACT_MODE_EMAIL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pas ouf de faire plein d'imports comme ça. Il vaut mieux importer directement le module : from labonneboite.common.contact_mode.

En fait, ces imports sont réalisés dans plusieurs modules différents. Du coup, est-ce que ça ne vaut pas la pein de créer quelques fonctions utilitaires dans labonneboite.common.contact_mode ?

@property
def recommended_contact_mode_label(self):
try:
return CONTACT_MODE_LABELS[self.recommended_contact_mode]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return CONTACT_MODE_LABELS.get(self.recommended_contact_mode, '')

@@ -17,7 +17,7 @@


def has_text_content(s):
return s is not None and len(s) > 0 and not s.isspace()
return s and s.strip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On pourrait utiliser cette fonction dans pas mal d'endroits pour simplifier le code. A déplacer dans un module utils.py peut-être ?

# office has a contact_mode suggesting email and has data
office = Office()
office.contact_mode = 'Contactez nous par mail'
office.email = '[email protected]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce que ça t'embête de remplacer tous les "pouac" et "plonk" par autre chose stp ? Ce sont les mots clés que j'utilise quand je débugge, et j'ai des git hooks pour être sûr de ne jamais envoyer "pouac" en prod.

('phone', 'Contactez l\'entreprise par téléphone'),
)
CONTACT_MODES = dict(CONTACT_MODES_ITEMS)
# FIXME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi FIXME?

elif self.website and self.website.strip():
return CONTACT_MODE_WEBSITE
else:
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je suggère de faire un peu de DNRY:

addresses = {
    CONTACT_MODE_EMAIL: self.email,
    CONTACT_MODE_PHONE: self.tel,
    CONTACT_MODE_WEBSITE: self.website,
}
if has_text_content(self.contact_mode):
    for contact_mode, keywords in CONTACT_MODE_KEYWORDS.items():
        for keyword in keywords:
            if keyword in self.contact_mode:
                if contact_mode not in addresses:
                    return contact_mode
                address = addresses.get(contact_mode)
                if has_text_content(address):
                    return contact_mode

for contact_mode in [CONTACT_MODE_EMAIL, CONTACT_MODE_PHONE, CONTACT_MODE.WEBSITE]:
    if has_text_content(addresses[contact_mode]):
        return contact_mode

@regisb regisb assigned dejafait and unassigned regisb Jan 7, 2019
@dejafait dejafait removed their assignment May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants