Skip to content

Commit

Permalink
change dashbord_bp a embeded_dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
germankay committed Feb 26, 2025
1 parent de2ca2e commit f108939
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions ckanext/dashboard/actions/dashboard_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ def dataset_dashboard_update(context, data_dict):
"""
log.info("Executing dataset_dashboard_update")

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

session = model.Session
dashboard = session.query(DatasetDashboard).filter_by(id=dashboard_id).first()
Expand All @@ -131,6 +129,10 @@ def dataset_dashboard_update(context, data_dict):
dashboard.title = data_dict['title']
if 'description' in data_dict:
dashboard.description = data_dict['description']
if 'embeded_url' in data_dict:
dashboard.embeded_url = data_dict['embeded_url']
if 'report_url' in data_dict:
dashboard.report_url = data_dict['report_url']

session.add(dashboard)
session.commit()
Expand All @@ -141,7 +143,7 @@ def dataset_dashboard_update(context, data_dict):
'title': dashboard.title,
'description': dashboard.description,
'embeded_url': dashboard.embeded_url,
'report_url': dashboard.report
'report_url': dashboard.report_url
}


Expand All @@ -155,9 +157,7 @@ def dataset_dashboard_delete(context, data_dict):
"""
log.info("Executing dataset_dashboard_delete")

dashboard_id = data_dict.get('id')
if not dashboard_id:
raise ValueError("The 'id' parameter is required to delete 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
8 changes: 4 additions & 4 deletions ckanext/dashboard/blueprints/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

log = logging.getLogger(__name__)

dashboard_bp = Blueprint('dashboard_bp', __name__, url_prefix='/dashboard-external')
dashboard_bp = Blueprint('embeded_dashboard', __name__, url_prefix='/embeded-dashboard')


@dashboard_bp.route('/', methods=['GET'], endpoint='dashboard_list')
Expand Down Expand Up @@ -52,7 +52,7 @@ def dashboard_new():
except Exception as e:
h.flash_error(f'Error: {e}', 'error')
log.error("Error creating dashboard: %s", e)
return redirect(url_for('dashboard_bp.dashboard_list'))
return redirect(url_for('embeded_dashboard.dashboard_list'))
return render('dashboard/new.html')


Expand All @@ -76,7 +76,7 @@ def dashboard_edit(dashboard_id):
except Exception as e:
h.flash_error(f'Error: {e}', 'error')
log.error("Error updating dashboard for dashboard_id %s: %s", dashboard_id, e)
return redirect(url_for('dashboard_bp.dashboard_list'))
return redirect(url_for('embeded_dashboard.dashboard_list'))
else:
try:
dashboard = p.toolkit.get_action('dataset_dashboard_show')(context, {'id': dashboard_id})
Expand All @@ -98,7 +98,7 @@ def dashboard_delete(dashboard_id):
except Exception as e:
h.flash_error(f'Error: {e}', 'error')
log.error("Error deleting dashboard for dashboard_id %s: %s", dashboard_id, e)
return redirect(url_for('dashboard_bp.dashboard_list'))
return redirect(url_for('embeded_dashboard.dashboard_list'))


@dashboard_bp.route('/show/<dashboard_id>', methods=['GET'], endpoint='dashboard_show')
Expand Down
2 changes: 1 addition & 1 deletion ckanext/dashboard/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block content_primary_nav %}
{{ super() }}
{{ h.build_nav_icon('dashboard_bp.dashboard_list', _('External dashboards'), icon='icon-list') }}
{{ h.build_nav_icon('embeded_dashboard.dashboard_list', _('Embebed dashboards'), icon='icon-list') }}
{# Los endpoints que requieren package_id se muestran en contextos específicos y no en la navegación global #}
{% endblock %}

Expand Down
4 changes: 2 additions & 2 deletions ckanext/dashboard/templates/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
{% block content %}
<div class="dashboard-list-container">
<h1>📊 Dashboard - List</h1>
<a href="{{ url_for('dashboard_bp.dashboard_new') }}">New</a>
<a href="{{ url_for('embeded_dashboard.dashboard_new') }}">New</a>

{% if dashboards %}
<ul class="dashboard-list">
{% for dashboard in dashboards %}
<li class="dashboard-item">
<strong>{{ dashboard.title }}</strong><br>
<a href="{{ h.url_for('dashboard_bp.dashboard_show', dashboard_id=dashboard.dashboard_id) }}">View</a>
<a href="{{ h.url_for('embeded_dashboard.dashboard_show', dashboard_id=dashboard.dashboard_id) }}">View</a>
</li>
{% endfor %}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions ckanext/dashboard/templates/dashboard/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ <h1>{{ dashboard.title }}</h1>
</p>

<div class="dashboard-actions">
<a class="btn btn-primary" href="{{ h.url_for('dashboard_bp.dashboard_edit', dashboard_id=dashboard_id) }}">Edit</a>
<form action="{{ h.url_for('dashboard_bp.dashboard_delete', dashboard_id=dashboard_id) }}" method="POST" style="display:inline;">
<a class="btn btn-primary" href="{{ h.url_for('embeded_dashboard.dashboard_edit', dashboard_id=dashboard_id) }}">Edit</a>
<form action="{{ h.url_for('embeded_dashboard.dashboard_delete', dashboard_id=dashboard_id) }}" method="POST" style="display:inline;">
<button class="btn btn-danger" type="submit" onclick="return confirm('Are you sure you want to delete this dashboard?');">Delete</button>
</form>
</div>
Expand Down
6 changes: 3 additions & 3 deletions ckanext/dashboard/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% extends "base.html" %}
{% block content %}
<h1>Dashboard Configurations</h1>
<a href="{{ h.url_for('dashboard_bp.dashboard_new') }}">Add new dashboard</a>
<a href="{{ h.url_for('embeded_dashboard.dashboard_new') }}">Add new dashboard</a>
<ul>
{% for d in dashboards %}
<li>
Dataset: {{ d.package_id }} -
<a href="{{ h.url_for('dashboard_bp.dashboard_edit', dashboard_id=dashboard.id) }}">Edit</a>
<form action="{{ h.url_for('dashboard_bp.dashboard_delete', dashboard_id=dashboard.id) }}" method="POST">
<a href="{{ h.url_for('embeded_dashboard.dashboard_edit', dashboard_id=dashboard.id) }}">Edit</a>
<form action="{{ h.url_for('embeded_dashboard.dashboard_delete', dashboard_id=dashboard.id) }}" method="POST">
<button type="submit">Delete</button>
</form>
</li>
Expand Down

0 comments on commit f108939

Please sign in to comment.