Show More
@@ -66,30 +66,25 b' class AuthnPluginViewBase(object):' | |||
|
66 | 66 | |
|
67 | 67 | return html |
|
68 | 68 | |
|
69 | def settings_get(self): | |
|
69 | def settings_get(self, errors={}): | |
|
70 | 70 | """ |
|
71 | 71 | View that displays the plugin settings as a form. |
|
72 | 72 | """ |
|
73 | form_defaults = {} | |
|
74 | validation_errors = None | |
|
75 | 73 | schema = self.plugin.get_settings_schema() |
|
76 | 74 | |
|
77 | 75 | # Get default values for the form. |
|
78 | 76 | for node in schema.children: |
|
79 |
value = self.plugin.get_setting_by_name(node.name) |
|
|
80 | form_defaults[node.name] = value | |
|
77 | value = self.plugin.get_setting_by_name(node.name) | |
|
78 | if value: | |
|
79 | node.default = value | |
|
81 | 80 | |
|
82 | 81 | template_context = { |
|
82 | 'errors': errors, | |
|
83 | 'plugin': self.context.plugin, | |
|
83 | 84 | 'resource': self.context, |
|
84 | 'plugin': self.context.plugin | |
|
85 | 85 | } |
|
86 | 86 | |
|
87 | return Response(self._render_and_fill( | |
|
88 | 'rhodecode:templates/admin/auth/plugin_settings.html', | |
|
89 | template_context, | |
|
90 | self.request, | |
|
91 | form_defaults, | |
|
92 | validation_errors)) | |
|
87 | return template_context | |
|
93 | 88 | |
|
94 | 89 | def settings_post(self): |
|
95 | 90 | """ |
@@ -100,24 +95,11 b' class AuthnPluginViewBase(object):' | |||
|
100 | 95 | valid_data = schema.deserialize(self.request.params) |
|
101 | 96 | except colander.Invalid, e: |
|
102 | 97 | # Display error message and display form again. |
|
103 | form_defaults = self.request.params | |
|
104 | validation_errors = e.asdict() | |
|
105 | 98 | self.request.session.flash( |
|
106 | 99 | _('Errors exist when saving plugin settings. ' |
|
107 | 100 |
|
|
108 | 101 | queue='error') |
|
109 | ||
|
110 | template_context = { | |
|
111 | 'resource': self.context, | |
|
112 | 'plugin': self.context.plugin | |
|
113 | } | |
|
114 | ||
|
115 | return Response(self._render_and_fill( | |
|
116 | 'rhodecode:templates/admin/auth/plugin_settings.html', | |
|
117 | template_context, | |
|
118 | self.request, | |
|
119 | form_defaults, | |
|
120 | validation_errors)) | |
|
102 | return self.settings_get(errors=e.asdict()) | |
|
121 | 103 | |
|
122 | 104 | # Store validated data. |
|
123 | 105 | for name, value in valid_data.items(): |
General Comments 0
You need to be logged in to leave comments.
Login now