Repository: carpentries/amy

Issue:
Use warning instead of error for missing eventbrite
I asked to validate one event and I got

![screenshot_2016-10-17_11-41-46](https://cloud.githubusercontent.com/assets/1506457/19434724/1a8d0392-945f-11e6-846f-aa32a805a8bb.png)

even if I have

```
eventbrite:    # optional (insert the alphanumeric key for Eventbrite registration, e.g., "1234567890AB")
```

Can we change the validate report to show a warning instead of a error?

Use warning instead of error for missing eventbrite
I asked to validate one event and I got

![screenshot_2016-10-17_11-41-46](https://cloud.githubusercontent.com/assets/1506457/19434724/1a8d0392-945f-11e6-846f-aa32a805a8bb.png)

even if I have

```
eventbrite:    # optional (insert the alphanumeric key for Eventbrite registration, e.g., "1234567890AB")
```

Can we change the validate report to show a warning instead of a error?



Discussion:

Resolving patch:
diff --git a/workshops/util.py b/workshops/util.py
--- a/workshops/util.py
+++ b/workshops/util.py
@@ -585,6 +585,7 @@ def parse_metadata_from_event_website(metadata):
 
 def validate_metadata_from_event_website(metadata):
     errors = []
+    warnings = []
 
     Requirement = namedtuple(
         'Requirement',
@@ -621,7 +622,8 @@ def validate_metadata_from_event_website(metadata):
         value_ = metadata.get(requirement.name)
 
         if value_ is None:
-            errors.append('Missing {} metadata {}.'.format(type_, name_))
+            issues = errors if required_ else warnings
+            issues.append('Missing {} metadata {}.'.format(type_, name_))
 
         if value_ == 'FIXME':
             errors.append('Placeholder value "FIXME" for {} metadata {}.'
@@ -639,7 +641,7 @@ def validate_metadata_from_event_website(metadata):
             except (re.error, TypeError):
                 pass
 
-    return errors
+    return errors, warnings
 
 
 def universal_date_format(date):
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -1018,11 +1018,13 @@ def validate_event(request, slug):
     page_url = page_url.strip()
 
     error_messages = []
+    warning_messages = []
 
     try:
         metadata = fetch_event_metadata(page_url)
         # validate metadata
-        error_messages = validate_metadata_from_event_website(metadata)
+        error_messages, warning_messages = \
+            validate_metadata_from_event_website(metadata)
 
     except WrongWorkshopURL as e:
         error_messages.append(str(e))
@@ -1042,6 +1044,7 @@ def validate_event(request, slug):
         'event': event,
         'page': page_url,
         'error_messages': error_messages,
+        'warning_messages': warning_messages,
     }
     return render(request, 'workshops/validate_event.html', context)
 


Test patch:
diff --git a/workshops/test/test_util.py b/workshops/test/test_util.py
--- a/workshops/test/test_util.py
+++ b/workshops/test/test_util.py
@@ -363,15 +363,18 @@ def test_validating_invalid_metadata(self):
             'contact': 'hermione@granger.co.uk, rweasley@ministry.gov',
             'eventbrite': 'bigmoney',
         }
-        errors = validate_metadata_from_event_website(metadata)
+        errors, warnings = validate_metadata_from_event_website(metadata)
         assert len(errors) == 7
+        assert not warnings
         assert all([error.startswith('Invalid value') for error in errors])
 
     def test_validating_missing_metadata(self):
         metadata = {}
-        errors = validate_metadata_from_event_website(metadata)
-        assert len(errors) == 12
-        assert all([error.startswith('Missing') for error in errors])
+        errors, warnings = validate_metadata_from_event_website(metadata)
+        assert len(errors) == 9  # There are nine required fields
+        assert len(warnings) == 3  # There are three optional fields
+        assert all([issue.startswith('Missing') 
+                    for issue in (errors + warnings)])
 
     def test_validating_empty_metadata(self):
         metadata = {
@@ -390,7 +393,8 @@ def test_validating_empty_metadata(self):
         }
         expected_errors = ['slug', 'startdate', 'country', 'latlng',
                            'instructor', 'helper', 'contact']
-        errors = validate_metadata_from_event_website(metadata)
+        errors, warnings = validate_metadata_from_event_website(metadata)
+        assert not warnings
         for error, key in zip(errors, expected_errors):
             self.assertIn(key, error)
 
@@ -409,8 +413,9 @@ def test_validating_default_metadata(self):
             'helper': 'FIXME',
             'contact': 'FIXME',
         }
-        errors = validate_metadata_from_event_website(metadata)
+        errors, warnings = validate_metadata_from_event_website(metadata)
         assert len(errors) == 12
+        assert not warnings
         assert all([
             error.startswith('Placeholder value "FIXME"')
             for error in errors
@@ -431,7 +436,8 @@ def test_validating_correct_metadata(self):
             'helper': 'Peter Parker, Tony Stark, Natasha Romanova',
             'contact': 'hermione@granger.co.uk, rweasley@ministry.gov',
         }
-        errors = validate_metadata_from_event_website(metadata)
+        errors, warnings = validate_metadata_from_event_website(metadata)
+        assert not warnings
         assert not errors
 
     def test_no_attribute_error_missing_instructors_helpers(self):