mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-16 11:20:12 -04:00
Post to the API when moving folders and templates
This commit adds logic to: - take the list of selected folders and templates - split it into two lists (of folders and templates) - `POST` that data to the API, to effect the movement of said folders and templates I’ve tried to architect it in such a way that we can easily add more template ‘operations’ in the future, as we add more forms to the choose template page.
This commit is contained in:
@@ -702,7 +702,7 @@ class ServicePostageForm(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
|
||||
class BrandingStyle(RadioField):
|
||||
class RadioFieldWithNoneOption(RadioField):
|
||||
|
||||
def post_validate(self, form, validation_stopped):
|
||||
if self.data == 'None':
|
||||
@@ -711,7 +711,7 @@ class BrandingStyle(RadioField):
|
||||
|
||||
class ServiceSetBranding(StripWhitespaceForm):
|
||||
|
||||
branding_style = BrandingStyle(
|
||||
branding_style = RadioFieldWithNoneOption(
|
||||
'Branding style',
|
||||
validators=[
|
||||
DataRequired()
|
||||
@@ -1124,7 +1124,7 @@ class TemplateAndFoldersSelectionForm(Form):
|
||||
|
||||
ALL_TEMPLATES_FOLDER = {
|
||||
'name': 'All templates',
|
||||
'id': None,
|
||||
'id': 'None',
|
||||
}
|
||||
|
||||
def __init__(
|
||||
@@ -1151,8 +1151,8 @@ class TemplateAndFoldersSelectionForm(Form):
|
||||
def ids_and_names(items, exclude=None):
|
||||
return [
|
||||
(item['id'], item['name']) for item in items
|
||||
if item['id'] != exclude
|
||||
if item['id'] != str(exclude)
|
||||
]
|
||||
|
||||
templates_and_folders = MultiCheckboxField('Choose templates or folders')
|
||||
move_to = RadioField('Choose a folder')
|
||||
move_to = RadioFieldWithNoneOption('Choose a folder')
|
||||
|
||||
Reference in New Issue
Block a user