From 74764a526b61fe9a20d1ba9c27e800ffad07e762 Mon Sep 17 00:00:00 2001 From: Aleksandra Nenadic Date: Fri, 14 Oct 2016 15:50:33 +0100 Subject: [PATCH] Fixed test and documentation for contact paremeter. --- bin/workshop_check.py | 23 ++++++++++++++++------- index.html | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bin/workshop_check.py b/bin/workshop_check.py index d3051bf..819d839 100755 --- a/bin/workshop_check.py +++ b/bin/workshop_check.py @@ -203,15 +203,23 @@ def check_helpers(helpers): @look_for_fixme -def check_email(email): +def check_emails(emails): """ - 'contact' must be a valid email address consisting of characters, - an '@', and more characters. It should not be the default contact + 'contact' must be a comma-separated list of valid email addresses. + The list may be empty. A valid email address consists of characters, + an '@', and more characters. It should not contain the default contact email address 'admin@software-carpentry.org'. """ - return bool(re.match(EMAIL_PATTERN, email)) and \ - (email != DEFAULT_CONTACT_EMAIL) + # YAML automatically loads list-like strings as lists. + if (isinstance(emails, list) and len(emails) >= 0): + for email in emails: + if ((not bool(re.match(EMAIL_PATTERN, email))) or (email == DEFAULT_CONTACT_EMAIL)): + return False + else: + return False + + return True def check_eventbrite(eventbrite): @@ -286,8 +294,9 @@ HANDLERS = { 'helper list isn\'t a valid list of format ' + '["First helper", "Second helper",..]'), - 'contact': (True, check_email, - 'contact email invalid or still set to ' + + 'contact': (True, check_emails, + 'contact email list isn\'t a valid list of format ' + + '["me@example.org", "you@example.org",..] or contains incorrectly formatted email addresses or ' + '"{0}".'.format(DEFAULT_CONTACT_EMAIL)), 'eventbrite': (False, check_eventbrite, 'Eventbrite key appears invalid'), diff --git a/index.html b/index.html index d8e81b7..c33cc7c 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@ startdate: FIXME # machine-readable start date for the workshop in YYYY-MM- enddate: FIXME # machine-readable end date for the workshop in YYYY-MM-DD format like 2015-01-02 instructor: ["FIXME"] # boxed, comma-separated list of instructors' names as strings, like ["Kay McNulty", "Betty Jennings", "Betty Snyder"] helper: ["FIXME"] # boxed, comma-separated list of helpers' names, like ["Marlyn Wescoff", "Fran Bilas", "Ruth Lichterman"] -contact: ["FIXME"] # boxed, comma-separated list of contact email addresses for host, lead instructor, or whoever else is handling questions, like ["marlyn.wescoff@example.org", "fran.bilas@example.org", "ruth.lichterman@example.org"] +contact: ["fixme@example.org"] # boxed, comma-separated list of contact email addresses for the host, lead instructor, or whoever else is handling questions, like ["marlyn.wescoff@example.org", "fran.bilas@example.org", "ruth.lichterman@example.org"] etherpad: # optional: URL for the workshop Etherpad if there is one eventbrite: # optional: alphanumeric key for Eventbrite registration, e.g., "1234567890AB" (if Eventbrite is being used) ---