Show checkboxes for users with permission to view the managed folder

This commit is contained in:
Pea Tyczynska
2019-03-15 14:13:27 +00:00
parent 077a533d81
commit 1ab36dd026
4 changed files with 38 additions and 10 deletions

View File

@@ -1285,6 +1285,15 @@ class ReturnedLettersForm(StripWhitespaceForm):
class TemplateFolderForm(StripWhitespaceForm):
def __init__(self, users_with_permission=None, *args, **kwargs):
super().__init__(*args, **kwargs)
if users_with_permission is not None:
self.viewing_permissions.users_with_permission = users_with_permission
self.viewing_permissions.choices = [
(item.id, item.name) for item in users_with_permission
]
viewing_permissions = MultiCheckboxField('Users who can see this folder:')
name = StringField('Folder name', validators=[DataRequired(message='Cant be empty')])

View File

@@ -430,9 +430,13 @@ def action_blocked(service_id, notification_type, return_to, template_id):
@login_required
@user_has_permissions('manage_templates')
def manage_template_folder(service_id, template_folder_id):
current_folder = current_service.get_template_folder(template_folder_id)
users_with_folder_permission = [
current_service.get_team_member(user_id) for user_id in current_folder['users_with_permission']
]
form = TemplateFolderForm(
name=current_service.get_template_folder(template_folder_id)['name']
name=current_folder['name'],
users_with_permission=users_with_folder_permission
)
if form.validate_on_submit():
@@ -449,7 +453,7 @@ def manage_template_folder(service_id, template_folder_id):
template_folder_path=current_service.get_template_folder_path(template_folder_id),
current_service_id=current_service.id,
template_folder_id=template_folder_id,
template_type="all"
template_type="all",
)