Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
germankay committed Feb 25, 2025
1 parent 92dad90 commit de2ca2e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
13 changes: 4 additions & 9 deletions ckanext/dashboard/actions/dashboard_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def dataset_dashboard_show(context, data_dict):
"""
log.info("Executing dataset_dashboard_show")

dashboard_id = data_dict.get('id')
if not dashboard_id:
raise ValueError("The 'id' parameter is required to show the dashboard.")
dashboard_id = toolkit.get_or_bust(data_dict, 'id')

session = model.Session
dashboard = session.query(DatasetDashboard).filter_by(id=dashboard_id).first()
Expand Down Expand Up @@ -78,14 +76,11 @@ def dataset_dashboard_create(context, data_dict):
log.info("Executing dataset_dashboard_create")

# Validate required fields
required_fields = ['package_id', 'title']
missing_fields = [field for field in required_fields if field not in data_dict]
if missing_fields:
raise ValueError("Missing required fields: " + ", ".join(missing_fields))
package_id, title = toolkit.get_or_bust(data_dict, ['package_id', 'title'])

session = model.Session
# Extract and validate package_id
package_id = data_dict.get('package_id', '').strip()

if not package_id:
# Generate a new UUID if package_id is empty
package_id = str(uuid.uuid4())
Expand Down Expand Up @@ -122,7 +117,7 @@ def dataset_dashboard_update(context, data_dict):
"""
log.info("Executing dataset_dashboard_update")

dashboard_id = data_dict.get('id')
dashboard_id = toolkit.get_or_bust('id')
if not dashboard_id:
raise ValueError("The 'id' parameter is required to update the dashboard.")

Expand Down
1 change: 0 additions & 1 deletion ckanext/dashboard/blueprints/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def index():
try:
dashboards = p.toolkit.get_action('dataset_dashboard_list')(context, {})
except Exception as e:
model.Session.rollback()
log.error("Failed to load dashboards: %s", e)
h.flash_error("An error occurred while retrieving the dashboards.", "error")
dashboards = []
Expand Down
2 changes: 1 addition & 1 deletion ckanext/dashboard/templates/dashboard/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1 class="mb-4">
<!-- CSRF Token -->
{{ h.csrf_input() }}

<!-- Si se está editando, se incluye el dashboard_id -->
<!-- If editing, include the dashboard_id -->
{% if dashboard %}
<input type="hidden" name="dashboard_id" value="{{ dashboard.id }}">
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/dashboard/templates/dashboard/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ <h2>Dashboard Not Found</h2>
<p>The dashboard you're trying to view does not exist.</p>
{% endif %}
</div>
{% endblock %}z
{% endblock %}
2 changes: 0 additions & 2 deletions ckanext/dashboard/templates/package/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
{% block package_description %}
{{ super() }}

{# Llamamos al helper para obtener la configuración del dashboard #}
{% set dashboard = h.get_dataset_dashboards(package['id']) %}

{% if dashboard and dashboard.embeded_url %}
<h3>Dashboard</h3>
{# Incluimos el snippet de embebido #}
{% include "dashboard/snippet.html" %}
{% endif %}
{% endblock %}

0 comments on commit de2ca2e

Please sign in to comment.