Skip to content

Commit

Permalink
feat: Add Ticker input method
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham1729 committed Dec 13, 2023
1 parent 5773bf2 commit 9fb6644
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 deletions.
8 changes: 4 additions & 4 deletions applications/backend/django_server/django_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
SECRET_KEY = DJANGO_SECRET_KEY

# SECURITY WARNING: don't run with debug turned on in production!
if ENV != "local":
DEBUG = False
else:
DEBUG = True
# if ENV != "local":
# DEBUG = False
# else:
DEBUG = True

# FORCE_SCRIPT_NAME = "/api"
ALLOWED_HOSTS = ["*"]
Expand Down
11 changes: 0 additions & 11 deletions applications/backend/django_server/news/filters.py

This file was deleted.

5 changes: 5 additions & 0 deletions applications/backend/django_server/news/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django import forms


class TickerForm(forms.Form):
ticker = forms.CharField(label="Ticker", max_length=100)
22 changes: 14 additions & 8 deletions applications/backend/django_server/news/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ <h1>Folio Feed</h1>

<p>Your Tickers:</p>
<ul>
{% for ticker in tickers %}
{% for ticker in tickers %}
<li>{{ ticker }}</li>
{% endfor %}
{% endfor %}
</ul>

<form method="post">
{% csrf_token %}
{{form}}
<input type="submit" value="Add Ticker">
</form>

<p>Here is news analysis for {{date}}:</p>
{% for analysis in analysis_items %}
<h2><a href="{% url 'news' analysis.symbol date %}">{{ analysis.symbol }}</a></h2>
<p>Avg Sentiment: {{ analysis.average_sentiment }}</p>
<p>Number of Articles: {{ analysis.total_news }}</p>
<p>Number of Positive Articles: {{ analysis.positive_news }}</p>
<p>Number of Negative Articles: {{ analysis.negative_news }}</p>
<p>Number of Neutral Articles: {{ analysis.neutral_news }}</p>
<p> Need Attention: {{analysis.need_attention}}</p>
<p>Avg Sentiment: {{ analysis.average_sentiment }}</p>
<p>Number of Articles: {{ analysis.total_news }}</p>
<p>Number of Positive Articles: {{ analysis.positive_news }}</p>
<p>Number of Negative Articles: {{ analysis.negative_news }}</p>
<p>Number of Neutral Articles: {{ analysis.neutral_news }}</p>
<p> Need Attention: {{analysis.need_attention}}</p>
{% endfor %}
</body>
</html>
9 changes: 9 additions & 0 deletions applications/backend/django_server/news/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
from django.utils import timezone
from rest_framework import viewsets

from .forms import TickerForm
from .models import Analysis, News, Ticker
from .serializers import AnalysisSerializer, NewsSerializer, TickerSerializer


def home(request):
if request.method == "POST":
form = TickerForm(request.POST)
if form.is_valid():
Ticker.objects.create(ticker=form.cleaned_data["ticker"])
else:
form = TickerForm()

tickers = Ticker.objects.all()
analysis = Analysis.objects.all().filter(
date=datetime.now().date() - timedelta(days=1)
Expand All @@ -20,6 +28,7 @@ def home(request):
"date": datetime.now().date() - timedelta(days=1),
"tickers": tickers,
"analysis_items": analysis,
"form": form,
},
)

Expand Down

0 comments on commit 9fb6644

Please sign in to comment.