-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from lookit/208-ui-improvements-study-edit-ki…
…m-review 208 ui improvements study edit kim review
- Loading branch information
Showing
5 changed files
with
72 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,19 +33,36 @@ def clean(self): | |
return cleaned_data | ||
|
||
|
||
# Form for editing an existing study | ||
class StudyEditForm(BaseStudyForm): | ||
# Form for creating a new study or editing an existing study | ||
class StudyForm(BaseStudyForm): | ||
|
||
structure = forms.CharField(label='Build Study - Add JSON', | ||
widget=AceOverlayWidget(mode='json', wordwrap=True, theme='textmate', width='100%', | ||
height='100%', showprintmargin=False), required=False, | ||
help_text='Add the frames of your study as well as the sequence of those frames. This can be added later.') | ||
|
||
def clean_structure(self): | ||
structure = self.cleaned_data['structure'] | ||
try: | ||
json_data = json.loads(structure) # loads string as json | ||
except: | ||
raise forms.ValidationError("Save failed due to invalid JSON! Please use valid JSON and save again. If you reload this page, all changes will be lost.") | ||
return json_data | ||
|
||
class Meta: | ||
model = Study | ||
fields = ['name', 'image', 'short_description', 'long_description', 'exit_url', 'criteria', 'min_age_days', 'min_age_months', 'min_age_years', 'max_age_days', 'max_age_months', 'max_age_years', 'duration', 'contact_info', 'public'] | ||
fields = ['name', 'image', 'short_description', 'long_description', 'exit_url', | ||
'criteria', 'min_age_days', 'min_age_months', 'min_age_years', 'max_age_days', | ||
'max_age_months', 'max_age_years', 'duration', 'contact_info', 'public', | ||
'structure', 'study_type'] | ||
labels = { | ||
'short_description': 'Short Description', | ||
'long_description': 'Purpose', | ||
'exit_url': 'Exit URL', | ||
'criteria': 'Participant Eligibility', | ||
'contact_info': 'Researcher Contact Information', | ||
'public': 'Discoverable - Do you want this study to be publicly discoverable on Lookit once activated?' | ||
'public': 'Discoverable - Do you want this study to be publicly discoverable on Lookit once activated?', | ||
'study_type': 'Study Type' | ||
} | ||
widgets = { | ||
'short_description': Textarea(attrs={'rows': 2}), | ||
|
@@ -62,53 +79,24 @@ class Meta: | |
'short_description': 'Give your study a description here.', | ||
'long_description': 'Explain the purpose of your study here.', | ||
'contact_info': 'This should give the name of the PI for your study, and an email address where the PI or study staff can be reached with questions. Format: PIs Name (contact: [email protected])', | ||
'criteria': 'Text shown to families - this is not used to actually verify eligibility.' | ||
'criteria': 'Text shown to families - this is not used to actually verify eligibility.', | ||
'study_type': '''<p>After selecting a study type above, you'll be asked | ||
to fill out some study type metadata as well. This metadata is unique to the | ||
study type, and provides important configurations for building your study.</p> | ||
<p>If you're not sure what to enter here, just leave the defaults (you can change this later).</p> | ||
<p>For more information on study types and their metadata, please | ||
<a href="https://lookit.readthedocs.io/en/develop/experimenter.html#editing-study-type">see the documentation.</a></p>''' | ||
} | ||
|
||
|
||
# Form for creating a new study. Set study_type and structure in same form | ||
# in this case, rather than separately in the build form. | ||
class StudyForm(StudyEditForm): | ||
structure = forms.CharField(label='Build Study - Add JSON', widget=AceOverlayWidget(mode='json', wordwrap=True, theme='textmate', width='100%', height='100%', showprintmargin=False), required=False, help_text='Add the frames of your study as well as the sequence of those frames. This can be added later.') | ||
|
||
def clean_structure(self): | ||
structure = self.cleaned_data['structure'] | ||
try: | ||
json_data = json.loads(structure) # loads string as json | ||
except: | ||
raise forms.ValidationError("Save failed due to invalid JSON! Please use valid JSON and save again. If you reload this page, all changes will be lost.") | ||
return json_data | ||
|
||
class Meta(StudyEditForm.Meta): | ||
fields = StudyEditForm.Meta.fields + ['structure', 'study_type'] | ||
|
||
labels = StudyEditForm.Meta.labels.copy() | ||
labels['study_type'] = 'Study Type' | ||
|
||
help_texts = StudyEditForm.Meta.help_texts.copy() | ||
help_texts['study_type'] = "Specify the build process as well as the parameters needed by the experiment builder. If you don't know what this is, just select the default." | ||
|
||
|
||
class StudyUpdateForm(StudyEditForm): | ||
structure = forms.CharField(label='Build Study - Add JSON', | ||
widget=AceOverlayWidget(mode='json', wordwrap=True, theme='textmate', width='100%', | ||
height='100%', showprintmargin=False), required=False, | ||
help_text='Add the frames of your study as well as the sequence of those frames. This can be added later.') | ||
|
||
def clean_structure(self): | ||
structure = self.cleaned_data['structure'] | ||
try: | ||
json_data = json.loads(structure) # loads string as json | ||
except: | ||
raise forms.ValidationError("Save failed due to invalid JSON! Please use valid JSON and save again. If you reload this page, all changes will be lost.") | ||
return json_data | ||
|
||
class Meta(StudyEditForm.Meta): | ||
fields = StudyEditForm.Meta.fields + ['structure'] | ||
|
||
labels = StudyEditForm.Meta.labels.copy() | ||
|
||
help_texts = StudyEditForm.Meta.help_texts.copy() | ||
class StudyEditForm(StudyForm): | ||
|
||
class Meta(StudyForm.Meta): | ||
help_texts = StudyForm.Meta.help_texts.copy() | ||
help_texts['study_type'] += '''<p class="help-block"> Once you've filled in the required metadata, you'll have to build the dependencies for your | ||
experiment in order to deploy it, which you can do from the detail page. However, you'll | ||
probably want to see what your experiment looks like before you actually deploy it and start | ||
collecting data! You can do that by clicking the "Build Preview Dependencies" button and | ||
then clicking on "See Preview" above after the build finishes.</p>''' | ||
|
||
|
||
class StudyBuildForm(forms.ModelForm): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters