Skip to content

Commit

Permalink
sin andar
Browse files Browse the repository at this point in the history
  • Loading branch information
germankay committed Dec 12, 2024
1 parent 97343ad commit c9241a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
9 changes: 5 additions & 4 deletions ckanext/superset/blueprints/superset.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ def create_dataset(chart_id):
superset_chart = sc.get_chart(chart_id)
# Obtener los grupos disponibles
groups_available = tk.get_action('group_list')(data_dict={})
print("groups_available", groups_available)

if request.method == 'GET':

selected_group = []
extra_vars = {
'superset_chart': superset_chart,
'groups_available': groups_available,
'selected_group': selected_group,
}
return tk.render('superset/create-dataset.html', extra_vars)

Expand All @@ -70,7 +69,9 @@ def create_dataset(chart_id):
c += 1

# Obtener los grupos seleccionados del formulario
selected_groups = request.form.getlist('ckan_dataset_groups')
selected_group_ids = request.form.getlist('ckan_group_ids[]')
# Transformar en lista de diccionarios
selected_groups = [{"id": group_id} for group_id in selected_group_ids]

# Create the dataset
action = tk.get_action("package_create")
Expand All @@ -80,11 +81,11 @@ def create_dataset(chart_id):
'title': ckan_dataset_title,
'notes': request.form.get('ckan_dataset_notes'),
'owner_org': request.form.get('ckan_organization_id'),
'groups': selected_groups,
'private': request.form.get('ckan_dataset_private'),
'extras': [
{'key': 'superset_chart_id', 'value': chart_id},
],
'groups': selected_groups
}
pkg = action(context, data)
# Create the resource
Expand Down
19 changes: 9 additions & 10 deletions ckanext/superset/templates/superset/create-dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@ <h2>Create CKAN dataset from Superset dataset</h2>
</div>

<!-- Grup list -->
{% set groups_available = h.groups_available('create_dataset') %}
<div class="form-group">
<label for="ckan_group_id">Groups</label>
<div class="checkbox-group">
{% for group in groups_available %}
<div class="form-check">
<input class="form-check-input" type="checkbox" id="group_{{ group.id }}" name="ckan_group_id" value="{{ group.id }}"
{% if group.id in selected_groups %}checked{% endif %}>
<label class="form-check-label" for="group_{{ group.id }}">
{{ group.title }}
</label>
</div>
{% endfor %}
{% for group in groups_available %}
<div class="form-check">
<input class="form-check-input" type="checkbox" id="group_{{ group.id }}" name="ckan_group_ids[]" value="{{ group.id }}">
<label class="form-check-label" for="group_{{ group.id }}">
{{ group }}
</label>
<small>{{ group.description }}</small>
</div>
{% endfor %}
</div>
</div>

Expand Down

0 comments on commit c9241a5

Please sign in to comment.