diff --git a/ckanext/dashboard/actions/dashboard_dataset.py b/ckanext/dashboard/actions/dashboard_dataset.py index 91d2b35..ae375c4 100644 --- a/ckanext/dashboard/actions/dashboard_dataset.py +++ b/ckanext/dashboard/actions/dashboard_dataset.py @@ -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() @@ -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()) @@ -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.") diff --git a/ckanext/dashboard/blueprints/dashboard.py b/ckanext/dashboard/blueprints/dashboard.py index 25b7026..b612b5e 100644 --- a/ckanext/dashboard/blueprints/dashboard.py +++ b/ckanext/dashboard/blueprints/dashboard.py @@ -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 = [] diff --git a/ckanext/dashboard/templates/dashboard/edit.html b/ckanext/dashboard/templates/dashboard/edit.html index 585750a..37fe9df 100644 --- a/ckanext/dashboard/templates/dashboard/edit.html +++ b/ckanext/dashboard/templates/dashboard/edit.html @@ -10,7 +10,7 @@
The dashboard you're trying to view does not exist.
{% endif %} -{% endblock %}z \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/ckanext/dashboard/templates/package/read.html b/ckanext/dashboard/templates/package/read.html index 25affb3..2f95846 100644 --- a/ckanext/dashboard/templates/package/read.html +++ b/ckanext/dashboard/templates/package/read.html @@ -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 %}