From 8e4405f260db4f0f95d18e14c81d27793fec281e Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 30 May 2017 14:44:18 -0400 Subject: [PATCH 1/3] Create a landing page to connect buildings to blocnote. Show all available links and their corresponding status. --- .../templates/financialInputs/index.html | 1 + blocnote/apps/financialInputs/urls.py | 1 + blocnote/apps/landingPage/__init__.py | 0 blocnote/apps/landingPage/admin.py | 3 + blocnote/apps/landingPage/apps.py | 5 ++ .../apps/landingPage/migrations/__init__.py | 0 blocnote/apps/landingPage/models.py | 3 + .../templates/landingPage/index.html | 60 +++++++++++++++++ blocnote/apps/landingPage/tests.py | 3 + blocnote/apps/landingPage/urls.py | 8 +++ blocnote/apps/landingPage/views.py | 64 +++++++++++++++++++ .../templates/preliminaryFinance/index.html | 1 + blocnote/apps/preliminaryFinance/urls.py | 1 + blocnote/settings.py | 1 + blocnote/urls.py | 1 + 15 files changed, 152 insertions(+) create mode 100644 blocnote/apps/landingPage/__init__.py create mode 100644 blocnote/apps/landingPage/admin.py create mode 100644 blocnote/apps/landingPage/apps.py create mode 100644 blocnote/apps/landingPage/migrations/__init__.py create mode 100644 blocnote/apps/landingPage/models.py create mode 100644 blocnote/apps/landingPage/templates/landingPage/index.html create mode 100644 blocnote/apps/landingPage/tests.py create mode 100644 blocnote/apps/landingPage/urls.py create mode 100644 blocnote/apps/landingPage/views.py diff --git a/blocnote/apps/financialInputs/templates/financialInputs/index.html b/blocnote/apps/financialInputs/templates/financialInputs/index.html index a208ffd..fb9b3c1 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/index.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/index.html @@ -49,6 +49,7 @@ {% include "financialInputs/customerPreference.html" %} +Go Back {% endblock %} {% block scripts %} diff --git a/blocnote/apps/financialInputs/urls.py b/blocnote/apps/financialInputs/urls.py index ce55b44..e668ab6 100644 --- a/blocnote/apps/financialInputs/urls.py +++ b/blocnote/apps/financialInputs/urls.py @@ -2,6 +2,7 @@ from django.conf.urls import url from . import views +app_name = 'financial-inputs' urlpatterns = [ url(r'^$', views.Index.as_view(), name='index'), url(r'^finance-overview/$', views.BlocNoteHeader.as_view(), name='header'), diff --git a/blocnote/apps/landingPage/__init__.py b/blocnote/apps/landingPage/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blocnote/apps/landingPage/admin.py b/blocnote/apps/landingPage/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/blocnote/apps/landingPage/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/blocnote/apps/landingPage/apps.py b/blocnote/apps/landingPage/apps.py new file mode 100644 index 0000000..e8bedb8 --- /dev/null +++ b/blocnote/apps/landingPage/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class LandingpageConfig(AppConfig): + name = 'landingPage' diff --git a/blocnote/apps/landingPage/migrations/__init__.py b/blocnote/apps/landingPage/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blocnote/apps/landingPage/models.py b/blocnote/apps/landingPage/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/blocnote/apps/landingPage/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/blocnote/apps/landingPage/templates/landingPage/index.html b/blocnote/apps/landingPage/templates/landingPage/index.html new file mode 100644 index 0000000..c1d74da --- /dev/null +++ b/blocnote/apps/landingPage/templates/landingPage/index.html @@ -0,0 +1,60 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% block content %} +
+

+ BLOCNOTE +

+
+ + + + + + + + + {% if if_completed %} + + + + + + + + + {% else %} + + + + + + + + + {% endif %} + +
OptionsStatus
+ Financial Inputs + Complete
+ Preliminary Finance + OK
+ Financial Inputs + + {% if if_started %} + Started but not complete. + {% else %} + Not Started. + {% endif %} +
+ Preliminary Finance + +
    + {% for item in not_saved_list %} +
  • Please fill {{ item }}
  • + {% endfor %} +
