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