From 24cdebe96062150a3a15c5c0afe6d70465f7c3d3 Mon Sep 17 00:00:00 2001 From: ahosking Date: Sat, 6 May 2023 11:23:21 -0400 Subject: [PATCH] Add templates! --- api/api/settings.py | 3 +- api/api/templates/index.html | 338 ++++++++++------------------------- api/api/views.py | 7 + api/bills/views.py | 19 +- 4 files changed, 115 insertions(+), 252 deletions(-) diff --git a/api/api/settings.py b/api/api/settings.py index 370ff96..1066560 100644 --- a/api/api/settings.py +++ b/api/api/settings.py @@ -183,6 +183,5 @@ JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard' STATICFILES_DIRS = [ BASE_DIR / "api/static", - ("assets", BASE_DIR / "assets"), - "[os.path.join(BASE_DIR, 'static')", + ("assets", BASE_DIR / "api/static/assets"), ] diff --git a/api/api/templates/index.html b/api/api/templates/index.html index be94f05..ed54fda 100644 --- a/api/api/templates/index.html +++ b/api/api/templates/index.html @@ -1,248 +1,100 @@ {% load static %} - + - - - - - - Manage My Bills - - - - - - - - - - - - - -
-
-
-
-
- -

Generate more leads with a professional landing page!

- - - - - - - - - -
-
-
-
-
- -
-
-
-
-
-
-

Fully Responsive

-

This theme will look great on any device, no matter the size!

-
-
-
-
-
-

Bootstrap 5 Ready

-

Featuring the latest build of the new Bootstrap 5 framework!

-
-
-
-
-
-

Easy to Use

-

Ready to use with your own content, or customize the source files!

-
-
-
-
-
- -
-
-
-
-
-

Fully Responsive Design

-

When you use a theme created by Start Bootstrap, you know that the theme will look great on any device, whether it's a phone, tablet, or desktop the page will behave responsively!

-
-
-
-
-
-

Updated For Bootstrap 5

-

Newly improved, and full of great utility classes, Bootstrap 5 is leading the way in mobile responsive web development! All of the themes on Start Bootstrap are now using Bootstrap 5!

-
-
-
-
-
-

Easy to Use & Customize

-

Landing Page is just HTML and CSS with a splash of SCSS for users who demand some deeper customization options. Out of the box, just add your content and images, and your new landing page will be ready to go!

-
-
-
-
- -
-
-

What people are saying...

-
-
-
- ... -
Margaret E.
-

"This is fantastic! Thanks so much guys!"

-
-
-
-
- ... -
Fred S.
-

"Bootstrap is amazing. I've been using it to create lots of super nice landing pages."

-
-
-
-
- ... -
Sarah W.
-

"Thanks so much for making these free resources available to us!"

-
-
-
-
-
- -
-
-
-
-

Ready to get started? Sign up now!

- - - - - - - - - -
-
-
-
- - - - - - - - - - - - +
+ Sign-up! +
+ +
+ +
+
+

Starter projects

+

Ready to beyond the starter template? Check out these open source projects that you can quickly duplicate to a new GitHub repository.

+ +
+ +
+

Guides

+

Read more detailed instructions and documentation on using or contributing to Bootstrap.

+ +
+
+ + + + + + + +
+ +
+ + + diff --git a/api/api/views.py b/api/api/views.py index c4004e3..529468c 100644 --- a/api/api/views.py +++ b/api/api/views.py @@ -1,5 +1,7 @@ +from django.contrib.auth import logout from django.http import HttpResponse from django.template import loader +from django.shortcuts import redirect def index(request): @@ -7,3 +9,8 @@ def index(request): template = loader.get_template('index.html') context = {} return HttpResponse(template.render(context, request)) + + +def logout(request): + logout(request) + redirect(index) diff --git a/api/bills/views.py b/api/bills/views.py index c5377b6..462e086 100644 --- a/api/bills/views.py +++ b/api/bills/views.py @@ -1,18 +1,23 @@ # from django.shortcuts import render +from django.contrib.auth import authenticate, login from django.http import HttpResponse, Http404 from django.template import loader -from django.shortcuts import render, get_object_or_404, get_list_or_404 +from django.shortcuts import render, get_object_or_404, get_list_or_404, redirect from .models import Bill def index(request): - bills_list = Bill.objects.order_by('-due') - # bills_list = get_list_or_404(Bill) - template = loader.get_template('bills/index.html') - context = {'bills_list': bills_list, } - print(bills_list) - return HttpResponse(template.render(context, request)) + if request.user.is_authenticated: + bills_list = Bill.objects.order_by('-due') + # bills_list = get_list_or_404(Bill) + template = loader.get_template('bills/index.html') + context = {'bills_list': bills_list, } + print(bills_list) + return HttpResponse(template.render(context, request)) + else: + # return redirect(api.index) + return render(request, "index.html") # return render(request, 'bills/index.html', context)