Repository: carpentries/amy

Issue:
Hide section for survey results
We've used a couple of different survey tools - this was requested in an earlier iteration of survey tools.  We're not recording these here now so I'd like to hide this from the view until we decide what to do.



Discussion:
@maneesha hide in the event edit form or on the event details page or both?

Both


Resolving patch:
diff --git a/workshops/forms.py b/workshops/forms.py
--- a/workshops/forms.py
+++ b/workshops/forms.py
@@ -3,7 +3,8 @@
 from captcha.fields import ReCaptchaField
 from crispy_forms.bootstrap import FormActions
 from crispy_forms.helper import FormHelper
-from crispy_forms.layout import Layout, Div, HTML, Submit, Reset
+from crispy_forms.layout import Layout, Div, HTML, Submit, Reset, Field
+from crispy_forms.bootstrap import AccordionGroup, Accordion
 from django import forms
 from django.core.exceptions import ValidationError
 from django.core.validators import RegexValidator
@@ -340,37 +341,34 @@ class EventForm(forms.ModelForm):
     admin_fee = forms.DecimalField(min_value=0, decimal_places=2,
                                    required=False, widget=TextInput)
 
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-        self.fields['slug'].widget.attrs['placeholder'] = 'YYYY-MM-DD-location'
-        self.fields['start'].widget.attrs['placeholder'] = 'YYYY-MM-DD'
-        self.fields['end'].widget.attrs['placeholder'] = 'YYYY-MM-DD'
-
-        self.helper = BootstrapHelper(self)
-
-        idx_start = self.helper['country'].slice[0][0][0]
-        idx_end = self.helper['longitude'].slice[0][0][0]
-        # wrap all venue fields within <div class='panel-body'>
-        self.helper[idx_start:idx_end + 1] \
-            .wrap_together(Div, css_class='panel-body')
-        # wrap <div class='panel-body'> within <div class='panel panel-…'>
-        self.helper[idx_start].wrap_together(Div,
-                                             css_class='panel panel-default')
-        # add <div class='panel-heading'>Loc. details</div> inside "div.panel"
-        self.helper.layout[idx_start].insert(0, Div(HTML('Location details'),
-                                                    css_class='panel-heading'))
-
-        id_learners_pre = self.helper['learners_pre'].slice[0][0][0]
-        id_learners_longterm = self.helper['learners_longterm'].slice[0][0][0]
-        # wrap all survey fields within <div class='panel-body'>
-        self.helper[id_learners_pre:id_learners_longterm + 1] \
-            .wrap_together(Div, css_class='panel-body')
-        # wrap <div class='panel-body'> within <div class='panel panel-…'>
-        self.helper[id_learners_pre].wrap_together(
-            Div, css_class='panel panel-default')
-        # add <div class='panel-heading'>Venue details</div> inside "div.panel"
-        self.helper.layout[id_learners_pre].insert(
-            0, Div(HTML('Survey results'), css_class='panel-heading'))
+    helper = BootstrapHelper()
+    helper.layout = Layout(
+        Field('slug', placeholder='YYYY-MM-DD-location'),
+        'completed',
+        Field('start', placeholder='YYYY-MM-DD'),
+        Field('end', placeholder='YYYY-MM-DD'),
+        'host',
+        'administrator',
+        'assigned_to',
+        'tags',
+        'url',
+        'language',
+        'reg_key',
+        'admin_fee',
+        'invoice_status',
+        'attendance',
+        'contact',
+        'notes',
+        Accordion(
+            AccordionGroup('Location details',
+                'country',
+                'venue',
+                'address',
+                'latitude',
+                'longitude',
+            ),
+        ),
+    )
 
     def clean_slug(self):
         # Ensure slug is in "YYYY-MM-DD-location" format
@@ -393,17 +391,10 @@ def clean_end(self):
 
     class Meta:
         model = Event
-        # reorder fields, don't display 'deleted' field
         fields = ('slug', 'completed', 'start', 'end', 'host', 'administrator',
-                  'assigned_to', 'tags', 'url', 'language', 'reg_key',
+                  'assigned_to', 'tags', 'url', 'language', 'reg_key', 'venue',
                   'admin_fee', 'invoice_status', 'attendance', 'contact',
-                  'notes', 'country', 'venue', 'address', 'latitude',
-                  'longitude', 'learners_pre', 'learners_post',
-                  'instructors_pre', 'instructors_post', 'learners_longterm')
-
-        # WARNING: don't change put any fields between 'country' and
-        #          'longitude' that don't relate to the venue of the event
-
+                  'notes', 'country', 'address', 'latitude', 'longitude', )
         widgets = {
             'attendance': TextInput,
             'latitude': TextInput,


Test patch: