Skip to content

Commit

Permalink
Merge pull request #25 from johncronan/dev
Browse files Browse the repository at this point in the history
admin to customize the form status message
  • Loading branch information
johncronan authored Apr 28, 2022
2 parents e4d5058 + 66f8f58 commit bf4f779
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion formative/forms/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ class FormAdminForm(AdminJSONForm):
widget=widgets.AdminRadioSelect(attrs={'class': 'radiolist'})
)
hidden = forms.BooleanField(required=False)
enabled_message = forms.CharField(required=False,
widget=widgets.AdminTextInputWidget,
help_text='If not specified, default is "Open for submissions."'
)
disabled_message = forms.CharField(required=False,
widget=widgets.AdminTextInputWidget,
help_text='If not specified, default is "Not yet open for submissions."'
)
completed_message = forms.CharField(required=False,
widget=widgets.AdminTextInputWidget,
help_text='If not specified, default is "Closed."'
)
access_enable = forms.CharField(required=False, label='?access= password')
review_pre = forms.CharField(
required=False, widget=widgets.AdminTextareaWidget(attrs={'rows': 5}),
Expand Down Expand Up @@ -390,7 +402,8 @@ class FormAdminForm(AdminJSONForm):
class Meta:
static_fields = ('program', 'name', 'slug', 'status', 'hidden')
json_fields = {'options': [
'hidden', 'access_enable', 'review_pre', 'review_post',
'hidden', 'enabled_message', 'disabled_message',
'completed_message', 'access_enable', 'review_pre', 'review_post',
'submitted_review_pre', 'timed_completion', 'complete_submit_time',
'no_review_after_submit', 'thanks', 'emails'
]}
Expand Down
6 changes: 6 additions & 0 deletions formative/models/formative.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,15 @@ def status_message(self):
if self.status == self.Status.DRAFT:
return 'NA'
elif self.status == self.Status.DISABLED:
if 'disabled_message' in self.options:
return self.options['disabled_message']
return _('Not yet open for submissions')
elif self.status == self.Status.COMPLETED:
if 'completed_message' in self.options:
return self.options['completed_message']
return _('Closed')
if 'enabled_message' in self.options:
return self.options['enabled_message']
return _('Open for submissions')

def hidden(self):
Expand Down

0 comments on commit bf4f779

Please sign in to comment.