Skip to content

Commit

Permalink
Remove the dummy object and re-work the home page
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhiek187 committed Mar 29, 2021
1 parent 546fa91 commit 4e89d67
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 81 deletions.
17 changes: 6 additions & 11 deletions stockhelper/stockapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2021-03-18 18:07
# Generated by Django 3.1.5 on 2021-03-29 19:14

from django.db import migrations, models
import uuid
Expand All @@ -20,19 +20,14 @@ class Migration(migrations.Migration):
('definition', models.TextField()),
],
),
migrations.CreateModel(
name='Dummy',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
),
migrations.CreateModel(
name='Stock',
fields=[
('ticker', models.CharField(max_length=10, primary_key=True, serialize=False)),
('name', models.CharField(max_length=100)),
('price', models.DecimalField(decimal_places=2, max_digits=7)),
('change', models.FloatField()),
('ticker', models.CharField(default='', max_length=10, primary_key=True, serialize=False)),
('name', models.CharField(default='', max_length=100)),
('shares', models.PositiveIntegerField(default=0)),
('price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
('change', models.FloatField(default=0)),
],
),
]
33 changes: 0 additions & 33 deletions stockhelper/stockapp/migrations/0002_auto_20210318_1422.py

This file was deleted.

18 changes: 0 additions & 18 deletions stockhelper/stockapp/migrations/0003_stock_shares.py

This file was deleted.

5 changes: 0 additions & 5 deletions stockhelper/stockapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
import uuid


# Placeholder model for generic views
class Dummy(models.Model):
pass


# The user's stock portfolio
class Stock(models.Model):
ticker = models.CharField(max_length=10, primary_key=True, default="")
Expand Down
6 changes: 0 additions & 6 deletions stockhelper/stockapp/static/stockapp/css/detail.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
align-items: center; /* center vertically */
}

.help {
/* Appear hoverable like with the <abbr> tag */
text-decoration: underline dotted;
cursor: help;
}

.short-chart-container,
.long-chart-container {
position: relative;
Expand Down
6 changes: 6 additions & 0 deletions stockhelper/stockapp/static/stockapp/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ body {
flex: 1;
}

.help {
/* Appear hoverable like with the <abbr> tag */
text-decoration: underline dotted;
cursor: help;
}

.home-nav-list {
list-style-type: none; /* remove the bullet points in an unordered list */
}
4 changes: 4 additions & 0 deletions stockhelper/stockapp/static/stockapp/js/home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const title = document.title;
const equity = document.querySelector(".equity");

// Initialize the popovers
new bootstrap.Popover(equity);

// Make the clicked link active and remove the active class from the previous link
if (title !== "How to Stock") {
Expand Down
14 changes: 12 additions & 2 deletions stockhelper/stockapp/templates/stockapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@
<main class="main-content">
<!-- Main content to be overriden with each page -->
{% block content %}
<h1 class="home-title">Welcome!</h1>
<h2 class="home-subtitle mb-4 fs-3">Please select an option from the top.</h2>
<h1 class="home-title mt-3 mx-3">Welcome to How to Stock!</h1>
<p class="home-subtitle mb-4 mx-3 fs-5">
You start off with a balance of $10,000. Your goal is to invest in enough
<a href="javascript:" class="equity help fw-bold" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-container="body" data-bs-placement="top" title="{{ terms.equity.word }}" data-bs-content="{{ terms.equity.definition }}"> equity </a>
to gain a profit. &#x25b2;
</p>
<p class="home-subtitle mb-4 mx-3 fs-5">
As you explore this app, you'll learn more about various financial terms and get first-hand experience at trading in the stock market. Not sure what each term means? Click on the dotted words to see their definition.
</p>
<p class="home-subtitle mb-4 mx-3 fs-5">
Click on one the links above to get started!
</p>
<ul class="home-nav-list list-group list-group-flush mx-3">
<li class="list-group-item">
<strong>Home</strong> - this page!
Expand Down
2 changes: 1 addition & 1 deletion stockhelper/stockapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

app_name = "stockapp"
urlpatterns = [
path("", views.IndexView.as_view(), name="index"),
path("", views.get_index, name="index"),
path("screener", views.get_stocks, name="screener"),
path("details/<ticker>", views.get_stock_details, name="detail"),
path("flashcards", views.FlashCardsView.as_view(), name="flashcards"),
Expand Down
14 changes: 9 additions & 5 deletions stockhelper/stockapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@

from . import api
from .forms import ScreenerForm
from .models import Card, Dummy, Stock
from .models import Card, Stock
from http import HTTPStatus
import json

class IndexView(generic.ListView):
model = Dummy
template_name = "stockapp/index.html"
def get_index(request):
# Aggregate all the terms needed for each page
terms = {
"equity": Card.objects.get(word="Equity")
}

return render(request, "stockapp/index.html", {"terms": terms})

def get_stocks(request):
if request.method == "POST":
Expand Down Expand Up @@ -90,7 +94,7 @@ def get_stock_details(request, ticker):
# Fetch details about a company and display it to the user
profile = api.get_company_profile(ticker) # returns a list of dicts
history = api.get_stock_history(ticker) # returns a dict with symbol and historical list
# Aggregate all the terms needed for this page

terms = {
"beta": Card.objects.get(word="Beta"),
"volume": Card.objects.get(word="Volume"),
Expand Down

0 comments on commit 4e89d67

Please sign in to comment.