diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 1efad34..cf7fed6 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -71,10 +71,10 @@ {% endmacro %} -{% macro render_field_in_row(field, after="") %} +{% macro render_field_in_row(field, after="", readonly=False) %} {{ field.label }} - {{ field(class="form-control")|safe }} + {{ field(class="form-control", readonly=readonly)|safe }} {% if after %} {{ after }}{% endif %} {% if field.errors %} {% for error in field.errors %} diff --git a/pagure/templates/plugin.html b/pagure/templates/plugin.html index b13fe4f..fbb5dd5 100644 --- a/pagure/templates/plugin.html +++ b/pagure/templates/plugin.html @@ -22,7 +22,11 @@ {% for field in fields %} + {% if field.id in form_fields_readonly %} + {{ render_field_in_row(field, readonly=True) }} + {% else %} {{ render_field_in_row(field) }} + {% endif %} {% endfor %}
diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py index 0f4b5bf..685c7f0 100644 --- a/pagure/ui/plugins.py +++ b/pagure/ui/plugins.py @@ -108,6 +108,10 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True): for field in plugin.form_fields: fields.append(getattr(form, field)) + form_fields_readonly = [] + if hasattr(plugin, 'form_fields_readonly'): + form_fields_readonly = plugin.form_fields_readonly + if form.validate_on_submit(): form.populate_obj(obj=dbobj) @@ -174,4 +178,6 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True): username=username, plugin=plugin, form=form, - fields=fields) + fields=fields, + form_fields_readonly=form_fields_readonly, + )