Projet

Général

Profil

0001-dashboard-don-t-remove-cell-associated-to-tile-18929.patch

Frédéric Péters, 25 septembre 2017 12:23

Télécharger (2,47 ko)

Voir les différences:

Subject: [PATCH] dashboard: don't remove cell associated to tile (#18929)

 combo/apps/dashboard/views.py | 14 ++++++++++++--
 tests/test_dashboard.py       |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)
combo/apps/dashboard/views.py
19 19
from django.conf import settings
20 20
from django.contrib.contenttypes.models import ContentType
21 21
from django.core.exceptions import PermissionDenied
22
from django.core.urlresolvers import reverse
22 23
from django.http import Http404, HttpResponse, HttpResponseRedirect
23 24
from django.views.decorators.csrf import csrf_exempt
24 25
from django.views.generic import View
......
67 68
        tile.order = 0
68 69
        tile.save()
69 70

  
70
        return dashboard_success(request, dashboard, get_cell_data(cell))
71
        cell_data = get_cell_data(cell)
72
        cell_data['remove_url'] = reverse(
73
                'combo-dashboard-remove-tile',
74
                kwargs={'cell_reference': cell.get_reference()})
75

  
76
        return dashboard_success(request, dashboard, cell_data)
71 77

  
72 78
dashboard_add_tile = DashboardAddTileView.as_view()
73 79

  
......
84 90
        dashboard = tile.dashboard
85 91
        cell_data = get_cell_data(cell)
86 92
        tile.delete()
87
        cell.delete()
93

  
94
        # do not remove cell so it can directly be added back
95
        cell_data['add_url'] = reverse(
96
                'combo-dashboard-add-tile',
97
                kwargs={'cell_reference': cell.get_reference()})
88 98

  
89 99
        return dashboard_success(request, dashboard, cell_data)
90 100

  
tests/test_dashboard.py
107 107
    resp = app.get(reverse('combo-dashboard-remove-tile',
108 108
        kwargs={'cell_reference': tile.cell.get_reference()}), status=302)
109 109
    assert Tile.objects.count() == 0
110
    assert TextCell.objects.count() == 10
110
    assert TextCell.objects.count() == 11 # the cell itself is kept
111 111

  
112 112
def test_ajax_remove_from_dashboard(app, site):
113 113
    test_add_to_dashboard(app, site)
114
-