+
+
+
+{% endblock %} diff --git a/blocnote/apps/landingPage/tests.py b/blocnote/apps/landingPage/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/blocnote/apps/landingPage/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/blocnote/apps/landingPage/urls.py b/blocnote/apps/landingPage/urls.py new file mode 100644 index 0000000..e92c33f --- /dev/null +++ b/blocnote/apps/landingPage/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url + +from . import views + +app_name = 'landingPage' +urlpatterns = [ + url(r'^$', views.Index.as_view(), name='index'), +] diff --git a/blocnote/apps/landingPage/views.py b/blocnote/apps/landingPage/views.py new file mode 100644 index 0000000..88baea2 --- /dev/null +++ b/blocnote/apps/landingPage/views.py @@ -0,0 +1,64 @@ +"""Define the views for the landing page for a building.""" +from django.shortcuts import render +from django.views import View + +from blocnote.apps.financialInputs.models import FinancingOverview +from blocnote.apps.financialInputs.models import BillsOverview +from blocnote.apps.financialInputs.models import CustomerPreference +from blocnote.apps.financialInputs.models import CashBalance +from blocnote.apps.financialInputs.models import IncomeStatement +from blocnote.apps.financialInputs.models import LoanOptions + + +class Index(View): + """Show the page with the urls for other apps.""" + + models = [ + FinancingOverview, + BillsOverview, + CustomerPreference, + CashBalance, + IncomeStatement, + LoanOptions, + ] + + model_names_map = { + FinancingOverview: 'Proforma Inputs', + BillsOverview: 'Bills Overview', + CustomerPreference: 'Customer Preference', + CashBalance: 'Cash Balance', + IncomeStatement: 'Income Statment', + LoanOptions: 'Loan Options' + } + + def get(self, request, building_id): + """HTTP GET request. + + Display links to the inputs, budget simulation and preliminary and full analysis pages. + """ + not_saved_list = self.check_inputs(building_id) + if_completed = True + if_started = False + if len(not_saved_list) > 0: + if_completed = False + print(not_saved_list) + if len(not_saved_list) < len(self.models): + if_started = True + context = { + 'building_id': building_id, + 'if_started': if_started, + 'if_completed': if_completed, + 'not_saved_list': not_saved_list, + + } + print(context) + return render(request, 'landingPage/index.html', context=context) + + def check_inputs(self, building_id): + """Check if all inputs have been filled out.""" + not_saved = [] + for model in self.models: + model_object = model.objects.filter(building_id=building_id) + if not model_object: + not_saved.append(self.model_names_map[model]) + return not_saved diff --git a/blocnote/apps/preliminaryFinance/templates/preliminaryFinance/index.html b/blocnote/apps/preliminaryFinance/templates/preliminaryFinance/index.html index 787a01a..f07eb5a 100644 --- a/blocnote/apps/preliminaryFinance/templates/preliminaryFinance/index.html +++ b/blocnote/apps/preliminaryFinance/templates/preliminaryFinance/index.html @@ -14,6 +14,7 @@
{% include "preliminaryFinance/scenario.html" %}
+Go Back {% endblock %} {% block scripts %} diff --git a/blocnote/apps/preliminaryFinance/urls.py b/blocnote/apps/preliminaryFinance/urls.py index 6bd796e..42d6fe8 100644 --- a/blocnote/apps/preliminaryFinance/urls.py +++ b/blocnote/apps/preliminaryFinance/urls.py @@ -2,6 +2,7 @@ from django.conf.urls import url from . import views +app_name = 'preliminary-finance' urlpatterns = [ url(r'^$', views.Index.as_view(), name='index'), url(r'^scenario/$', views.Scenarios.as_view(), name='scenario'), diff --git a/blocnote/settings.py b/blocnote/settings.py index ad0f38b..44905a6 100644 --- a/blocnote/settings.py +++ b/blocnote/settings.py @@ -43,6 +43,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'blocnote.apps.financialInputs', 'blocnote.apps.preliminaryFinance', + 'blocnote.apps.landingPage', ] MIDDLEWARE = [ diff --git a/blocnote/urls.py b/blocnote/urls.py index d8c2845..965a595 100644 --- a/blocnote/urls.py +++ b/blocnote/urls.py @@ -20,5 +20,6 @@ urlpatterns = [ url('', admin.site.urls), url(r'^buildings/(?P[0-9]+)/preliminary-finance/', include('blocnote.apps.preliminaryFinance.urls')), url(r'^buildings/(?P[0-9]+)/financial-inputs/', include('blocnote.apps.financialInputs.urls')), + url(r'^buildings/(?P[0-9]+)/', include('blocnote.apps.landingPage.urls')), url(r'^admin/', admin.site.urls), ] -- GitLab From 40e3ecf59794174244588c564e6b3c83faacb073 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Wed, 31 May 2017 10:54:10 -0400 Subject: [PATCH 2/3] Use strict in javascript file. Remove print statements and blank line. --- .../financialInputs/static/financialInputs/scripts/app.js | 1 + blocnote/apps/landingPage/views.py | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 0bc6e05..b1b45df 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -1,3 +1,4 @@ +'use strict' const utilities = ['electricity', 'gas', 'oil', 'water']; var today = new Date(); const todaysDate = { diff --git a/blocnote/apps/landingPage/views.py b/blocnote/apps/landingPage/views.py index 88baea2..0e2608c 100644 --- a/blocnote/apps/landingPage/views.py +++ b/blocnote/apps/landingPage/views.py @@ -39,9 +39,8 @@ class Index(View): not_saved_list = self.check_inputs(building_id) if_completed = True if_started = False - if len(not_saved_list) > 0: + if not_saved_list: if_completed = False - print(not_saved_list) if len(not_saved_list) < len(self.models): if_started = True context = { @@ -49,9 +48,7 @@ class Index(View): 'if_started': if_started, 'if_completed': if_completed, 'not_saved_list': not_saved_list, - } - print(context) return render(request, 'landingPage/index.html', context=context) def check_inputs(self, building_id): -- GitLab From 22e574a3348f2cc846070a2a6f5c7264821d659d Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Wed, 31 May 2017 10:56:39 -0400 Subject: [PATCH 3/3] Remove use strict from this PR. --- .../apps/financialInputs/static/financialInputs/scripts/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index b1b45df..0bc6e05 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -1,4 +1,3 @@ -'use strict' const utilities = ['electricity', 'gas', 'oil', 'water']; var today = new Date(); const todaysDate = { -- GitLab