From 2665d5e4da92b3272218250f4a03c45816cdadfa Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 4 Jan 2017 22:00:07 -0600 Subject: [PATCH] Basic bikes page. --- bikeshop_project/assets/js/bikes/index.jsx | 22 +++++++++++++++++++ bikeshop_project/bike/templates/bikes.html | 7 ++++++ bikeshop_project/bike/urls.py | 7 ++++++ bikeshop_project/bike/views.py | 12 ++++++++-- bikeshop_project/bikeshop/urls.py | 2 ++ .../core/templates/dashboard.html | 1 + 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 bikeshop_project/assets/js/bikes/index.jsx create mode 100644 bikeshop_project/bike/templates/bikes.html create mode 100644 bikeshop_project/bike/urls.py diff --git a/bikeshop_project/assets/js/bikes/index.jsx b/bikeshop_project/assets/js/bikes/index.jsx new file mode 100644 index 0000000..6b0ab20 --- /dev/null +++ b/bikeshop_project/assets/js/bikes/index.jsx @@ -0,0 +1,22 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import injectTapEventPlugin from 'react-tap-event-plugin'; + +// Needed for onTouchTap +// http://stackoverflow.com/a/34015469/988941 +injectTapEventPlugin(); + + +class App extends React.Component { + render() { + return ( +
+
+

Bikes

+
+
+ ); + } +} + +ReactDOM.render(, document.getElementById('root')); diff --git a/bikeshop_project/bike/templates/bikes.html b/bikeshop_project/bike/templates/bikes.html new file mode 100644 index 0000000..20a7768 --- /dev/null +++ b/bikeshop_project/bike/templates/bikes.html @@ -0,0 +1,7 @@ +{% extends 'dashboard.html' %} +{% load render_bundle from webpack_loader %} +{% block content %} +
+ {% render_bundle 'webpack' %} + {% render_bundle 'bikes' %} +{% endblock %} \ No newline at end of file diff --git a/bikeshop_project/bike/urls.py b/bikeshop_project/bike/urls.py new file mode 100644 index 0000000..db058ba --- /dev/null +++ b/bikeshop_project/bike/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url + +from .views import BikesView + +urlpatterns = [ + url(r'^$', BikesView.as_view(), name='bikes') +] diff --git a/bikeshop_project/bike/views.py b/bikeshop_project/bike/views.py index 91ea44a..4d978f4 100644 --- a/bikeshop_project/bike/views.py +++ b/bikeshop_project/bike/views.py @@ -1,3 +1,11 @@ -from django.shortcuts import render +from django.contrib.auth.decorators import login_required +from django.utils.decorators import method_decorator +from django.views.generic import TemplateView -# Create your views here. + +@method_decorator(login_required, name='dispatch') +class BikesView(TemplateView): + template_name = 'bikes.html' + + def get(self, request): + return self.render_to_response({}) diff --git a/bikeshop_project/bikeshop/urls.py b/bikeshop_project/bikeshop/urls.py index 26264fe..f1da2b1 100644 --- a/bikeshop_project/bikeshop/urls.py +++ b/bikeshop_project/bikeshop/urls.py @@ -24,6 +24,7 @@ from rest_framework_jwt.views import obtain_jwt_token import registration from core import urls as core_urls from registration import urls as member_urls +from bike import urls as bike_urls routeLists = [ registration.urls.apiRoutes, @@ -39,6 +40,7 @@ urlpatterns = [ url(r'^login/', login, {'template_name': 'login.html'}, name='login'), url(r'^logout/', logout_then_login, name='logout'), url(r'^members/', include(member_urls)), + url(r'^bikes/', include(bike_urls)), url(r'^admin/', admin.site.urls), url(r'^api/v1/', include(router.urls)), url(r'^api/v1/token-auth/', obtain_jwt_token), diff --git a/bikeshop_project/core/templates/dashboard.html b/bikeshop_project/core/templates/dashboard.html index 547723e..99d9e76 100644 --- a/bikeshop_project/core/templates/dashboard.html +++ b/bikeshop_project/core/templates/dashboard.html @@ -47,6 +47,7 @@ homeHome personNew Member peopleMembers + directions_bikeBikes
{# help_outlineHelp#}