Skip to content

Commit

Permalink
Use visibility var from schema to display and allow changing of fields
Browse files Browse the repository at this point in the history
  • Loading branch information
saj-derilinx committed Oct 21, 2024
1 parent 23778a7 commit 12b4402
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
10 changes: 8 additions & 2 deletions ckanext/scheming/templates/scheming/organization/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
{% block primary_content_inner %}
<dl>
{% for f in c.scheming_fields %}
<dt>{{ h.scheming_language_text(f.label) }}:</dt>
<dd>{{ group_dict[f.field_name] or ("&nbsp;"|safe) }}</dd>
{% set visibility = f.visibility or 'user' %}
{% if visibility == 'user' %}
<dt>{{ h.scheming_language_text(f.label) }}:</dt>
<dd>{{ group_dict[f.field_name] or ("&nbsp;"|safe) }}</dd>
{% elif visibility == 'sysadmin' and g.userobj.sysadmin %}
<dt>{{ h.scheming_language_text(f.label) }}:</dt>
<dd>{{ group_dict[f.field_name] or ("&nbsp;"|safe) }}</dd>
{% endif %}
{% endfor %}
</dl>
{% endblock %}
15 changes: 12 additions & 3 deletions ckanext/scheming/templates/scheming/organization/group_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@
{{ h.csrf_input() if 'csrf_input' in h }}
{%- set schema = h.scheming_get_organization_schema(group_type) -%}
{%- for field in schema['fields'] -%}
{% set visibility = field.visibility or 'admin'%}
{%- if field.form_snippet is not none -%}
{%- snippet 'scheming/snippets/form_field.html',
field=field, data=data, errors=errors, licenses=licenses,
entity_type='organization', object_type=group_type -%}
{% if visibility == 'sysadmin' and not g.userobj.sysadmin %}
{% set name = field.field_name %}
<div class="form-group control-medium control-select">
<label class="control-label" for="field-{{ name }}">{{ field.label }}</label>
<input id="field-{{ name }}" name="{{ name }}" type="text" value="{{ data[name] }}" disabled="True" class="form-control">
</div>
{% else %}
{%- snippet 'scheming/snippets/form_field.html',
field=field, data=data, errors=errors, licenses=licenses,
entity_type='organization', object_type=group_type -%}
{% endif %}
{%- endif -%}
{%- endfor -%}

Expand Down

0 comments on commit 12b4402

Please sign in to comment.