Skip to content

Commit 56b7cc0

Browse files
committed
More work converting to django 2
1 parent dd18479 commit 56b7cc0

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

dashboard/gadgets/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ def find_gadgets():
88
if not f.startswith('_') and f.endswith('.py')]
99
except OSError:
1010
return []
11-
gadgetArray = []
11+
gadget_array = []
1212
for f in file_dict:
13-
gadgetArray.append(open_gadget(f).gadget_info())
14-
return gadgetArray
13+
gadget_array.append(open_gadget(f).gadget_info())
14+
return gadget_array
1515

1616

1717
def open_gadget(gadget):
18-
g = __import__("django-dashboard.dashboard.gadgets." + gadget, globals(), locals(), ["Gadget"])
18+
g = __import__("dashboard.gadgets." + gadget, globals(), locals(), ["Gadget"])
1919
return g.Gadget()

dashboard/templates/view_gadgets.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<body>
66
<ul>
77
{% for gadget in gadgets %}
8-
<li><a href="{% url dashboard_add_gadget name gadget.name %}">{{ gadget.name }}</a></li>
8+
<li><a href="{% url 'dashboard:add_gadget' dashboard.slug gadget.name %}">{{ gadget.name }}</a></li>
99
{% endfor %}
1010
</ul>
1111
</body>

dashboard/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616

1717
from django.urls import path
18-
from dashboard.views import ViewDashboard, ViewGadgets
18+
from dashboard.views import ViewDashboard, ViewGadgets, AddGadget
1919

2020
app_name = 'dashboard'
2121
urlpatterns = [
2222
path('<slug:slug>/', ViewDashboard.as_view(), name='view_dashboard'),
2323
path('<slug:slug>/view-gadgets/', ViewGadgets.as_view(), name='view_gadgets'),
24+
path('<slug:slug>/add/<str:gadget>/', AddGadget.as_view(), name="add_gadget"),
2425
]

dashboard/views.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ def get_context_data(self, **kwargs):
9696
return context
9797

9898

99-
# # noinspection PyUnusedLocal
100-
# def view_gadgets(request, name):
101-
# return render_to_response('view_gadgets.html', {'name': name, 'gadgets': find_gadgets()})
102-
#
103-
#
99+
class AddGadget(View):
100+
def get(self, slug, gadget):
101+
pass
104102
# def add_gadget(request, name, gadget):
105103
# try:
106104
# dashboard = models.Dashboard.objects.get(name=name, user=request.user)

0 commit comments

Comments
 (0)