Feat: Assessment page complete and new Home page layout for marketing phase 1 of the customer acquisition plan and offering a demo and for trainers to join the alpha trials. Reporting images created for radar diagram of Command mastery by Command Category; line graph of single command progress measured by obedience level, response latency, and compliance duration over time; Calendar Entries page filtered to unpaid bill calendary entries created using dummy data created in web server as database implementation not yet started.
This commit is contained in:
@@ -55,7 +55,7 @@ def assessments():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Assessment(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_assessments.html', model = model)
|
||||
|
||||
@@ -161,7 +161,7 @@ def assessment():
|
||||
else:
|
||||
model.assessments = [Assessment()]
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
session[Model_View_Dog_Assessment.FLAG_CSRF_TOKEN] = model.form_filters.csrf_token.current_token #.hidden_tag()
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_assessment.html', model = model)
|
||||
|
||||
@@ -51,7 +51,7 @@ def button_icons():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Button_Icon(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_button_icons.html', model = model)
|
||||
|
||||
|
||||
99
controllers/dog/calendar_entry.py
Normal file
99
controllers/dog/calendar_entry.py
Normal file
@@ -0,0 +1,99 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: App Routing
|
||||
Feature: Dog - Calendar Entry Routes
|
||||
|
||||
Description:
|
||||
Contact Page Controller.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
from business_objects.api import API
|
||||
from business_objects.dog.calendar_entry import Calendar_Entry
|
||||
from datastores.datastore_dog import DataStore_Dog
|
||||
from forms.dog.calendar_entry import Filters_Calendar_Entry
|
||||
from helpers.helper_app import Helper_App
|
||||
from models.model_view_dog_calendar_entry import Model_View_Dog_Calendar_Entry
|
||||
from models.model_view_home import Model_View_Home
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app, flash
|
||||
from flask_mail import Mail, Message
|
||||
from extensions import db, oauth, mail
|
||||
from urllib.parse import quote_plus, urlencode
|
||||
from authlib.integrations.flask_client import OAuth
|
||||
from authlib.integrations.base_client import OAuthError
|
||||
from urllib.parse import quote, urlparse, parse_qs
|
||||
import json
|
||||
import base64
|
||||
import hmac
|
||||
import hashlib
|
||||
import datetime
|
||||
from altcha import ChallengeOptions, create_challenge, verify_solution
|
||||
|
||||
|
||||
routes_dog_calendar_entry = Blueprint('routes_dog_calendar_entry', __name__)
|
||||
|
||||
|
||||
@routes_dog_calendar_entry.route(Model_View_Dog_Calendar_Entry.HASH_PAGE_DOG_CALENDAR_ENTRIES, methods=['GET'])
|
||||
def calendar_entries():
|
||||
Helper_App.console_log('calendar_entries')
|
||||
Helper_App.console_log(f'request_args: {request.args}')
|
||||
try:
|
||||
form_filters = Filters_Calendar_Entry.from_json(request.args)
|
||||
except Exception as e:
|
||||
Helper_App.console_log(f'Error: {e}')
|
||||
form_filters = Filters_Calendar_Entry()
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Calendar_Entry(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_calendar_entries.html', model = model)
|
||||
|
||||
"""
|
||||
@routes_dog_calendar_entry.route(Model_View_Dog_Calendar_Entry.HASH_SAVE_DOG_CALENDAR_ENTRY, methods=['POST'])
|
||||
def save_calendar_entry():
|
||||
data = Helper_App.get_request_data(request)
|
||||
try:
|
||||
form_filters = Filters_Calendar_Entry.from_json(data[Model_View_Dog_Calendar_Entry.FLAG_FORM_FILTERS])
|
||||
if not form_filters.validate_on_submit():
|
||||
return jsonify({
|
||||
Model_View_Dog_Calendar_Entry.FLAG_STATUS: Model_View_Dog_Calendar_Entry.FLAG_FAILURE,
|
||||
Model_View_Dog_Calendar_Entry.FLAG_MESSAGE: f'Filters form invalid.\n{form_filters.errors}'
|
||||
})
|
||||
model_return = Model_View_Dog_Calendar_Entry(form_filters_old=form_filters)
|
||||
if not model_return.is_user_logged_in:
|
||||
raise Exception('User not logged in')
|
||||
|
||||
calendar_entries = data[Model_View_Dog_Calendar_Entry.FLAG_CALENDAR_ENTRY]
|
||||
if len(calendar_entries) == 0:
|
||||
return jsonify({
|
||||
Model_View_Dog_Calendar_Entry.FLAG_STATUS: Model_View_Dog_Calendar_Entry.FLAG_FAILURE,
|
||||
Model_View_Dog_Calendar_Entry.FLAG_MESSAGE: f'No calendar entries.'
|
||||
})
|
||||
objs_calendar_entry = []
|
||||
for calendar_entry in calendar_entries:
|
||||
objs_calendar_entry.append(Calendar_Entry.from_json(calendar_entry))
|
||||
Helper_App.console_log(f'objs_calendar_entry={objs_calendar_entry}')
|
||||
errors = DataStore_Dog.save_calendar_entries(data.get('comment', 'No comment'), objs_calendar_entry)
|
||||
|
||||
if (len(errors) > 0):
|
||||
return jsonify({
|
||||
Model_View_Dog_Calendar_Entry.FLAG_STATUS: Model_View_Dog_Calendar_Entry.FLAG_FAILURE,
|
||||
Model_View_Dog_Calendar_Entry.FLAG_MESSAGE: f'Error saving calendar entries.\n{model_return.convert_list_objects_to_json(errors)}'
|
||||
})
|
||||
return jsonify({
|
||||
Model_View_Dog_Calendar_Entry.FLAG_STATUS: Model_View_Dog_Calendar_Entry.FLAG_SUCCESS,
|
||||
Model_View_Dog_Calendar_Entry.FLAG_DATA: Model_View_Dog_Calendar_Entry.convert_list_objects_to_json(model_return.calendar_entries)
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
Model_View_Dog_Calendar_Entry.FLAG_STATUS: Model_View_Dog_Calendar_Entry.FLAG_FAILURE,
|
||||
Model_View_Dog_Calendar_Entry.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'
|
||||
})
|
||||
"""
|
||||
@@ -52,7 +52,7 @@ def commands():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Command(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_commands.html', model = model)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ def command_button_links():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Command_Button_Link(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_command_button_links.html', model = model)
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ def command_categories():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Command_Category(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_command_categories.html', model = model)
|
||||
|
||||
|
||||
@@ -40,9 +40,11 @@ from altcha import ChallengeOptions, create_challenge, verify_solution
|
||||
routes_dog = Blueprint('routes_dog', __name__)
|
||||
|
||||
|
||||
"""
|
||||
@routes_dog.route(Model_View_Dog_Base.HASH_GET_DOG_SCRIPTS_SHARED, methods=['GET'])
|
||||
def scripts_section_dog():
|
||||
hash_page_current = request.args.get('hash_page_current', default = Model_View_Dog_Base.HASH_GET_DOG_SCRIPTS_SHARED, type = str)
|
||||
model = Model_View_Dog_Base(hash_page_current=hash_page_current)
|
||||
template = render_template('js/sections/dog.js', model = model)
|
||||
return Response(template, mimetype='application/javascript')
|
||||
return Response(template, mimetype='application/javascript')
|
||||
"""
|
||||
@@ -52,7 +52,7 @@ def dog_command_links():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Dog_Command_Link(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_dog_command_links.html', model = model)
|
||||
|
||||
|
||||
@@ -41,10 +41,8 @@ routes_dog_home = Blueprint('routes_dog_home', __name__)
|
||||
|
||||
|
||||
@routes_dog_home.route(Model_View_Dog_Base.HASH_PAGE_DOG_HOME, methods=['GET'])
|
||||
def dog_command_links():
|
||||
def home():
|
||||
Helper_App.console_log('DOG HOME')
|
||||
model = Model_View_Dog_Base(hash_page_current = Model_View_Dog_Base.HASH_PAGE_DOG_HOME)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
return render_template('pages/dog/_home.html', model = model)
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ def locations():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Dog_Location(form_filters_old = form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
return render_template('pages/dog/_locations.html', model = model)
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ def logout():
|
||||
@routes_user.route("/logout_callback")
|
||||
@handle_db_disconnect
|
||||
def logout_callback():
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
|
||||
@routes_user.route("/account")
|
||||
def user():
|
||||
@@ -185,7 +185,7 @@ def user():
|
||||
break
|
||||
model.users = [model.user]
|
||||
if not model.is_user_logged_in:
|
||||
return redirect(url_for('routes_core_home.home'))
|
||||
return redirect(url_for('routes_dog_home.home'))
|
||||
html_body = render_template('pages/user/_user.html', model = model)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
Reference in New Issue
Block a user